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 9592b9d02..2750d05ab 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 @@ -98,7 +98,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return state; boolean connect = AllBlocks.GANTRY_SHAFT.has(neighbour) && neighbour.get(FACING) == facing; - Part part = state.get(PART); + Part part = state.get(PART), prevPart = part; if (direction.getAxisDirection() == facing.getAxisDirection()) { if (connect) { if (part == Part.END) @@ -125,6 +125,13 @@ 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); } @@ -260,7 +267,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return super.areStatesKineticallyEquivalent(oldState, newState) && oldState.get(POWERED) == newState.get(POWERED); } - + @Override public float getParticleTargetRadius() { return .35f; @@ -270,7 +277,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { public float getParticleInitialRadius() { return .25f; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; 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 681a01269..3b15e5992 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,15 +19,12 @@ public class GantryShaftTileEntity extends KineticTileEntity { super(typeIn); } - @Override - public void onSpeedChanged(float previousSpeed) { - super.onSpeedChanged(previousSpeed); - - if (!canAssembleOn()) + public void checkAttachedCarriageBlocks(boolean willBeMiddle) { + if (!canAssembleOn(willBeMiddle)) return; for (Direction d : Iterate.directions) { if (d.getAxis() == getBlockState().get(GantryShaftBlock.FACING) - .getAxis()) + .getAxis()) continue; BlockPos offset = pos.offset(d); BlockState pinionState = world.getBlockState(offset); @@ -39,7 +36,12 @@ public class GantryShaftTileEntity extends KineticTileEntity { if (tileEntity instanceof GantryCarriageTileEntity) ((GantryCarriageTileEntity) tileEntity).queueAssembly(); } + } + @Override + public void onSpeedChanged(float previousSpeed) { + super.onSpeedChanged(previousSpeed); + checkAttachedCarriageBlocks(false); } @Override @@ -73,6 +75,10 @@ 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; @@ -80,6 +86,9 @@ 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; @@ -99,7 +108,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { return 0; return MathHelper.clamp(-getSpeed() / 512f, -.49f, .49f); } - + @Override protected boolean isNoisy() { return false;