Clean up gantry fix

This commit is contained in:
reidbhuntley 2021-05-21 13:18:15 -04:00
parent d0040260d7
commit c7d3166fd1
2 changed files with 17 additions and 17 deletions

View file

@ -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_) {

View file

@ -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;