mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-25 06:27:41 +01:00
BeltTileEntity safety checks
This commit is contained in:
parent
1dd68bf427
commit
ecc02fec71
1 changed files with 19 additions and 5 deletions
|
@ -78,7 +78,10 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
|
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
|
||||||
if (face.getAxis() != getRotationAxis(state))
|
if (face.getAxis() != getRotationAxis(state))
|
||||||
return false;
|
return false;
|
||||||
BeltTileEntity beltEntity = (BeltTileEntity) world.getTileEntity(pos);
|
TileEntity tileEntity = world.getTileEntity(pos);
|
||||||
|
if (!(tileEntity instanceof BeltTileEntity))
|
||||||
|
return false;
|
||||||
|
BeltTileEntity beltEntity = (BeltTileEntity) tileEntity;
|
||||||
return beltEntity != null && beltEntity.hasPulley();
|
return beltEntity != null && beltEntity.hasPulley();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +152,12 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
|
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
|
||||||
|
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||||
|
if (!(tileEntity instanceof BeltTileEntity))
|
||||||
|
return;
|
||||||
|
|
||||||
BeltTileEntity belt = null;
|
BeltTileEntity belt = null;
|
||||||
belt = (BeltTileEntity) worldIn.getTileEntity(pos);
|
belt = (BeltTileEntity) tileEntity;
|
||||||
|
|
||||||
if (state.get(SLOPE) == Slope.VERTICAL)
|
if (state.get(SLOPE) == Slope.VERTICAL)
|
||||||
return;
|
return;
|
||||||
|
@ -180,7 +187,10 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeltTileEntity controller = (BeltTileEntity) worldIn.getTileEntity(belt.getController());
|
TileEntity controllerTE = worldIn.getTileEntity(belt.getController());
|
||||||
|
if (!(controllerTE instanceof BeltTileEntity))
|
||||||
|
return;
|
||||||
|
BeltTileEntity controller = (BeltTileEntity) controllerTE;
|
||||||
if (controller == null || controller.passengers == null)
|
if (controller == null || controller.passengers == null)
|
||||||
return;
|
return;
|
||||||
if (controller.passengers.containsKey(entityIn)) {
|
if (controller.passengers.containsKey(entityIn)) {
|
||||||
|
@ -367,8 +377,12 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||||
ISelectionContext context) {
|
ISelectionContext context) {
|
||||||
VoxelShape shape = getShape(state, worldIn, pos, context);
|
VoxelShape shape = getShape(state, worldIn, pos, context);
|
||||||
BeltTileEntity belt = (BeltTileEntity) worldIn.getTileEntity(pos);
|
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||||
if (belt == null || context.getEntity() == null)
|
if (!(tileEntity instanceof BeltTileEntity))
|
||||||
|
return shape;
|
||||||
|
|
||||||
|
BeltTileEntity belt = (BeltTileEntity) tileEntity;
|
||||||
|
if (context.getEntity() == null)
|
||||||
return shape;
|
return shape;
|
||||||
BeltTileEntity controller = (BeltTileEntity) worldIn.getTileEntity(belt.getController());
|
BeltTileEntity controller = (BeltTileEntity) worldIn.getTileEntity(belt.getController());
|
||||||
if (controller == null)
|
if (controller == null)
|
||||||
|
|
Loading…
Reference in a new issue