diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java index 2750d05ab..e468327dd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java @@ -125,13 +125,6 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } } - if (!world.isRemote() && part == Part.MIDDLE && prevPart != Part.MIDDLE) { - TileEntity te = world.getTileEntity(pos); - if (te instanceof GantryShaftTileEntity) { - ((GantryShaftTileEntity)te).checkAttachedCarriageBlocks(true); - } - } - return state.with(PART, part); } @@ -176,6 +169,20 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return onWrenched; } + @Override + public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onBlockAdded(state, worldIn, pos, oldState, isMoving); + + if (!worldIn.isRemote() && oldState.getBlock().is(AllBlocks.GANTRY_SHAFT.get())) { + Part oldPart = oldState.get(PART), part = state.get(PART); + if ((oldPart != Part.MIDDLE && part == Part.MIDDLE) || (oldPart == Part.SINGLE && part != Part.SINGLE)) { + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof GantryShaftTileEntity) + ((GantryShaftTileEntity) te).checkAttachedCarriageBlocks(); + } + } + } + @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java index 3b15e5992..2f9fe658a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java @@ -19,8 +19,8 @@ public class GantryShaftTileEntity extends KineticTileEntity { super(typeIn); } - public void checkAttachedCarriageBlocks(boolean willBeMiddle) { - if (!canAssembleOn(willBeMiddle)) + public void checkAttachedCarriageBlocks() { + if (!canAssembleOn()) return; for (Direction d : Iterate.directions) { if (d.getAxis() == getBlockState().get(GantryShaftBlock.FACING) @@ -41,7 +41,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { @Override public void onSpeedChanged(float previousSpeed) { super.onSpeedChanged(previousSpeed); - checkAttachedCarriageBlocks(false); + checkAttachedCarriageBlocks(); } @Override @@ -75,10 +75,6 @@ public class GantryShaftTileEntity extends KineticTileEntity { } public boolean canAssembleOn() { - return canAssembleOn(false); - } - - public boolean canAssembleOn(boolean willBeMiddle) { BlockState blockState = getBlockState(); if (!AllBlocks.GANTRY_SHAFT.has(blockState)) return false; @@ -86,9 +82,6 @@ public class GantryShaftTileEntity extends KineticTileEntity { return false; float speed = getPinionMovementSpeed(); - if (willBeMiddle) - return speed != 0; - switch (blockState.get(GantryShaftBlock.PART)) { case END: return speed < 0;