From 348409a0a46b6d970b99c5aba613bdcb114525e5 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Sun, 9 Aug 2020 14:36:07 +0200 Subject: [PATCH] Movement behaviour registration changes - buffering SeatMovementBehaviour - changed visibility of AllMovementBehaviours.addMovementBehaviour(ResourceLocation, MovementBehaviour) to public for easier mod compat - added console warn message when something tries to register more than one movement behaviour per block --- src/main/java/com/simibubi/create/AllBlocks.java | 3 ++- src/main/java/com/simibubi/create/AllMovementBehaviours.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 983e9d35f..6e293278b 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -669,9 +669,10 @@ public class AllBlocks { static { for (DyeColor colour : DyeColor.values()) { String colourName = colour.getName(); + SeatMovementBehaviour movementBehaviour = new SeatMovementBehaviour(); REGISTRATE.block(colourName + "_seat", p -> new SeatBlock(p, colour == DyeColor.RED)) .initialProperties(SharedProperties::wooden) - .onRegister(AllMovementBehaviours.addMovementBehaviour(new SeatMovementBehaviour())) + .onRegister(AllMovementBehaviours.addMovementBehaviour(movementBehaviour)) .blockstate((c, p) -> { p.simpleBlock(c.get(), p.models() .withExistingParent(colourName + "_seat", p.modLoc("block/seat")) diff --git a/src/main/java/com/simibubi/create/AllMovementBehaviours.java b/src/main/java/com/simibubi/create/AllMovementBehaviours.java index 5032ace15..bc5274f2d 100644 --- a/src/main/java/com/simibubi/create/AllMovementBehaviours.java +++ b/src/main/java/com/simibubi/create/AllMovementBehaviours.java @@ -16,7 +16,9 @@ import net.minecraft.util.ResourceLocation; public class AllMovementBehaviours { private static final HashMap movementBehaviours = new HashMap<>(); - private static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) { + public static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) { + if (movementBehaviours.containsKey(resourceLocation)) + Create.logger.warn("Movement behaviour for " + resourceLocation.toString() + " was overridden"); movementBehaviours.put(resourceLocation, movementBehaviour); }