Fixed a rare client crash when bounding box is active during jump

This commit is contained in:
LemADEC 2021-01-30 16:52:08 +01:00
parent 0cfbce1345
commit 3ed1744790

View file

@ -150,7 +150,15 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
if (Math.abs(movement.z) - shipSize.z > maxDistance) {
movement.z = (int) Math.signum(movement.z) * (shipSize.z + maxDistance);
}
facing = world.getBlockState(pos).getValue(BlockProperties.FACING_HORIZONTAL);
final IBlockState blockState = world.getBlockState(pos);
if (!(blockState.getBlock() instanceof BlockShipCore)) {
if (Commons.throttleMe("InvalidBlockToRenderBondingBox")) {
WarpDrive.logger.warn(String.format("Invalid block %s while trying to render ship bounding box with tile entity %s", blockState, this));
}
showBoundingBox = false;
return;
}
facing = blockState.getValue(BlockProperties.FACING_HORIZONTAL);
final int moveX = facing.getXOffset() * movement.x - facing.getZOffset() * movement.z;
final int moveY = movement.y;
final int moveZ = facing.getZOffset() * movement.x + facing.getXOffset() * movement.z;
@ -374,7 +382,7 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
// compute distance
distanceSquared = getMovement().getMagnitudeSquared();
// rescan ship mass/volume if it's too old
if (timeLastShipScanDone + WarpDriveConfig.SHIP_VOLUME_SCAN_AGE_TOLERANCE_SECONDS * 20 < world.getTotalWorldTime()) {
if (timeLastShipScanDone + WarpDriveConfig.SHIP_VOLUME_SCAN_AGE_TOLERANCE_SECONDS * 20L < world.getTotalWorldTime()) {
timeLastShipScanDone = -1;
break;
}