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
This commit is contained in:
LordGrimmauld 2020-08-09 14:36:07 +02:00
parent 2675d6ae2f
commit 348409a0a4
2 changed files with 5 additions and 2 deletions

View file

@ -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"))

View file

@ -16,7 +16,9 @@ import net.minecraft.util.ResourceLocation;
public class AllMovementBehaviours {
private static final HashMap<ResourceLocation, MovementBehaviour> 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);
}