mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 07:24:32 +01:00
6c390977d8
- Refactor AllContainerTypes to use Registrate - Replace RegistryEntry in AllEntityTypes and AllFluids with EntityEntry and FluidEntry, respectively - Make AllEntityTypes use Registrate to register entity renderers instead of a separate method - Refactor AllColorHandlers - Fix error when a POI block is moved by a contraption - Rename some static final fields to be upper snake case - Make static fields in Create and CreateClient final - Add I prefix to Coordinate interface - Fix typo (BracketedTileEntityBehaviour#isBacketPresent) - Make mixins go in alphabetical order - Make pack.mcmeta use 2 spaces for indents
65 lines
2.4 KiB
Java
65 lines
2.4 KiB
Java
package com.simibubi.create;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour;
|
|
import com.simibubi.create.content.contraptions.components.actors.CampfireMovementBehaviour;
|
|
import com.simibubi.create.content.contraptions.components.actors.dispenser.DispenserMovementBehaviour;
|
|
import com.simibubi.create.content.contraptions.components.actors.dispenser.DropperMovementBehaviour;
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
|
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.Blocks;
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
public class AllMovementBehaviours {
|
|
private static final HashMap<ResourceLocation, MovementBehaviour> MOVEMENT_BEHAVIOURS = new HashMap<>();
|
|
|
|
public static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) {
|
|
if (MOVEMENT_BEHAVIOURS.containsKey(resourceLocation))
|
|
Create.LOGGER.warn("Movement behaviour for " + resourceLocation.toString() + " was overridden");
|
|
MOVEMENT_BEHAVIOURS.put(resourceLocation, movementBehaviour);
|
|
}
|
|
|
|
public static void addMovementBehaviour(Block block, MovementBehaviour movementBehaviour) {
|
|
addMovementBehaviour(block.getRegistryName(), movementBehaviour);
|
|
}
|
|
|
|
@Nullable
|
|
public static MovementBehaviour of(ResourceLocation resourceLocation) {
|
|
return MOVEMENT_BEHAVIOURS.getOrDefault(resourceLocation, null);
|
|
}
|
|
|
|
@Nullable
|
|
public static MovementBehaviour of(Block block) {
|
|
return of(block.getRegistryName());
|
|
}
|
|
|
|
@Nullable
|
|
public static MovementBehaviour of(BlockState state) {
|
|
return of(state.getBlock());
|
|
}
|
|
|
|
public static boolean contains(Block block) {
|
|
return MOVEMENT_BEHAVIOURS.containsKey(block.getRegistryName());
|
|
}
|
|
|
|
public static <B extends Block> NonNullConsumer<? super B> addMovementBehaviour(
|
|
MovementBehaviour movementBehaviour) {
|
|
return b -> addMovementBehaviour(b.getRegistryName(), movementBehaviour);
|
|
}
|
|
|
|
static void register() {
|
|
addMovementBehaviour(Blocks.BELL, new BellMovementBehaviour());
|
|
addMovementBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour());
|
|
|
|
DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours();
|
|
addMovementBehaviour(Blocks.DISPENSER, new DispenserMovementBehaviour());
|
|
addMovementBehaviour(Blocks.DROPPER, new DropperMovementBehaviour());
|
|
}
|
|
}
|