2020-08-08 23:16:22 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2020-08-09 13:32:08 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2020-08-09 12:40:33 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour;
|
2020-08-09 13:32:08 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.actors.CampfireMovementBehaviour;
|
2020-08-08 23:16:22 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
|
|
|
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
2020-08-09 13:32:08 +02:00
|
|
|
|
2020-08-08 23:16:22 +02:00
|
|
|
import net.minecraft.block.Block;
|
2020-08-09 12:40:33 +02:00
|
|
|
import net.minecraft.block.Blocks;
|
2020-08-08 23:16:22 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
|
|
|
public class AllMovementBehaviours {
|
|
|
|
private static final HashMap<ResourceLocation, MovementBehaviour> movementBehaviours = new HashMap<>();
|
|
|
|
|
2020-08-09 14:36:07 +02:00
|
|
|
public static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) {
|
|
|
|
if (movementBehaviours.containsKey(resourceLocation))
|
|
|
|
Create.logger.warn("Movement behaviour for " + resourceLocation.toString() + " was overridden");
|
2020-08-08 23:16:22 +02:00
|
|
|
movementBehaviours.put(resourceLocation, movementBehaviour);
|
|
|
|
}
|
|
|
|
|
2020-08-09 13:32:08 +02:00
|
|
|
public static void addMovementBehaviour(Block block, MovementBehaviour movementBehaviour) {
|
|
|
|
addMovementBehaviour(block.getRegistryName(), movementBehaviour);
|
|
|
|
}
|
|
|
|
|
2020-08-08 23:16:22 +02:00
|
|
|
@Nullable
|
|
|
|
public static MovementBehaviour getMovementBehaviour(ResourceLocation resourceLocation) {
|
|
|
|
return movementBehaviours.getOrDefault(resourceLocation, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static MovementBehaviour getMovementBehaviour(Block block) {
|
|
|
|
return getMovementBehaviour(block.getRegistryName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean hasMovementBehaviour(Block block) {
|
|
|
|
return movementBehaviours.containsKey(block.getRegistryName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <B extends Block> NonNullConsumer<? super B> addMovementBehaviour(
|
|
|
|
MovementBehaviour movementBehaviour) {
|
|
|
|
return b -> addMovementBehaviour(b.getRegistryName(), movementBehaviour);
|
|
|
|
}
|
|
|
|
|
2020-08-09 12:40:33 +02:00
|
|
|
static void register() {
|
2020-08-09 13:32:08 +02:00
|
|
|
addMovementBehaviour(Blocks.BELL, new BellMovementBehaviour());
|
|
|
|
addMovementBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour());
|
2020-08-09 12:40:33 +02:00
|
|
|
}
|
2020-08-08 23:16:22 +02:00
|
|
|
}
|