From fe1e6172c7fc3ac979ab40083252b2967d6b3a6f Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 8 Sep 2022 18:49:58 +0200 Subject: [PATCH] Fix lava and water matching --- .../unicopia/block/state/StatePredicate.java | 10 ++++++++++ .../resources/data/unicopia/state_maps/fire.json | 15 +++++++++------ .../resources/data/unicopia/state_maps/ice.json | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java index 76f5b923..8e3c4ce7 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java @@ -106,6 +106,8 @@ public abstract class StatePredicate implements Predicate { switch (type) { case "plants": return StatePredicate::isPlant; case "ores": return StatePredicate::isOre; + case "water": return StatePredicate::isWater; + case "lava": return StatePredicate::isLava; default: throw new IllegalArgumentException("Invalid builtin type: " + type); } } @@ -118,6 +120,14 @@ public abstract class StatePredicate implements Predicate { return s.getBlock() instanceof OreBlock; } + static boolean isWater(BlockState s) { + return s.getMaterial() == Material.WATER; + } + + static boolean isLava(BlockState s) { + return s.getMaterial() == Material.LAVA; + } + public static Predicate ofState(String state) { Identifier id = new Identifier(state.split("\\{")[0]); List properties = Optional.of(state) diff --git a/src/main/resources/data/unicopia/state_maps/fire.json b/src/main/resources/data/unicopia/state_maps/fire.json index 8d051e68..6b5ba0e6 100644 --- a/src/main/resources/data/unicopia/state_maps/fire.json +++ b/src/main/resources/data/unicopia/state_maps/fire.json @@ -3,9 +3,9 @@ "entries": [ { "match": [ - { "state": "minecraft:snow" }, - { "state": "minecraft:snow_block" }, - { "builtin": "plants" } + { "state": "minecraft:snow" }, + { "state": "minecraft:snow_block" }, + { "builtin": "plants" } ], "apply": { "action": "unicopia:set_state", @@ -13,7 +13,10 @@ } }, { - "match": { "state": "minecraft:ice" }, + "match": [ + { "state": "minecraft:ice" }, + { "state": "minecraft:frosted_ice" } + ], "apply": { "action": "unicopia:set_state", "state": "minecraft:water" @@ -28,8 +31,8 @@ }, { "match": [ - { "state": "minecraft:obsidian" }, - { "state": "unicopia:frosted_obsidian" } + { "state": "minecraft:obsidian" }, + { "state": "unicopia:frosted_obsidian" } ], "apply": { "action": "unicopia:set_state", diff --git a/src/main/resources/data/unicopia/state_maps/ice.json b/src/main/resources/data/unicopia/state_maps/ice.json index 4f72deb6..e47d728e 100644 --- a/src/main/resources/data/unicopia/state_maps/ice.json +++ b/src/main/resources/data/unicopia/state_maps/ice.json @@ -9,14 +9,14 @@ } }, { - "match": { "tag": "minecraft:water" }, + "match": { "builtin": "water" }, "apply": { "action": "unicopia:set_state", "state": "minecraft:frosted_ice" } }, { - "match": { "state": "minecraft:lava" }, + "match": { "builtin": "lava" }, "apply": { "action": "unicopia:set_state", "state": "unicopia:frosted_obsidian"