From ac9854b816781e2fb76a4e7c2fea4b6f0266790d Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 24 Apr 2016 15:10:23 +0200 Subject: [PATCH] Fixed space world border check for ships --- .../cr0s/warpdrive/event/JumpSequencer.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java index fc2b487f..8bd0402a 100644 --- a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java @@ -589,8 +589,7 @@ public class JumpSequencer extends AbstractSequencer { WarpDrive.logger.info(this + " From world " + sourceWorld.provider.getDimensionName() + " to " + targetWorld.provider.getDimensionName()); } - // Validate positions aren't overlapping - if (!betweenWorlds) { + { ChunkCoordinates target1 = transformation.apply(ship.minX, ship.minY, ship.minZ); ChunkCoordinates target2 = transformation.apply(ship.maxX, ship.maxY, ship.maxZ); AxisAlignedBB aabbSource = AxisAlignedBB.getBoundingBox(ship.minX, ship.minY, ship.minZ, ship.maxX, ship.maxY, ship.maxZ); @@ -598,7 +597,8 @@ public class JumpSequencer extends AbstractSequencer { AxisAlignedBB aabbTarget = AxisAlignedBB.getBoundingBox( Math.min(target1.posX, target2.posX), Math.min(target1.posY, target2.posY), Math.min(target1.posZ, target2.posZ), Math.max(target1.posX, target2.posX), Math.max(target1.posY, target2.posY), Math.max(target1.posZ, target2.posZ)); - if (aabbSource.intersectsWith(aabbTarget)) { + // Validate positions aren't overlapping + if (!betweenWorlds && aabbSource.intersectsWith(aabbTarget)) { // render fake explosions doCollisionDamage(false); @@ -609,6 +609,26 @@ public class JumpSequencer extends AbstractSequencer { LocalProfiler.stop(); return; } + + // Check world border + if ( (targetWorld.provider.dimensionId == WarpDriveConfig.G_SPACE_DIMENSION_ID) + || (targetWorld.provider.dimensionId == WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID)) { + if (WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS > 0) {// Space world border is enabled + if ( Math.abs(aabbTarget.minX) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS + || Math.abs(aabbTarget.minZ) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS + || Math.abs(aabbTarget.maxX) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS + || Math.abs(aabbTarget.maxZ) > WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS ) { + // cancel jump + String msg = "Space border reach, max is " + WarpDriveConfig.G_SPACE_WORLDBORDER_BLOCKS; + disable(msg); + ship.messageToAllPlayersOnShip(msg); + LocalProfiler.stop(); + return; + } + } + } else { + // TODO: implement planet world border independent from transition plane + } } if (!forceTargetChunks(reason)) {