movement behaviour hash map

This commit is contained in:
LordGrimmauld 2020-08-08 23:16:22 +02:00
parent e15c19222f
commit 9bf81f4d7f
16 changed files with 115 additions and 101 deletions

View file

@ -12,10 +12,16 @@ import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.AllSections;
import com.simibubi.create.content.contraptions.base.CasingBlock;
import com.simibubi.create.content.contraptions.components.actors.DrillBlock;
import com.simibubi.create.content.contraptions.components.actors.DrillMovementBehaviour;
import com.simibubi.create.content.contraptions.components.actors.HarvesterBlock;
import com.simibubi.create.content.contraptions.components.actors.HarvesterMovementBehaviour;
import com.simibubi.create.content.contraptions.components.actors.PloughBlock;
import com.simibubi.create.content.contraptions.components.actors.PloughMovementBehaviour;
import com.simibubi.create.content.contraptions.components.actors.PortableStorageInterfaceBlock;
import com.simibubi.create.content.contraptions.components.actors.SawMovementBehaviour;
import com.simibubi.create.content.contraptions.components.actors.SeatBlock;
import com.simibubi.create.content.contraptions.components.actors.SeatMovementBehaviour;
import com.simibubi.create.content.contraptions.components.actors.StorageInterfaceMovement;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockBlock;
import com.simibubi.create.content.contraptions.components.crafter.CrafterCTBehaviour;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterBlock;
@ -23,6 +29,7 @@ import com.simibubi.create.content.contraptions.components.crank.HandCrankBlock;
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelBlock;
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerBlock;
import com.simibubi.create.content.contraptions.components.deployer.DeployerBlock;
import com.simibubi.create.content.contraptions.components.deployer.DeployerMovementBehaviour;
import com.simibubi.create.content.contraptions.components.fan.EncasedFanBlock;
import com.simibubi.create.content.contraptions.components.fan.NozzleBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
@ -98,6 +105,7 @@ import com.simibubi.create.content.logistics.block.diodes.PulseRepeaterGenerator
import com.simibubi.create.content.logistics.block.diodes.ToggleLatchBlock;
import com.simibubi.create.content.logistics.block.diodes.ToggleLatchGenerator;
import com.simibubi.create.content.logistics.block.extractor.ExtractorBlock;
import com.simibubi.create.content.logistics.block.extractor.ExtractorMovementBehaviour;
import com.simibubi.create.content.logistics.block.extractor.LinkedExtractorBlock;
import com.simibubi.create.content.logistics.block.extractor.VerticalExtractorGenerator;
import com.simibubi.create.content.logistics.block.funnel.AndesiteBeltFunnelBlock;
@ -114,6 +122,7 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmBlock;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmItem;
import com.simibubi.create.content.logistics.block.packager.PackagerBlock;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverBlock;
import com.simibubi.create.content.logistics.block.redstone.ContactMovementBehaviour;
import com.simibubi.create.content.logistics.block.redstone.NixieTubeBlock;
import com.simibubi.create.content.logistics.block.redstone.NixieTubeGenerator;
import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock;
@ -605,6 +614,7 @@ public class AllBlocks {
.initialProperties(SharedProperties::stone)
.blockstate(BlockStateGen.directionalBlockProvider(true))
.transform(StressConfigDefaults.setImpact(4.0))
.onRegister(AllMovementBehaviours.addMovementBehaviour(new DrillMovementBehaviour()))
.item()
.transform(customItemModel())
.register();
@ -613,6 +623,7 @@ public class AllBlocks {
.initialProperties(SharedProperties::stone)
.blockstate(new SawGenerator()::generate)
.transform(StressConfigDefaults.setImpact(4.0))
.onRegister(AllMovementBehaviours.addMovementBehaviour(new SawMovementBehaviour()))
.addLayer(() -> RenderType::getCutoutMipped)
.item()
.model((c, p) -> p.blockItem(() -> c.getEntry()
@ -624,6 +635,7 @@ public class AllBlocks {
.initialProperties(SharedProperties::stone)
.blockstate(BlockStateGen.directionalAxisBlockProvider())
.transform(StressConfigDefaults.setImpact(4.0))
.onRegister(AllMovementBehaviours.addMovementBehaviour(new DeployerMovementBehaviour()))
.item()
.transform(customItemModel())
.register();
@ -631,6 +643,7 @@ public class AllBlocks {
public static final BlockEntry<PortableStorageInterfaceBlock> PORTABLE_STORAGE_INTERFACE =
REGISTRATE.block("portable_storage_interface", PortableStorageInterfaceBlock::new)
.initialProperties(SharedProperties::stone)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new StorageInterfaceMovement()))
.blockstate(BlockStateGen.directionalBlockProvider(false))
.simpleItem()
.register();
@ -638,6 +651,7 @@ public class AllBlocks {
public static final BlockEntry<HarvesterBlock> MECHANICAL_HARVESTER =
REGISTRATE.block("mechanical_harvester", HarvesterBlock::new)
.initialProperties(SharedProperties::stone)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new HarvesterMovementBehaviour()))
.blockstate(BlockStateGen.horizontalBlockProvider(true))
.addLayer(() -> RenderType::getCutoutMipped)
.item()
@ -647,6 +661,7 @@ public class AllBlocks {
public static final BlockEntry<PloughBlock> MECHANICAL_PLOUGH =
REGISTRATE.block("mechanical_plough", PloughBlock::new)
.initialProperties(SharedProperties::stone)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new PloughMovementBehaviour()))
.blockstate(BlockStateGen.horizontalBlockProvider(false))
.simpleItem()
.register();
@ -656,6 +671,7 @@ public class AllBlocks {
String colourName = colour.getName();
REGISTRATE.block(colourName + "_seat", p -> new SeatBlock(p, colour == DyeColor.RED))
.initialProperties(SharedProperties::wooden)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new SeatMovementBehaviour()))
.blockstate((c, p) -> {
p.simpleBlock(c.get(), p.models()
.withExistingParent(colourName + "_seat", p.modLoc("block/seat"))
@ -812,6 +828,7 @@ public class AllBlocks {
public static final BlockEntry<RedstoneContactBlock> REDSTONE_CONTACT =
REGISTRATE.block("redstone_contact", RedstoneContactBlock::new)
.initialProperties(SharedProperties::stone)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new ContactMovementBehaviour()))
.blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.forPowered(c, p)))
.item()
.transform(customItemModel("_", "block"))
@ -878,6 +895,7 @@ public class AllBlocks {
public static final BlockEntry<ExtractorBlock> EXTRACTOR = REGISTRATE.block("extractor", ExtractorBlock::new)
.initialProperties(SharedProperties::softMetal)
.tag(AllBlockTags.BRITTLE.tag)
.onRegister(AllMovementBehaviours.addMovementBehaviour(new ExtractorMovementBehaviour()))
.blockstate((c, p) -> p.horizontalBlock(c.get(), AssetLookup.forPowered(c, p, c.getName() + "/horizontal")))
.item()
.transform(customItemModel("_", "horizontal"))

View file

@ -0,0 +1,38 @@
package com.simibubi.create;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.tterrag.registrate.util.nullness.NonNullConsumer;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
import java.util.HashMap;
public class AllMovementBehaviours {
private static final HashMap<ResourceLocation, MovementBehaviour> movementBehaviours = new HashMap<>();
public static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) {
movementBehaviours.put(resourceLocation, movementBehaviour);
}
@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);
}
static void register() {}
}

View file

@ -63,6 +63,7 @@ public class Create {
AllPaletteBlocks.register();
AllEntityTypes.register();
AllTileEntities.register();
AllMovementBehaviours.register();
modEventBus.addListener(Create::init);
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register);

View file

@ -1,9 +1,9 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
@ -18,7 +18,11 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
public abstract class AttachedActorBlock extends HorizontalBlock implements IPortableBlock, IWrenchable {
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class AttachedActorBlock extends HorizontalBlock implements IWrenchable {
protected AttachedActorBlock(Properties p_i48377_1_) {
super(p_i48377_1_);

View file

@ -3,8 +3,6 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.foundation.block.ITE;
import net.minecraft.block.Block;
@ -25,9 +23,12 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
public class DrillBlock extends DirectionalKineticBlock implements IPortableBlock, ITE<DrillTileEntity> {
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
public static MovementBehaviour MOVEMENT = new DrillMovementBehaviour();
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTileEntity> {
public static DamageSource damageSourceDrill = new DamageSource("create.drill").setDamageBypassesArmor();
public DrillBlock(Properties properties) {
@ -83,11 +84,6 @@ public class DrillBlock extends DirectionalKineticBlock implements IPortableBloc
return PushReaction.NORMAL;
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
@Override
public Class<DrillTileEntity> getTileEntityClass() {
return DrillTileEntity.class;

View file

@ -1,16 +1,12 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class HarvesterBlock extends AttachedActorBlock implements IPortableBlock {
public static MovementBehaviour MOVEMENT = new HarvesterMovementBehaviour();
public class HarvesterBlock extends AttachedActorBlock {
public HarvesterBlock(Properties p_i48377_1_) {
super(p_i48377_1_);
@ -25,10 +21,4 @@ public class HarvesterBlock extends AttachedActorBlock implements IPortableBlock
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new HarvesterTileEntity(AllTileEntities.HARVESTER.get());
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
}

View file

@ -9,17 +9,10 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.FakePlayer;
public class PloughBlock extends AttachedActorBlock {
public static MovementBehaviour MOVEMENT = new PloughMovementBehaviour();
public PloughBlock(Properties p_i48377_1_) {
super(p_i48377_1_);
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
/**
* The OnHoeUse event takes a player, so we better not pass null

View file

@ -1,8 +1,6 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import net.minecraft.block.BlockState;
@ -12,9 +10,13 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
public class PortableStorageInterfaceBlock extends ProperDirectionalBlock implements IPortableBlock {
public static MovementBehaviour MOVEMENT = new StorageInterfaceMovement();
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class PortableStorageInterfaceBlock extends ProperDirectionalBlock {
public PortableStorageInterfaceBlock(Properties p_i48415_1_) {
super(p_i48415_1_);
@ -31,9 +33,4 @@ public class PortableStorageInterfaceBlock extends ProperDirectionalBlock implem
return AllShapes.PORTABLE_STORAGE_INTERFACE.get(state.get(FACING));
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
}

View file

@ -3,8 +3,6 @@ package com.simibubi.create.content.contraptions.components.actors;
import java.util.List;
import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -27,10 +25,16 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class SeatBlock extends Block implements IPortableBlock {
public static MovementBehaviour MOVEMENT = new SeatMovementBehaviour();
private boolean inCreativeTab;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class SeatBlock extends Block {
private final boolean inCreativeTab;
public SeatBlock(Properties p_i48440_1_, boolean inCreativeTab) {
super(p_i48440_1_);
@ -63,7 +67,7 @@ public class SeatBlock extends Block implements IPortableBlock {
}
@Override
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, MobEntity entity) {
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity) {
return PathNodeType.RAIL;
}
@ -118,8 +122,4 @@ public class SeatBlock extends Block implements IPortableBlock {
entity.startRiding(seat, true);
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
}

View file

@ -4,8 +4,6 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
@ -25,9 +23,12 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<DeployerTileEntity>, IPortableBlock {
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
public static MovementBehaviour MOVEMENT = new DeployerMovementBehaviour();
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<DeployerTileEntity> {
public DeployerBlock(Properties properties) {
super(properties);
@ -102,11 +103,6 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
return ActionResultType.SUCCESS;
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
@Override
public Class<DeployerTileEntity> getTileEntityClass() {
return DeployerTileEntity.class;

View file

@ -3,9 +3,6 @@ package com.simibubi.create.content.contraptions.components.saw;
import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.components.actors.SawMovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -32,11 +29,15 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTileEntity>, IPortableBlock {
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTileEntity> {
public static final BooleanProperty RUNNING = BooleanProperty.create("running");
public static DamageSource damageSourceSaw = new DamageSource("create.saw").setDamageBypassesArmor();
public static MovementBehaviour MOVEMENT = new SawMovementBehaviour();
public SawBlock(Properties properties) {
super(properties);
@ -127,11 +128,6 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTile
worldIn.removeTileEntity(pos);
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
@Override
public Class<SawTileEntity> getTileEntityClass() {
return SawTileEntity.class;

View file

@ -17,6 +17,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.simibubi.create.AllMovementBehaviours;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
@ -146,9 +147,9 @@ public abstract class Contraption {
protected static MovementBehaviour getMovement(BlockState state) {
Block block = state.getBlock();
if (!(block instanceof IPortableBlock))
if (!AllMovementBehaviours.hasMovementBehaviour(block))
return null;
return ((IPortableBlock) block).getMovementBehaviour();
return AllMovementBehaviours.getMovementBehaviour(block);
}
public Set<BlockPos> getColliders(World world, Direction movementDirection) {
@ -439,7 +440,7 @@ public abstract class Contraption {
TileEntity te = pair.getValue();
if (te != null && MountedStorage.canUseAsStorage(te))
storage.put(localPos, new MountedStorage(te));
if (captured.state.getBlock() instanceof IPortableBlock)
if (AllMovementBehaviours.hasMovementBehaviour(captured.state.getBlock()))
actors.add(MutablePair.of(blockInfo, null));
}
@ -463,7 +464,7 @@ public abstract class Contraption {
else
renderOrder.add(0, info.pos);
CompoundNBT tag = info.nbt;
if (tag == null || block instanceof IPortableBlock)
if (tag == null || AllMovementBehaviours.hasMovementBehaviour(block))
return;
tag.putInt("x", info.pos.getX());

View file

@ -9,6 +9,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import com.simibubi.create.AllMovementBehaviours;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.lang3.mutable.MutableObject;
@ -393,11 +394,11 @@ public class ContraptionCollider {
BlockState collidedState = world.getBlockState(colliderPos);
BlockInfo blockInfo = contraption.blocks.get(pos);
if (blockInfo.state.getBlock() instanceof IPortableBlock) {
IPortableBlock block = (IPortableBlock) blockInfo.state.getBlock();
if (block.getMovementBehaviour() instanceof BlockBreakingMovementBehaviour) {
if (AllMovementBehaviours.hasMovementBehaviour(blockInfo.state.getBlock())) {
MovementBehaviour movementBehaviour = AllMovementBehaviours.getMovementBehaviour(blockInfo.state.getBlock());
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour =
(BlockBreakingMovementBehaviour) block.getMovementBehaviour();
(BlockBreakingMovementBehaviour) movementBehaviour;
if (!behaviour.canBreak(world, colliderPos, collidedState)
&& !collidedState.getCollisionShape(world, pos)
.isEmpty()) {

View file

@ -1,7 +0,0 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
public interface IPortableBlock {
public MovementBehaviour getMovementBehaviour();
}

View file

@ -3,8 +3,6 @@ package com.simibubi.create.content.logistics.block.extractor;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.logistics.block.AttachedLogisticalBlock;
import com.simibubi.create.content.logistics.block.belts.BeltAttachableLogisticalBlock;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -25,10 +23,9 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class ExtractorBlock extends BeltAttachableLogisticalBlock implements IPortableBlock {
public class ExtractorBlock extends BeltAttachableLogisticalBlock {
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
private static final MovementBehaviour MOVEMENT = new ExtractorMovementBehaviour();
public ExtractorBlock(Properties properties) {
super(properties);
@ -127,9 +124,4 @@ public class ExtractorBlock extends BeltAttachableLogisticalBlock implements IPo
}
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
}

View file

@ -3,8 +3,6 @@ package com.simibubi.create.content.logistics.block.redstone;
import java.util.Random;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.IPortableBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
@ -21,10 +19,15 @@ import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class RedstoneContactBlock extends ProperDirectionalBlock implements IPortableBlock, IWrenchable {
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class RedstoneContactBlock extends ProperDirectionalBlock implements IWrenchable {
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
public static MovementBehaviour MOVEMENT = new ContactMovementBehaviour();
public RedstoneContactBlock(Properties properties) {
super(properties);
@ -94,7 +97,7 @@ public class RedstoneContactBlock extends ProperDirectionalBlock implements IPor
}
@Override
public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side) {
if (side == null)
return true;
return state.get(FACING) != side.getOpposite();
@ -105,9 +108,4 @@ public class RedstoneContactBlock extends ProperDirectionalBlock implements IPor
return state.get(POWERED) ? 15 : 0;
}
@Override
public MovementBehaviour getMovementBehaviour() {
return MOVEMENT;
}
}