@Override public void updateEntity() { super.updateEntity(); if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return; if (++searchTicks > 20) { shipCore = searchShipCore(); searchTicks = 0; } // Warp core is not found if (!isDeploying && shipCore == null) { setActive(false); // disable scanner return; } if (!isActive) { // inactive if (++laserTicks > 20) { PacketHandler.sendBeamPacket( worldObj, new Vector3(this).translate(0.5D), new Vector3(shipCore.xCoord, shipCore.yCoord, shipCore.zCoord).translate(0.5D), 0f, 1f, 0f, 40, 0, 100); laserTicks = 0; } } else if (!isDeploying) { // active and scanning if (++laserTicks > 5) { laserTicks = 0; for (int i = 0; i < shipCore.maxX - shipCore.minX; i++) { int x = shipCore.minX + i; int randomZ = shipCore.minZ + worldObj.rand.nextInt(shipCore.maxZ - shipCore.minZ); worldObj.playSoundEffect( xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); float r = 0.0f, g = 0.0f, b = 0.0f; switch (worldObj.rand.nextInt(6)) { case 0: r = 1.0f; g = b = 0; break; case 1: r = b = 0; g = 1.0f; break; case 2: r = g = 0; b = 1.0f; break; case 3: r = b = 0.5f; g = 0; break; case 4: r = g = 1.0f; b = 0; break; case 5: r = 1.0f; b = 0.5f; g = 0f; break; default: break; } PacketHandler.sendBeamPacket( worldObj, new Vector3(this).translate(0.5D), new Vector3(x, shipCore.maxY, randomZ).translate(0.5D), r, g, b, 15, 0, 100); } } if (++scanTicks > 20 * (1 + shipCore.shipMass / 10)) { setActive(false); // disable scanner scanTicks = 0; } } else { // active and deploying if (++deployDelayTicks < 20) return; deployDelayTicks = 0; int blocks = Math.min(WarpDriveConfig.G_BLOCKS_PER_TICK, blocksToDeployCount - currentDeployIndex); if (blocks == 0) { isDeploying = false; setActive(false); // disable scanner return; } for (int index = 0; index < blocks; index++) { if (currentDeployIndex >= blocksToDeployCount) { isDeploying = false; setActive(false); // disable scanner break; } // Deploy single block JumpBlock jb = blocksToDeploy[currentDeployIndex]; if (jb != null && !WarpDriveConfig.BLOCKS_ANCHOR.contains(jb.block)) { Block blockAtTarget = worldObj.getBlock(targetX + jb.x, targetY + jb.y, targetZ + jb.z); if (blockAtTarget == Blocks.air || WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockAtTarget)) { jb.deploy(worldObj, targetX, targetY, targetZ); if (worldObj.rand.nextInt(100) <= 10) { worldObj.playSoundEffect( xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); PacketHandler.sendBeamPacket( worldObj, new Vector3(this).translate(0.5D), new Vector3(targetX + jb.x, targetY + jb.y, targetZ + jb.z).translate(0.5D), 0f, 1f, 0f, 15, 0, 100); } } } currentDeployIndex++; } } }