mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 08:53:41 +01:00
Assemble gantry carriage when shaft is extended
This commit is contained in:
parent
305b16fea9
commit
d0040260d7
2 changed files with 26 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue