Code cleanup
This commit is contained in:
parent
7ee3252070
commit
625d422a36
10 changed files with 183 additions and 136 deletions
|
@ -1057,6 +1057,11 @@ public class EntityJump extends Entity {
|
|||
case 270:
|
||||
v[0] = -dz;
|
||||
v[2] = dx;
|
||||
break;
|
||||
|
||||
default:
|
||||
WarpDrive.logger.error(this + "Invalid direction " + i);
|
||||
break;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
|
|
@ -33,23 +33,23 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
|||
public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
||||
private boolean isActive = false;
|
||||
private TileEntityShipCore shipCore = null;
|
||||
|
||||
|
||||
int laserTicks = 0;
|
||||
int scanTicks = 0;
|
||||
int deployDelayTicks = 0;
|
||||
|
||||
|
||||
int searchTicks = 0;
|
||||
|
||||
|
||||
private String schematicFileName;
|
||||
|
||||
|
||||
private JumpBlock[] blocksToDeploy; // JumpBlock class stores a basic
|
||||
// information about block
|
||||
private int currentDeployIndex;
|
||||
private int blocksToDeployCount;
|
||||
private boolean isDeploying = false;
|
||||
|
||||
|
||||
private int targetX, targetY, targetZ;
|
||||
|
||||
|
||||
public TileEntityShipScanner() {
|
||||
super();
|
||||
peripheralName = "warpdriveShipScanner";
|
||||
|
@ -60,25 +60,25 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
"state"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@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),
|
||||
|
@ -88,51 +88,57 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
} 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);
|
||||
|
||||
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;
|
||||
|
@ -140,20 +146,20 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
} 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;
|
||||
isDeploying = false;
|
||||
setActive(false); // disable scanner
|
||||
break;
|
||||
}
|
||||
|
@ -165,12 +171,14 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,46 +187,46 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setActive(boolean newState) {
|
||||
isActive = newState;
|
||||
if ((getBlockMetadata() == 1) == newState) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, isActive ? 1 : 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TileEntityShipCore searchShipCore() {
|
||||
StringBuilder reason = new StringBuilder();
|
||||
TileEntityShipCore result = null;
|
||||
|
||||
|
||||
// Search for warp cores above
|
||||
for (int newY = yCoord + 1; newY <= 255; newY++) {
|
||||
if (worldObj.getBlock(xCoord, newY, zCoord).isAssociatedBlock(WarpDrive.blockShipCore)) { // found
|
||||
// warp core above
|
||||
result = (TileEntityShipCore) worldObj.getTileEntity(xCoord, newY, zCoord);
|
||||
|
||||
|
||||
if (result != null) {
|
||||
if (!result.validateShipSpatialParameters(reason)) { // If
|
||||
// we can't refresh ship's spatial parameters
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private int getScanningEnergyCost(int size) {
|
||||
if (WarpDriveConfig.SS_ENERGY_PER_BLOCK_SCAN > 0) {
|
||||
return size * WarpDriveConfig.SS_ENERGY_PER_BLOCK_SCAN;
|
||||
} else {
|
||||
return WarpDriveConfig.SS_MAX_ENERGY_STORED;
|
||||
return WarpDriveConfig.SS_MAX_ENERGY_STORED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getDeploymentEnergyCost(int size) {
|
||||
if (WarpDriveConfig.SS_ENERGY_PER_BLOCK_DEPLOY > 0) {
|
||||
return size * WarpDriveConfig.SS_ENERGY_PER_BLOCK_DEPLOY;
|
||||
|
@ -226,60 +234,59 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return WarpDriveConfig.SS_MAX_ENERGY_STORED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean saveShipToSchematic(String fileName, StringBuilder reason) {
|
||||
NBTTagCompound schematic = new NBTTagCompound();
|
||||
|
||||
|
||||
short width = (short) (shipCore.maxX - shipCore.minX + 1);
|
||||
short length = (short) (shipCore.maxZ - shipCore.minZ + 1);
|
||||
short height = (short) (shipCore.maxY - shipCore.minY + 1);
|
||||
|
||||
|
||||
if (width <= 0 || length <= 0 || height <= 0) {
|
||||
reason.append("Invalid ship dimensions, nothing to scan");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
schematic.setShort("Width", width);
|
||||
schematic.setShort("Length", length);
|
||||
schematic.setShort("Height", height);
|
||||
|
||||
|
||||
int size = width * length * height;
|
||||
|
||||
|
||||
// Consume energy
|
||||
if (!consumeEnergy(getScanningEnergyCost(size), false)) {
|
||||
reason.append("Insufficient energy (" + getScanningEnergyCost(size) + " required)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
NBTTagList localBlocks = new NBTTagList();
|
||||
byte localMetadata[] = new byte[size];
|
||||
|
||||
|
||||
NBTTagList tileEntitiesList = new NBTTagList();
|
||||
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
Block block = worldObj.getBlock(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);
|
||||
|
||||
|
||||
// Skip leftBehind and anchor blocks
|
||||
if ( WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)
|
||||
|| WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) {
|
||||
if (WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block) || WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) {
|
||||
block = Blocks.air;
|
||||
}
|
||||
|
||||
|
||||
//Old coord calc [x + (y * length + z) * width]
|
||||
localBlocks.appendTag(new NBTTagString(block.getUnlocalizedName()));
|
||||
localMetadata[x + (y * length + z) * width] = (byte) worldObj.getBlockMetadata(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);
|
||||
|
||||
|
||||
if (!block.isAssociatedBlock(Blocks.air)) {
|
||||
TileEntity te = worldObj.getTileEntity(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);
|
||||
if (te != null) {
|
||||
try {
|
||||
NBTTagCompound tileTag = new NBTTagCompound();
|
||||
te.writeToNBT(tileTag);
|
||||
|
||||
|
||||
// Clear inventory.
|
||||
if (te instanceof IInventory) {
|
||||
if (te instanceof IInventory) {
|
||||
TileEntity tmp_te = TileEntity.createAndLoadEntity(tileTag);
|
||||
if (tmp_te instanceof IInventory) {
|
||||
for (int i = 0; i < ((IInventory) tmp_te).getSizeInventory(); i++) {
|
||||
|
@ -288,7 +295,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
}
|
||||
tmp_te.writeToNBT(tileTag);
|
||||
}
|
||||
|
||||
|
||||
// Remove energy from energy storages
|
||||
// IC2
|
||||
if (tileTag.hasKey("energy")) {
|
||||
|
@ -298,54 +305,54 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
if (tileTag.hasKey("mStoredEnergy")) {
|
||||
tileTag.setInteger("mStoredEnergy", 0);
|
||||
}
|
||||
|
||||
|
||||
// Transform TE's coordinates from local axis to
|
||||
// .schematic offset-axis
|
||||
tileTag.setInteger("x", te.xCoord - shipCore.minX);
|
||||
tileTag.setInteger("y", te.yCoord - shipCore.minY);
|
||||
tileTag.setInteger("z", te.zCoord - shipCore.minZ);
|
||||
|
||||
|
||||
tileEntitiesList.appendTag(tileTag);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
schematic.setString("Materials", "Alpha");
|
||||
schematic.setTag("Blocks", localBlocks);
|
||||
schematic.setByteArray("Data", localMetadata);
|
||||
|
||||
|
||||
schematic.setTag("Entities", new NBTTagList()); // don't save entities
|
||||
schematic.setTag("TileEntities", tileEntitiesList);
|
||||
|
||||
|
||||
writeNBTToFile(fileName, schematic);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void writeNBTToFile(String fileName, NBTTagCompound nbttagcompound) {
|
||||
WarpDrive.logger.info(this + " Filename: " + fileName);
|
||||
|
||||
|
||||
try {
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
|
||||
FileOutputStream fileoutputstream = new FileOutputStream(file);
|
||||
|
||||
|
||||
CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);
|
||||
|
||||
|
||||
fileoutputstream.close();
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Begins ship scan
|
||||
private boolean scanShip(StringBuilder reason) {
|
||||
// Enable scanner
|
||||
|
@ -354,39 +361,39 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
if (!f.exists() || !f.isDirectory()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
// Generate unique file name
|
||||
do {
|
||||
schematicFileName = (new StringBuilder().append(shipCore.shipName).append(System.currentTimeMillis()).append(".schematic")).toString();
|
||||
} while (new File(WarpDriveConfig.G_SCHEMALOCATION + "/" + schematicFileName).exists());
|
||||
|
||||
|
||||
if (!saveShipToSchematic(WarpDriveConfig.G_SCHEMALOCATION + "/" + schematicFileName, reason)) {
|
||||
return false;
|
||||
}
|
||||
reason.append(schematicFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static NBTTagCompound readNBTFromFile(String fileName) {
|
||||
try {
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
FileInputStream fileinputstream = new FileInputStream(file);
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
|
||||
|
||||
|
||||
fileinputstream.close();
|
||||
|
||||
|
||||
return nbttagcompound;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Returns error code and reason string
|
||||
private int deployShip(String fileName, int offsetX, int offsetY, int offsetZ, StringBuilder reason) {
|
||||
// Load schematic
|
||||
|
@ -395,17 +402,17 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
reason.append("Schematic not found or unknow error reading it.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Compute geometry
|
||||
short width = schematic.getShort("Width");
|
||||
short height = schematic.getShort("Height");
|
||||
short length = schematic.getShort("Length");
|
||||
|
||||
|
||||
targetX = xCoord + offsetX;
|
||||
targetY = yCoord + offsetY;
|
||||
targetZ = zCoord + offsetZ;
|
||||
blocksToDeployCount = width * height * length;
|
||||
|
||||
|
||||
// Validate context
|
||||
{
|
||||
// Check distance
|
||||
|
@ -413,18 +420,18 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
double dY = yCoord - targetY;
|
||||
double dZ = zCoord - targetZ;
|
||||
double distance = MathHelper.sqrt_double(dX * dX + dY * dY + dZ * dZ);
|
||||
|
||||
|
||||
if (distance > WarpDriveConfig.SS_MAX_DEPLOY_RADIUS_BLOCKS) {
|
||||
reason.append("Cannot deploy ship so far away from scanner.");
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
// Consume energy
|
||||
if (!consumeEnergy(getDeploymentEnergyCost(blocksToDeployCount), false)) {
|
||||
reason.append("Insufficient energy (" + getDeploymentEnergyCost(blocksToDeployCount) + " required)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Check specified area for occupation by blocks
|
||||
// If specified area occupied, break deploying with error message
|
||||
int occupiedBlockCount = 0;
|
||||
|
@ -441,43 +448,43 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set deployment variables
|
||||
blocksToDeploy = new JumpBlock[blocksToDeployCount];
|
||||
isDeploying = true;
|
||||
currentDeployIndex = 0;
|
||||
|
||||
|
||||
// Read blocks and TileEntities from NBT to internal storage array
|
||||
NBTTagList localBlocks = (NBTTagList) schematic.getTag("Blocks");
|
||||
byte localMetadata[] = schematic.getByteArray("Data");
|
||||
|
||||
|
||||
// Load Tile Entities
|
||||
NBTTagCompound[] tileEntities = new NBTTagCompound[blocksToDeployCount];
|
||||
NBTTagList tileEntitiesList = schematic.getTagList("TileEntities", new NBTTagByteArray(new byte[0]).getId()); //TODO: 0 is not correct
|
||||
|
||||
|
||||
for (int i = 0; i < tileEntitiesList.tagCount(); i++) {
|
||||
NBTTagCompound teTag = tileEntitiesList.getCompoundTagAt(i);
|
||||
int teX = teTag.getInteger("x");
|
||||
int teY = teTag.getInteger("y");
|
||||
int teZ = teTag.getInteger("z");
|
||||
|
||||
|
||||
tileEntities[teX + (teY * length + teZ) * width] = teTag;
|
||||
}
|
||||
|
||||
|
||||
// Create list of blocks to deploy
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
int index = x + (y * length + z) * width;
|
||||
JumpBlock jb = new JumpBlock();
|
||||
|
||||
|
||||
jb.x = x;
|
||||
jb.y = y;
|
||||
jb.z = z;
|
||||
jb.block = Block.getBlockFromName(localBlocks.getStringTagAt(index));
|
||||
jb.blockMeta = (localMetadata[index]) & 0xFF;
|
||||
jb.blockNBT = tileEntities[index];
|
||||
|
||||
|
||||
if (jb.block != null) {
|
||||
|
||||
if (WarpDriveConfig.LOGGING_BUILDING) {
|
||||
|
@ -487,57 +494,57 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
WarpDrive.logger.info("[ShipScanner] Adding block to deploy: " + jb.block.getUnlocalizedName() + " with tile entity " + tileEntities[index].getString("id"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
blocksToDeploy[index] = jb;
|
||||
} else {
|
||||
jb = null;
|
||||
|
||||
|
||||
blocksToDeploy[index] = jb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setActive(true);
|
||||
reason.append("Ship deploying...");
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
}
|
||||
|
||||
|
||||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] scan(Context context, Arguments arguments) {
|
||||
return scan(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] filename(Context context, Arguments arguments) {
|
||||
return filename(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] deploy(Context context, Arguments arguments) {
|
||||
return deploy(argumentsOCtoCC(arguments));
|
||||
}
|
||||
|
||||
|
||||
private Object[] scan(Object[] arguments) {
|
||||
// Already scanning?
|
||||
if (isActive) {
|
||||
return new Object[] { false, 0, "Already active" };
|
||||
}
|
||||
|
||||
|
||||
if (shipCore == null) {
|
||||
return new Object[] { false, 1, "Warp-Core not found" };
|
||||
} else if (!consumeEnergy(getScanningEnergyCost(shipCore.shipMass), true)) {
|
||||
|
@ -548,7 +555,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return new Object[] { success, 3, reason.toString() };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Object[] filename(Object[] arguments) {
|
||||
if (isActive && !schematicFileName.isEmpty()) {
|
||||
if (isDeploying) {
|
||||
|
@ -557,17 +564,17 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return new Object[] { false, "Scan in progress. Please wait..." };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new Object[] { true, schematicFileName };
|
||||
}
|
||||
|
||||
|
||||
private Object[] deploy(Object[] arguments) {
|
||||
if (arguments.length == 4) {
|
||||
String fileName = (String) arguments[0];
|
||||
int x = toInt(arguments[1]);
|
||||
int y = toInt(arguments[2]);
|
||||
int z = toInt(arguments[3]);
|
||||
|
||||
|
||||
if (!new File(WarpDriveConfig.G_SCHEMALOCATION + "/" + fileName).exists()) {
|
||||
return new Object[] { 0, "Specified .schematic file was not found!" };
|
||||
} else {
|
||||
|
@ -579,7 +586,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return new Object[] { 4, "Invalid arguments count, you need .schematic file name, offsetX, offsetY and offsetZ!" };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Object[] state(Object[] arguments) {
|
||||
if (!isActive) {
|
||||
return new Object[] { false, "IDLE", 0, 0 };
|
||||
|
@ -589,7 +596,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
return new Object[] { true, "Deploying", currentDeployIndex, blocksToDeployCount };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ComputerCraft IPeripheral methods implementation
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
|
@ -611,13 +618,13 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
|
|||
|
||||
return super.callMethod(computer, context, method, arguments);
|
||||
}
|
||||
|
||||
|
||||
// IEnergySink methods implementation
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return WarpDriveConfig.SS_MAX_ENERGY_STORED;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canInputEnergy(ForgeDirection from) {
|
||||
return true;
|
||||
|
|
|
@ -223,6 +223,8 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
|
|||
return new Object[] { "up" };
|
||||
case 2:
|
||||
return new Object[] { "down" };
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,9 @@ public class CommandDebug extends CommandBase
|
|||
te.updateContainingBlockInfo();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
WarpDrive.logger.info("[" + getCommandName() + "] " + side + ": invalid step '" + ch + "'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -934,6 +934,9 @@ public class WarpDriveConfig {
|
|||
case "PlaceNormal" : BLOCKS_PLACE.put(block, 2); break;
|
||||
case "PlaceLater" : BLOCKS_PLACE.put(block, 3); break;
|
||||
case "PlaceLatest" : BLOCKS_PLACE.put(block, 4); break;
|
||||
default:
|
||||
WarpDrive.logger.error("Unsupported tag '" + tag + "' for block " + block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -968,6 +971,9 @@ public class WarpDriveConfig {
|
|||
case "NoMass" : ENTITIES_NOMASS.add(entityId); break;
|
||||
case "LeftBehind" : ENTITIES_LEFTBEHIND.add(entityId); break;
|
||||
case "NonLivingTarget" : ENTITIES_NONLIVINGTARGET.add(entityId); break;
|
||||
default:
|
||||
WarpDrive.logger.error("Unsupported tag '" + tag + "' for entity " + entityId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -993,6 +999,9 @@ public class WarpDriveConfig {
|
|||
case "FlyInSpace" : ITEMS_FLYINSPACE.add(item); break;
|
||||
case "NoFallDamage" : ITEMS_NOFALLDAMAGE.add(item); break;
|
||||
case "BreathingIC2" : ITEMS_BREATHINGIC2.add(item); break;
|
||||
default:
|
||||
WarpDrive.logger.error("Unsupported tag '" + tag + "' for item " + item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,6 +200,7 @@ public class StarMapRegistry {
|
|||
case STAR: break;
|
||||
case STRUCTURE: break;
|
||||
case WARPECHO: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,9 @@ public class Vector3 implements Cloneable {
|
|||
break;
|
||||
case EAST:
|
||||
x += amount;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -383,28 +386,31 @@ public class Vector3 implements Cloneable {
|
|||
case 0:
|
||||
this.y -= amount;
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
this.y += amount;
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
this.z -= amount;
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
this.z += amount;
|
||||
break;
|
||||
|
||||
|
||||
case 4:
|
||||
this.x -= amount;
|
||||
break;
|
||||
|
||||
|
||||
case 5:
|
||||
this.x += amount;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,9 @@ public class VectorI implements Cloneable {
|
|||
break;
|
||||
case EAST:
|
||||
x += amount;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -99,27 +99,34 @@ public final class EntitySphereGen extends Entity {
|
|||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ticksDelay > 0) {
|
||||
ticksDelay--;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.state) {
|
||||
|
||||
switch (state) {
|
||||
case STATE_SAVING:
|
||||
tickScheduleBlocks();
|
||||
this.state = STATE_SETUP;
|
||||
break;
|
||||
|
||||
case STATE_SETUP:
|
||||
if (currentIndex >= blocks.size() - 1)
|
||||
this.state = STATE_DELETE;
|
||||
else
|
||||
tickPlaceBlocks();
|
||||
break;
|
||||
|
||||
case STATE_DELETE:
|
||||
currentIndex = 0;
|
||||
killEntity();
|
||||
break;
|
||||
|
||||
default:
|
||||
WarpDrive.logger.error(this + " Invalid state " + state + ". Killing entity...");
|
||||
killEntity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,21 +49,24 @@ public class WorldGenSmallShip extends WorldGenerator {
|
|||
case 0:
|
||||
cableType.setItemDamage(0);
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
cableType.setItemDamage(3);
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
cableType.setItemDamage(6);
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
cableType.setItemDamage(9);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int i = centerX - 5, j = centerY - 4, k = centerZ - 6;
|
||||
world.setBlock(i + 0, j + 1, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));
|
||||
world.setBlock(i + 0, j + 1, k + 10, WorldGenStructure.getStoneBlock(corrupted, rand));
|
||||
|
@ -627,7 +630,7 @@ public class WorldGenSmallShip extends WorldGenerator {
|
|||
|
||||
while (!isDone) {
|
||||
switch (rand.nextInt(14)) {
|
||||
case 0:// Mass fabricator
|
||||
case 0: // Mass fabricator
|
||||
res = WarpDriveConfig.getModItemStack("IC2", "blockMachine", -1);
|
||||
res.setItemDamage(14);
|
||||
res.stackSize = 1; // + rand.nextInt(2);
|
||||
|
@ -653,22 +656,21 @@ public class WorldGenSmallShip extends WorldGenerator {
|
|||
res.stackSize = 2 + rand.nextInt(12);
|
||||
isDone = true;
|
||||
break;
|
||||
|
||||
|
||||
case 7:// UU matter cell
|
||||
res = WarpDriveConfig.getModItemStack("IC2", "itemCellEmpty", -1);
|
||||
res.setItemDamage(3);
|
||||
res.stackSize = 2 + rand.nextInt(14);
|
||||
isDone = true;
|
||||
break;
|
||||
|
||||
|
||||
case 8:
|
||||
isDone = true;
|
||||
break;// skipped
|
||||
|
||||
|
||||
case 9:
|
||||
case 10:
|
||||
// Rocket launcher platform Tier3
|
||||
case 11:
|
||||
case 11: // Rocket launcher platform Tier3
|
||||
if (WarpDriveConfig.isICBMLoaded) {
|
||||
// TODO: No 1.7 ICBM yet
|
||||
// res = new ItemStack(WarpDriveConfig.ICBM_Machine, 1 +
|
||||
|
@ -676,9 +678,9 @@ public class WorldGenSmallShip extends WorldGenerator {
|
|||
isDone = true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Missles from conventional to hypersonic
|
||||
case 12:
|
||||
|
||||
|
||||
case 12: // Missiles from conventional to hypersonic
|
||||
if (WarpDriveConfig.isICBMLoaded) {
|
||||
// TODO: No 1.7 ICBM yet
|
||||
// res = new ItemStack(WarpDriveConfig.ICBM_Missile, 2 +
|
||||
|
@ -686,14 +688,16 @@ public class WorldGenSmallShip extends WorldGenerator {
|
|||
isDone = true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Advanced solar panels
|
||||
case 13:
|
||||
|
||||
case 13: // Advanced solar panels
|
||||
if (WarpDriveConfig.isAdvancedSolarPanelLoaded) {
|
||||
res = new ItemStack(solarPanel_block, rand.nextInt(3), solarPanel_metadata);
|
||||
isDone = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue