mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
feat(bukkit): 添加作物方块条件判断和部分配置
This commit is contained in:
@@ -4,6 +4,7 @@ i18n:
|
||||
item.fairy_flower: "Fairy Flower"
|
||||
item.reed: "Reed"
|
||||
item.flame_cane: "Flame Cane"
|
||||
item.ender_pearl_crop_seed: "Ender Pearl Flower Seeds"
|
||||
item.bench: "Bench"
|
||||
item.table_lamp: "Table Lamp"
|
||||
item.wooden_chair: "Wooden Chair"
|
||||
@@ -43,6 +44,7 @@ i18n:
|
||||
item.fairy_flower: "仙灵花"
|
||||
item.reed: "芦苇"
|
||||
item.flame_cane: "烈焰甘蔗"
|
||||
item.ender_pearl_crop_seed: "末影珍珠花种子"
|
||||
item.bench: "长椅"
|
||||
item.table_lamp: "台灯"
|
||||
item.wooden_chair: "木椅"
|
||||
|
||||
@@ -35,6 +35,18 @@ items:
|
||||
behavior:
|
||||
type: block_item
|
||||
block: default:flame_cane
|
||||
default:ender_pearl_crop_seed:
|
||||
material: paper
|
||||
custom-model-data: 4003
|
||||
data:
|
||||
item-name: "<!i><i18n:item.ender_pearl_crop_seed>"
|
||||
model:
|
||||
template: default:model/simplified_generated
|
||||
arguments:
|
||||
path: "minecraft:item/custom/ender_pearl_crop_seed"
|
||||
behavior:
|
||||
type: block_item
|
||||
block: default:ender_pearl_crop
|
||||
blocks:
|
||||
default:fairy_flower:
|
||||
settings:
|
||||
@@ -167,6 +179,120 @@ blocks:
|
||||
age=5:
|
||||
appearance: default
|
||||
id: 7
|
||||
default:ender_pearl_crop:
|
||||
settings:
|
||||
template:
|
||||
- default:hardness/none
|
||||
- default:sound/grass
|
||||
overrides:
|
||||
item: default:ender_pearl_crop_seed
|
||||
push-reaction: DESTROY
|
||||
map-color: 15
|
||||
is-randomly-ticking: true
|
||||
behavior:
|
||||
type: crop_block
|
||||
grow-speed: 1
|
||||
min-grow-light: 9
|
||||
bottom-blocks:
|
||||
- minecraft:end_stone
|
||||
loot:
|
||||
pools:
|
||||
- rolls: 1
|
||||
entries:
|
||||
- type: alternatives
|
||||
children:
|
||||
- type: item
|
||||
item: "default:ender_pearl_crop_seed"
|
||||
conditions:
|
||||
- type: survives_explosion
|
||||
- type: item
|
||||
item: "minecraft:ender_pearl"
|
||||
conditions:
|
||||
- type: crop_ripe
|
||||
functions:
|
||||
- type: apply_bonus
|
||||
enchantment: minecraft:fortune
|
||||
formula:
|
||||
type: ore_drops
|
||||
- type: explosion_decay
|
||||
count:
|
||||
type: uniform
|
||||
min: "1"
|
||||
max: "5"
|
||||
states:
|
||||
properties:
|
||||
age:
|
||||
type: int
|
||||
default: 0
|
||||
range: 0~5
|
||||
appearances:
|
||||
default:
|
||||
state: "sugar_cane:3"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage1"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage1"
|
||||
age1:
|
||||
state: "sugar_cane:4"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage2"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage2"
|
||||
age2:
|
||||
state: "sugar_cane:5"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage3"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage3"
|
||||
age3:
|
||||
state: "sugar_cane:6"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage4"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage4"
|
||||
age4:
|
||||
state: "sugar_cane:7"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage5"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage5"
|
||||
age5:
|
||||
state: "sugar_cane:8"
|
||||
models:
|
||||
- path: "minecraft:block/custom/ender_pearl_crop_stage6"
|
||||
generation:
|
||||
parent: "minecraft:block/crop"
|
||||
textures:
|
||||
"crop": "minecraft:block/custom/ender_pearl_crop_stage6"
|
||||
variants:
|
||||
age=0:
|
||||
appearance: default
|
||||
id: 8
|
||||
age=1:
|
||||
appearance: age1
|
||||
id: 9
|
||||
age=2:
|
||||
appearance: age2
|
||||
id: 10
|
||||
age=3:
|
||||
appearance: age3
|
||||
id: 11
|
||||
age=4:
|
||||
appearance: age4
|
||||
id: 12
|
||||
age=5:
|
||||
appearance: age5
|
||||
id: 13
|
||||
recipes:
|
||||
default:paper_from_reed:
|
||||
type: shaped
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.bukkit.block;
|
||||
|
||||
import io.papermc.paper.event.block.BlockBreakBlockEvent;
|
||||
import net.momirealms.craftengine.bukkit.api.event.CustomBlockBreakEvent;
|
||||
import net.momirealms.craftengine.bukkit.block.behavior.CropBlockBehavior;
|
||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
||||
import net.momirealms.craftengine.bukkit.util.*;
|
||||
@@ -138,6 +139,9 @@ public class BlockEventListener implements Listener {
|
||||
builder.withParameter(LootParameters.LOCATION, vec3d);
|
||||
builder.withParameter(LootParameters.PLAYER, serverPlayer);
|
||||
builder.withOptionalParameter(LootParameters.TOOL, itemInHand);
|
||||
if (state.behavior() instanceof CropBlockBehavior) {
|
||||
builder.withParameter(LootParameters.CROP_BLOCK, true);
|
||||
}
|
||||
for (Item<Object> item : state.getDrops(builder, world)) {
|
||||
world.dropItemNaturally(vec3d, item);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.momirealms.craftengine.core.loot.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.loot.LootContext;
|
||||
import net.momirealms.craftengine.core.loot.parameter.LootParameters;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CropRipeCondition implements LootCondition {
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static final CropRipeCondition INSTANCE = new CropRipeCondition();
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return LootConditions.CROP_RIPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(LootContext lootContext) {
|
||||
return lootContext.getOptionalParameter(LootParameters.CROP_BLOCK).orElse(false);
|
||||
}
|
||||
|
||||
public static class Factory implements LootConditionFactory {
|
||||
@Override
|
||||
public LootCondition create(Map<String, Object> arguments) {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class LootConditions {
|
||||
public static final Key ENCHANTMENT = Key.from("craftengine:enchantment");
|
||||
public static final Key INVERTED = Key.from("craftengine:inverted");
|
||||
public static final Key FALLING_BLOCK = Key.from("craftengine:falling_block");
|
||||
public static final Key CROP_RIPE = Key.from("craftengine:crop_ripe");
|
||||
|
||||
static {
|
||||
register(MATCH_ITEM, MatchItemCondition.FACTORY);
|
||||
@@ -31,6 +32,7 @@ public class LootConditions {
|
||||
register(ENCHANTMENT, EnchantmentCondition.FACTORY);
|
||||
register(INVERTED, InvertedCondition.FACTORY);
|
||||
register(FALLING_BLOCK, FallingCondition.FACTORY);
|
||||
register(CROP_RIPE, CropRipeCondition.FACTORY);
|
||||
}
|
||||
|
||||
public static void register(Key key, LootConditionFactory factory) {
|
||||
|
||||
@@ -18,4 +18,5 @@ public class LootParameters {
|
||||
public static final ContextKey<Player> PLAYER = new ContextKey<>(Key.of("craftengine:player"));
|
||||
public static final ContextKey<Item<?>> TOOL = new ContextKey<>(Key.of("craftengine:tool"));
|
||||
public static final ContextKey<ImmutableBlockState> BLOCK_STATE = new ContextKey<>(Key.of("craftengine:block_state"));
|
||||
public static final ContextKey<Boolean> CROP_BLOCK = new ContextKey<>(Key.of("craftengine:crop_block"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user