diff --git a/src/cr0s/WarpDrive/TileEntityProtocol.java b/src/cr0s/WarpDrive/TileEntityProtocol.java index 437789f9..1d0396c9 100644 --- a/src/cr0s/WarpDrive/TileEntityProtocol.java +++ b/src/cr0s/WarpDrive/TileEntityProtocol.java @@ -479,7 +479,13 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral case 0: // dim_getp () return new Integer[] { getFront(), getRight(), getUp() }; case 1: // dim_setp (front, right, up) - if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) + if ( arguments.length != 3 || + ( ( (Double)arguments[0] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() < 0 || + ( (Double)arguments[2] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[2] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[3] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE ) ) { return new Integer[] { -1 }; } @@ -494,7 +500,13 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral case 2: // dim_getn () return new Integer[] { getBack(), getLeft(), getDown() }; case 3: // dim_setn (back, left, down) - if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) + if ( arguments.length != 3 || + ( ( (Double)arguments[0] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() < 0 || + ( (Double)arguments[2] ).intValue() < 0 || + ( (Double)arguments[1] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[2] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || + ( (Double)arguments[3] ).intValue() > WarpDriveConfig.i.WC_MAX_SHIP_SIDE ) ) { return new Integer[] { -1 }; } diff --git a/src/cr0s/WarpDrive/TileEntityReactor.java b/src/cr0s/WarpDrive/TileEntityReactor.java index 73f6a8cb..1b31bac8 100644 --- a/src/cr0s/WarpDrive/TileEntityReactor.java +++ b/src/cr0s/WarpDrive/TileEntityReactor.java @@ -53,8 +53,8 @@ public class TileEntityReactor extends TileEntity implements IEnergySink public int shipLeft, shipRight; public int shipUp, shipDown; public int shipHeight, shipWidth, shipLength; - int shipSize = 0; - int shipVolume; + int shipSize = 0; //ship length in the direction of a jump + int shipVolume = 0; //number of all blocks the ship consists of int currentMode = 0; int currentEnergyValue = 0; @@ -67,7 +67,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink private final byte MODE_GATE_JUMP = 6; // Jump via jumpgate int cooldownTime = 0; - public int randomCooldownAddition = 0; private int registryUpdateTicks = 0; public String coreFrequency = "default"; @@ -188,7 +187,7 @@ public class TileEntityReactor extends TileEntity implements IEnergySink } // Awaiting cooldown time - if (/*currentMode != MODE_BASIC_JUMP && */cooldownTime++ < ((WarpDriveConfig.i.WC_COOLDOWN_INTERVAL_SECONDS) * 20) + randomCooldownAddition) + if (/*currentMode != MODE_BASIC_JUMP && */cooldownTime++ < ((WarpDriveConfig.i.WC_COOLDOWN_INTERVAL_SECONDS) * 20) ) { return; } @@ -454,28 +453,32 @@ System.out.println("ZLO7"); minY = yCoord - shipDown; maxY = yCoord + shipUp; this.shipSize = 0; - + + int sizeFrontBack = shipFront + shipBack; + int sizeRightLeft = shipRight + shipLeft; + int sizeUpDown = shipUp + shipDown; + switch (this.direction) { case 0: case 180: - this.shipSize = this.shipBack + this.shipFront; + this.shipSize = sizeFrontBack; break; case 90: case 270: - this.shipSize = this.shipLeft + shipRight; + this.shipSize = sizeRightLeft; break; case -1: case -2: - this.shipSize = this.shipDown + this.shipUp; + this.shipSize = sizeUpDown; break; - } - - // Ship side is too big - if (shipLength > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || shipWidth > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || shipHeight > WarpDriveConfig.i.WC_MAX_SHIP_SIDE) + } + // Ship size is too big + if (sizeFrontBack > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || sizeRightLeft > WarpDriveConfig.i.WC_MAX_SHIP_SIDE || sizeUpDown > WarpDriveConfig.i.WC_MAX_SHIP_SIDE) { + messageToAllPlayersOnShip("Ship is too long. Cannot jump."); this.controller.setJumpFlag(false); return false; } diff --git a/src/cr0s/WarpDrive/WarpDriveConfig.java b/src/cr0s/WarpDrive/WarpDriveConfig.java index 311766d0..f4b571ee 100644 --- a/src/cr0s/WarpDrive/WarpDriveConfig.java +++ b/src/cr0s/WarpDrive/WarpDriveConfig.java @@ -40,9 +40,9 @@ public class WarpDriveConfig public int WC_ENERGY_PER_DISTANCE_MODE2 = 1000; // eU public int WC_ENERGY_PER_ENTITY_TO_SPACE = 1000000; // eU public int WC_MAX_JUMP_DISTANCE = 128; // Maximum jump length value - public int WC_MAX_SHIP_VOLUME_ON_SURFACE = 15000; // Maximum ship mass to jump on earth (15k blocks) - public int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 500; // Minimum ship volume value for - public int WC_MAX_SHIP_SIDE = 100; + public int WC_MAX_SHIP_VOLUME_ON_SURFACE = 15000; // Maximum ship volume to jump on earth + public int WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE = 500; // Minimum ship volume value for hyperspace travel + public int WC_MAX_SHIP_SIDE = 199; //miaximum ship length - 1 public int WC_COOLDOWN_INTERVAL_SECONDS = 4; public int WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = 10; public int WC_ISOLATION_UPDATE_INTARVAL_SECONDS = 10;