diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 74d15e740..b529b1fdb 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -337,7 +337,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl d06cd9a1101b18d306a786320aab12018b1325d6 assets/create/blockstates/purple_sail.json 92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json 61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json -5d1b30c2bab556f57c78e7780fd445b08f541a50 assets/create/blockstates/radial_chassis.json +4439fc83a8c7370ab44b211a3fd48abde20a4728 assets/create/blockstates/radial_chassis.json 45877c4d90a7185c2f304edbd67379d800920439 assets/create/blockstates/red_sail.json da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json 722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json @@ -1586,7 +1586,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear 9f9455ccb5fc9e3cbfce73862b46078346a522a5 assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json e76041b7ae829fdd7dc0524f6ca4d2f89fca51bb assets/create/sounds.json -cb9641eaf33211af46daf57241c76733cf371ed2 data/create/advancements/aesthetics.json +0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 356f4855a2a6c65be3fb51d7d1aabf2ca6034d42 data/create/advancements/arm_blaze_burner.json @@ -1625,9 +1625,9 @@ acef16596b7ae82aaf853142d69bcea7094b8173 data/create/advancements/fan_smoke.json 489c58a0508a2a41cc0849dfb933eb5ac96ef364 data/create/advancements/glass_pipe.json 62f3610188f7dbd3900ab305edc2d06282705a38 data/create/advancements/goggles.json 10c8686da9cec2ae30c10f434836ac15a1b88666 data/create/advancements/hose_pulley.json -a8595e5fdf6517e5c9c790afccc99fe9d3dd95aa data/create/advancements/infinite_chocolate.json -50460d4470e9630b2d3ae1ec4f24d00d8d7c7e6b data/create/advancements/infinite_lava.json -19d9794ac08cee962c7c718085d3e3ba5e89a328 data/create/advancements/infinite_water.json +9f642faf92b75a28c564e90be8448b9a4328af5e data/create/advancements/infinite_chocolate.json +a933fa5e7217e2ffe123ae035cfbc9210ba69fd5 data/create/advancements/infinite_lava.json +a8ab0e4ffba358d23f9efaa9f51245b6d490a8be data/create/advancements/infinite_water.json 9beb622c79e9f5ce2397c22222cac0faf272f388 data/create/advancements/integrated_circuit.json 316bed3d8985d0a371200967d7edd2936f1b9f94 data/create/advancements/integrated_circuit_eob.json a80eea863bfdc7777b8bade39a81655b2f99e02f data/create/advancements/item_drain.json @@ -1638,7 +1638,7 @@ a80eea863bfdc7777b8bade39a81655b2f99e02f data/create/advancements/item_drain.jso 218568a4e416c5fa559c55a5c92aa4e93f88b837 data/create/advancements/mechanical_drill.json 6dc84ad2f0512495fe3f01f99d3c547849351e33 data/create/advancements/mechanical_saw.json 3bc549c06dc6d9568f92e1abc9654c9b4c33f035 data/create/advancements/millstone.json -6f872e1e8be9d8e5fa378db1384b1de72fadac23 data/create/advancements/mixer.json +f41d548c21a8540428ea043451e5fbb641fc2e58 data/create/advancements/mixer.json 325d4cef263ce301b143ee0498fb15afdb2c125b data/create/advancements/musical_arm.json c9c4060ed207226b69fada2d61e01a97d7077eae data/create/advancements/nixie_tube.json 9329cb210a954c0de1dcf517e7dff1ece77c19c0 data/create/advancements/overstress_flywheel.json diff --git a/src/generated/resources/assets/create/blockstates/radial_chassis.json b/src/generated/resources/assets/create/blockstates/radial_chassis.json index 04e5c08ae..8bd829ffc 100644 --- a/src/generated/resources/assets/create/blockstates/radial_chassis.json +++ b/src/generated/resources/assets/create/blockstates/radial_chassis.json @@ -207,8 +207,8 @@ }, { "when": { - "sticky_east": "true", - "axis": "x" + "axis": "x", + "sticky_east": "true" }, "apply": { "model": "create:block/radial_chassis_side_x_sticky", @@ -217,8 +217,8 @@ }, { "when": { - "sticky_east": "true", - "axis": "y" + "axis": "y", + "sticky_east": "true" }, "apply": { "model": "create:block/radial_chassis_side_y_sticky", @@ -227,8 +227,8 @@ }, { "when": { - "sticky_east": "true", - "axis": "z" + "axis": "z", + "sticky_east": "true" }, "apply": { "model": "create:block/radial_chassis_side_z_sticky" @@ -236,8 +236,8 @@ }, { "when": { - "sticky_east": "false", - "axis": "x" + "axis": "x", + "sticky_east": "false" }, "apply": { "model": "create:block/radial_chassis_side_x", @@ -246,8 +246,8 @@ }, { "when": { - "sticky_east": "false", - "axis": "y" + "axis": "y", + "sticky_east": "false" }, "apply": { "model": "create:block/radial_chassis_side_y", @@ -256,8 +256,8 @@ }, { "when": { - "sticky_east": "false", - "axis": "z" + "axis": "z", + "sticky_east": "false" }, "apply": { "model": "create:block/radial_chassis_side_z" diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index 722bd2ec7..d723cbe38 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -17,13 +17,29 @@ }, "criteria": { "0": { - "trigger": "create:bracket_shaft" + "trigger": "create:bracket_apply", + "conditions": { + "accepted_entries": [ + "create:shaft" + ] + } }, "1": { - "trigger": "create:bracket_cog" + "trigger": "create:bracket_apply", + "conditions": { + "accepted_entries": [ + "create:cogwheel", + "create:large_cogwheel" + ] + } }, "2": { - "trigger": "create:bracket_pipe" + "trigger": "create:bracket_apply", + "conditions": { + "accepted_entries": [ + "create:fluid_pipe" + ] + } } }, "requirements": [ diff --git a/src/generated/resources/data/create/advancements/infinite_chocolate.json b/src/generated/resources/data/create/advancements/infinite_chocolate.json index d192ca113..5715963c3 100644 --- a/src/generated/resources/data/create/advancements/infinite_chocolate.json +++ b/src/generated/resources/data/create/advancements/infinite_chocolate.json @@ -19,7 +19,9 @@ "0": { "trigger": "create:infinite_fluid", "conditions": { - "registry_entry": "create:chocolate" + "accepted_entries": [ + "create:chocolate" + ] } } }, diff --git a/src/generated/resources/data/create/advancements/infinite_lava.json b/src/generated/resources/data/create/advancements/infinite_lava.json index 40b98a1fd..5d634ef94 100644 --- a/src/generated/resources/data/create/advancements/infinite_lava.json +++ b/src/generated/resources/data/create/advancements/infinite_lava.json @@ -19,7 +19,9 @@ "0": { "trigger": "create:infinite_fluid", "conditions": { - "registry_entry": "minecraft:lava" + "accepted_entries": [ + "minecraft:lava" + ] } } }, diff --git a/src/generated/resources/data/create/advancements/infinite_water.json b/src/generated/resources/data/create/advancements/infinite_water.json index 0f4771011..27b8c7a64 100644 --- a/src/generated/resources/data/create/advancements/infinite_water.json +++ b/src/generated/resources/data/create/advancements/infinite_water.json @@ -19,7 +19,9 @@ "0": { "trigger": "create:infinite_fluid", "conditions": { - "registry_entry": "minecraft:water" + "accepted_entries": [ + "minecraft:water" + ] } } }, diff --git a/src/generated/resources/data/create/advancements/mixer.json b/src/generated/resources/data/create/advancements/mixer.json index ab35b7f7d..145bea240 100644 --- a/src/generated/resources/data/create/advancements/mixer.json +++ b/src/generated/resources/data/create/advancements/mixer.json @@ -25,7 +25,9 @@ "1": { "trigger": "create:kinetic_block", "conditions": { - "registry_entry": "create:mechanical_mixer" + "accepted_entries": [ + "create:mechanical_mixer" + ] } }, "2": { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java index 0763e60d9..ede978f67 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java @@ -25,7 +25,7 @@ public class FluidPipeTileEntity extends SmartTileEntity { public void addBehaviours(List behaviours) { behaviours.add(new StandardPipeFluidTransportBehaviour(this)); behaviours.add(new BracketedTileEntityBehaviour(this, this::canHaveBracket) - .withTrigger(state -> AllTriggers.BRACKET_PIPE)); + .withTrigger(state -> AllTriggers.BRACKET_APPLY_TRIGGER.constructTriggerFor(state.getBlock()))); } private boolean canHaveBracket(BlockState state) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java index ef69047a0..8bc847faf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java @@ -1,17 +1,11 @@ package com.simibubi.create.content.contraptions.relays.elementary; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Predicate; - -import com.google.common.base.Predicates; import com.simibubi.create.foundation.advancement.AllTriggers; -import com.simibubi.create.foundation.advancement.SimpleTrigger; +import com.simibubi.create.foundation.advancement.ITriggerable; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.NBTHelper; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -20,6 +14,10 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.world.World; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; + public class BracketedTileEntityBehaviour extends TileEntityBehaviour { public static BehaviourType TYPE = new BehaviourType<>(); @@ -28,10 +26,10 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { private boolean reRender; private Predicate pred; - private Function trigger; + private Function trigger; public BracketedTileEntityBehaviour(SmartTileEntity te) { - this(te, Predicates.alwaysTrue()); + this(te, state -> true); } public BracketedTileEntityBehaviour(SmartTileEntity te, Predicate pred) { @@ -40,7 +38,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { bracket = Optional.empty(); } - public BracketedTileEntityBehaviour withTrigger(Function trigger) { + public BracketedTileEntityBehaviour withTrigger(Function trigger) { this.trigger = trigger; return this; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java index df6b20f6f..ddf55f972 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/SimpleKineticTileEntity.java @@ -23,7 +23,7 @@ public class SimpleKineticTileEntity extends KineticTileEntity { public void addBehaviours(List behaviours) { behaviours.add( new BracketedTileEntityBehaviour(this, state -> state.getBlock() instanceof AbstractShaftBlock).withTrigger( - state -> state.getBlock() instanceof ShaftBlock ? AllTriggers.BRACKET_SHAFT : AllTriggers.BRACKET_COG)); + state -> AllTriggers.BRACKET_APPLY_TRIGGER.constructTriggerFor(state.getBlock()))); super.addBehaviours(behaviours); } diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java index e73c1cfc8..043b36303 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java @@ -64,9 +64,9 @@ public class AllAdvancements implements IDataProvider { Advancement aesthetics = advancement("aesthetics", AllBlocks.WOODEN_BRACKET.get(), TaskType.NORMAL).withParent(andesite_alloy) - .withCriterion("0", AllTriggers.BRACKET_SHAFT.instance()) - .withCriterion("1", AllTriggers.BRACKET_COG.instance()) - .withCriterion("2", AllTriggers.BRACKET_PIPE.instance()) + .withCriterion("0", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.SHAFT.get())) + .withCriterion("1", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.COGWHEEL.get(), AllBlocks.LARGE_COGWHEEL.get())) + .withCriterion("2", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.FLUID_PIPE.get())) .register(t, id + ":aesthetics"); Advancement reinforced = @@ -497,11 +497,11 @@ public class AllAdvancements implements IDataProvider { } public RegistryTrigger.Instance isPowered(Block block) { - return AllTriggers.KINETIC_BLOCK.forEntry(block); + return AllTriggers.KINETIC_BLOCK.forEntries(block); } public RegistryTrigger.Instance isInfinite(FlowingFluid fluid) { - return AllTriggers.INFINITE_FLUID.forEntry(fluid.getStillFluid()); + return AllTriggers.INFINITE_FLUID.forEntries(fluid.getStillFluid()); } public InventoryChangeTrigger.Instance itemGathered(IItemProvider itemprovider) { diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java index 67b5f2332..c98942bc1 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java @@ -19,6 +19,7 @@ public class AllTriggers { public static RegistryTrigger KINETIC_BLOCK = add(new RegistryTrigger<>("kinetic_block", Block.class)); public static RegistryTrigger INFINITE_FLUID = add(new RegistryTrigger<>("infinite_fluid", Fluid.class)); + public static RegistryTrigger BRACKET_APPLY_TRIGGER = add(new RegistryTrigger<>("bracket_apply", Block.class)); public static SimpleTrigger ROTATION = simple("rotation"), @@ -40,9 +41,6 @@ public class AllTriggers { MECHANICAL_ARM = simple("mechanical_arm"), MUSICAL_ARM = simple("musical_arm"), CUCKOO = simple("cuckoo"), - BRACKET_SHAFT = simple("bracket_shaft"), - BRACKET_COG = simple("bracket_cog"), - BRACKET_PIPE = simple("bracket_pipe"), CASING_SHAFT = simple("casing_shaft"), CASING_BELT = simple("casing_belt"), CASING_PIPE = simple("casing_pipe"), diff --git a/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java b/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java index 14006415b..368c3bc3c 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/CriterionTriggerBase.java @@ -77,7 +77,7 @@ public abstract class CriterionTriggerBase> extends Criterion this.registryType = registryType; } - public Instance forEntry(@Nullable T registryEntry) { - return new Instance<>(getId(), registryEntry); + @SafeVarargs + public final Instance forEntries(@Nullable T... entries) { + return new Instance<>(getId(), entries == null ? null : Sets.newHashSet(entries)); } public void trigger(ServerPlayerEntity player, T registryEntry) { trigger(player, Collections.singletonList(() -> registryEntry)); } - @Override - public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) { - T entry = null; - if (json.has("registry_entry")) { - ResourceLocation entryLocation = new ResourceLocation(JSONUtils.getString(json, "registry_entry")); - entry = RegistryManager.ACTIVE.getRegistry(registryType).getValue(entryLocation); - - if (entry == null) - throw new JsonSyntaxException("Unknown registry entry '" + entryLocation + "'"); - } - - return forEntry(entry); + public ITriggerable constructTriggerFor(T entry) { + BiConsumer trigger = this::trigger; + return player -> trigger.accept(player, entry); } + @Override + public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) { + if (json.has("accepted_entries")) { + JsonArray elements = json.getAsJsonArray("accepted_entries"); + IForgeRegistry registry = RegistryManager.ACTIVE.getRegistry(registryType); + + return new Instance<>(getId(), + StreamSupport.stream(elements.spliterator(), false).map(JsonElement::getAsString).map(ResourceLocation::new) + .map(rl -> { + T entry = registry.getValue(rl); + if (entry == null) + throw new JsonSyntaxException("Unknown registry entry '" + rl + "'"); + return entry; + }).collect(Collectors.toSet())); + } + + return forEntries((T) null); + } public static class Instance> extends CriterionTriggerBase.Instance { @Nullable - private final T entry; + private final Set entries; - public Instance(ResourceLocation id, @Nullable T registryEntry) { + public Instance(ResourceLocation id, @Nullable Set registryEntries) { super(id); - entry = registryEntry; + entries = registryEntries; } @Override protected boolean test(@Nullable List> suppliers) { - if (entry == null || suppliers == null || suppliers.isEmpty()) + if (entries == null || suppliers == null || suppliers.isEmpty()) return false; - return entry.equals(suppliers.get(0).get()); + return entries.contains(suppliers.get(0).get()); } @Override public JsonElement serialize() { JsonObject jsonobject = new JsonObject(); - if (entry == null) - return jsonobject; + JsonArray elements = new JsonArray(); - ResourceLocation key = RegistryManager.ACTIVE.getRegistry(entry.getRegistryType()).getKey(entry); - if (key != null) { - jsonobject.addProperty("registry_entry", key.toString()); + if (entries == null) { + jsonobject.add("accepted_entries", elements); + return jsonobject; } + + for (T entry : entries) { + if (entry == null) + continue; + ResourceLocation key = RegistryManager.ACTIVE.getRegistry(entry.getRegistryType()).getKey(entry); + if (key != null) + elements.add(key.toString()); + } + + jsonobject.add("accepted_entries", elements); return jsonobject; } }