diff --git a/common-files/src/main/resources/resources/default/configuration/blocks/palm_tree.yml b/common-files/src/main/resources/resources/default/configuration/blocks/palm_tree.yml index 2d2a8ca3e..d628ff0d8 100644 --- a/common-files/src/main/resources/resources/default/configuration/blocks/palm_tree.yml +++ b/common-files/src/main/resources/resources/default/configuration/blocks/palm_tree.yml @@ -198,10 +198,7 @@ items: material: oak_leaves data: item-name: - block-state: - distance: '1' - persistent: 'false' - waterlogged: 'false' + block-state: default:palm_leaves[persistent=true,waterlogged=false,distance=7] model: type: minecraft:model path: minecraft:item/custom/palm_leaves @@ -223,7 +220,7 @@ items: settings: template: default:settings/leaves states: - template: default:block_state/leaves + template: default:block_state/tintable_leaves arguments: model_path: minecraft:block/custom/palm_leaves texture_path: minecraft:block/custom/palm_leaves diff --git a/common-files/src/main/resources/resources/default/configuration/templates.yml b/common-files/src/main/resources/resources/default/configuration/templates.yml index da609c8b0..9e6140712 100644 --- a/common-files/src/main/resources/resources/default/configuration/templates.yml +++ b/common-files/src/main/resources/resources/default/configuration/templates.yml @@ -898,8 +898,7 @@ templates#block_states: appearance: axisY axis=z: appearance: axisZ - # leaves block - default:block_state/leaves: + default:block_state/__leaves__: properties: waterlogged: type: boolean @@ -913,7 +912,7 @@ templates#block_states: range: 1~7 appearances: default: - auto-state: leaves + auto-state: ${auto_state} model: path: ${model_path} generation: @@ -921,7 +920,7 @@ templates#block_states: textures: all: ${texture_path} waterlogged: - auto-state: waterlogged_leaves + auto-state: waterlogged_${auto_state} model: path: ${model_path} variants: @@ -936,6 +935,21 @@ templates#block_states: distance=7,persistent=false: settings: is-randomly-ticking: true + # any leaves block + default:block_state/leaves: + template: default:block_state/__leaves__ + arguments: + auto_state: leaves + # tintable leaves block + default:block_state/tintable_leaves: + template: default:block_state/__leaves__ + arguments: + auto_state: tintable_leaves + # non-tintable leaves block + default:block_state/non_tintable_leaves: + template: default:block_state/__leaves__ + arguments: + auto_state: non_tintable_leaves # trapdoor block default:block_state/trapdoor: properties: @@ -3400,4 +3414,4 @@ templates#loot_tables: type: uniform min: 1 max: 2 - - type: explosion_decay \ No newline at end of file + - type: explosion_decay diff --git a/core/src/main/java/net/momirealms/craftengine/core/block/AutoStateGroup.java b/core/src/main/java/net/momirealms/craftengine/core/block/AutoStateGroup.java index 3b2f2efda..333d43669 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/block/AutoStateGroup.java +++ b/core/src/main/java/net/momirealms/craftengine/core/block/AutoStateGroup.java @@ -9,13 +9,33 @@ import java.util.*; import java.util.function.Predicate; public enum AutoStateGroup { + NON_TINTABLE_LEAVES(List.of("no_tint_leaves", "leaves_no_tint", "non_tintable_leaves"), + Set.of(BlockKeys.SPRUCE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), + (w) -> !(boolean) w.getProperty("waterlogged") + ), + WATERLOGGED_NON_TINTABLE_LEAVES( + List.of("waterlogged_no_tint_leaves", "waterlogged_leaves_no_tint", "waterlogged_non_tintable_leaves"), + Set.of(BlockKeys.SPRUCE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), + (w) -> w.getProperty("waterlogged") + ), + TINTABLE_LEAVES("tintable_leaves", + Set.of(BlockKeys.OAK_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES), + (w) -> !(boolean) w.getProperty("waterlogged") + ), + WATERLOGGED_TINTABLE_LEAVES( + "waterlogged_tintable_leaves", + Set.of(BlockKeys.OAK_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES), + (w) -> w.getProperty("waterlogged") + ), LEAVES("leaves", - Set.of(BlockKeys.OAK_LEAVES, BlockKeys.SPRUCE_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), + Set.of(BlockKeys.OAK_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES, + BlockKeys.SPRUCE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), (w) -> !(boolean) w.getProperty("waterlogged") ), WATERLOGGED_LEAVES( "waterlogged_leaves", - Set.of(BlockKeys.OAK_LEAVES, BlockKeys.SPRUCE_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), + Set.of(BlockKeys.OAK_LEAVES, BlockKeys.BIRCH_LEAVES, BlockKeys.JUNGLE_LEAVES, BlockKeys.ACACIA_LEAVES, BlockKeys.DARK_OAK_LEAVES, BlockKeys.MANGROVE_LEAVES, + BlockKeys.SPRUCE_LEAVES, BlockKeys.CHERRY_LEAVES, BlockKeys.PALE_OAK_LEAVES, BlockKeys.AZALEA_LEAVES, BlockKeys.FLOWERING_AZALEA_LEAVES), (w) -> w.getProperty("waterlogged") ), LOWER_TRIPWIRE("lower_tripwire", Set.of(BlockKeys.TRIPWIRE), (w) -> w.getProperty("attached")), @@ -32,12 +52,18 @@ public enum AutoStateGroup { SOLID("solid", Set.of(BlockKeys.BROWN_MUSHROOM_BLOCK, BlockKeys.RED_MUSHROOM_BLOCK, BlockKeys.MUSHROOM_STEM, BlockKeys.NOTE_BLOCK), (w) -> true); private final Set blocks; - private final String id; + private final List id; private final Predicate predicate; private final List candidates = new ArrayList<>(); private int pointer; AutoStateGroup(String id, Set blocks, Predicate predicate) { + this.id = List.of(id); + this.blocks = blocks; + this.predicate = predicate; + } + + AutoStateGroup(List id, Set blocks, Predicate predicate) { this.id = id; this.blocks = blocks; this.predicate = predicate; @@ -80,6 +106,10 @@ public enum AutoStateGroup { } public String id() { + return id.getFirst(); + } + + public List ids() { return id; } @@ -88,10 +118,11 @@ public enum AutoStateGroup { static { for (AutoStateGroup group : AutoStateGroup.values()) { - BY_ID.put(group.id(), group); - BY_ID.put(group.id().toUpperCase(Locale.ROOT), group); - for (Key key : group.blocks) { - BY_BLOCKS.computeIfAbsent(key, k -> new ArrayList<>(4)).add(group); + for (String id : group.ids()) { + BY_ID.put(id, group); + for (Key key : group.blocks) { + BY_BLOCKS.computeIfAbsent(key, k -> new ArrayList<>(4)).add(group); + } } } }