diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index dd581416..341bd217 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -21,6 +21,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.WorldServer; @@ -131,7 +133,7 @@ public class Commons { boolean isExisting = false; for (final String lineExisting : list) { if ( lineExisting.contains(split[0]) - || split[0].contains(lineExisting) ) { + || split[0].contains(lineExisting) ) { isExisting = true; break; } @@ -316,25 +318,25 @@ public class Commons { // data manipulation methods - public static int toInt(double d) { + public static int toInt(final double d) { return (int) Math.round(d); } - public static int toInt(Object object) { + public static int toInt(final Object object) { return toInt(toDouble(object)); } - public static double toDouble(Object object) { + public static double toDouble(final Object object) { assert(!(object instanceof Object[])); return Double.parseDouble(object.toString()); } - public static float toFloat(Object object) { + public static float toFloat(final Object object) { assert(!(object instanceof Object[])); return Float.parseFloat(object.toString()); } - public static boolean toBool(Object object) { + public static boolean toBool(final Object object) { if (object == null) { return false; } @@ -620,4 +622,15 @@ public class Commons { return worldServer; } + // server side version of EntityLivingBase.rayTrace + private static final double BLOCK_REACH_DISTANCE = 5.0D; // this is a client side hardcoded value, applicable to creative players + public static MovingObjectPosition getInteractingBlock(final World world, final EntityPlayer entityPlayer) { + return getInteractingBlock(world, entityPlayer, BLOCK_REACH_DISTANCE); + } + public static MovingObjectPosition getInteractingBlock(final World world, final EntityPlayer entityPlayer, final double distance) { + Vec3 vec3Position = Vec3.createVectorHelper(entityPlayer.posX, entityPlayer.posY + entityPlayer.eyeHeight, entityPlayer.posZ); + Vec3 vec3Look = entityPlayer.getLook(1.0F); + Vec3 vec3Target = vec3Position.addVector(vec3Look.xCoord * distance, vec3Look.yCoord * distance, vec3Look.zCoord * distance); + return world.func_147447_a(vec3Position, vec3Target, false, false, true); + } } diff --git a/src/main/java/cr0s/warpdrive/api/ParticleStack.java b/src/main/java/cr0s/warpdrive/api/ParticleStack.java index cd9e6c39..b1e0ea7b 100644 --- a/src/main/java/cr0s/warpdrive/api/ParticleStack.java +++ b/src/main/java/cr0s/warpdrive/api/ParticleStack.java @@ -11,9 +11,10 @@ import net.minecraft.world.World; import cpw.mods.fml.common.FMLLog; public class ParticleStack { + private final Particle particle; private int amount; - private NBTTagCompound tag; + private NBTTagCompound tagCompound; public ParticleStack(@Nonnull final Particle particle, final int amount) { if (!ParticleRegistry.isParticleRegistered(particle)) { @@ -28,42 +29,42 @@ public class ParticleStack { this(particle, amount); if (nbt != null) { - tag = (NBTTagCompound) nbt.copy(); + tagCompound = (NBTTagCompound) nbt.copy(); } } public ParticleStack(ParticleStack stack, int amount) { - this(stack.getParticle(), amount, stack.tag); + this(stack.getParticle(), amount, stack.tagCompound); } /** * Return null if stack is invalid. */ - public static ParticleStack loadFromNBT(NBTTagCompound nbt) { - if (nbt == null) { + public static ParticleStack loadFromNBT(final NBTTagCompound tagCompound) { + if (tagCompound == null) { return null; } - String particleName = nbt.getString("name"); + String particleName = tagCompound.getString("name"); if (particleName == null || ParticleRegistry.getParticle(particleName) == null) { return null; } - ParticleStack stack = new ParticleStack(ParticleRegistry.getParticle(particleName), nbt.getInteger("amount")); + ParticleStack stack = new ParticleStack(ParticleRegistry.getParticle(particleName), tagCompound.getInteger("amount")); - if (nbt.hasKey("tag")) { - stack.tag = nbt.getCompoundTag("tag"); + if (tagCompound.hasKey("tag")) { + stack.tagCompound = tagCompound.getCompoundTag("tag"); } return stack; } - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setString("name", ParticleRegistry.getParticleName(getParticle())); - nbt.setInteger("amount", amount); + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setString("name", ParticleRegistry.getParticleName(getParticle())); + tagCompound.setInteger("amount", amount); - if (tag != null) { - nbt.setTag("tag", tag); + if (this.tagCompound != null) { + tagCompound.setTag("tag", this.tagCompound); } - return nbt; + return tagCompound; } public final Particle getParticle() { @@ -103,11 +104,11 @@ public class ParticleStack { } public ParticleStack copy() { - return new ParticleStack(getParticle(), amount, tag); + return new ParticleStack(getParticle(), amount, tagCompound); } public ParticleStack copy(final int amount) { - return new ParticleStack(getParticle(), amount, tag); + return new ParticleStack(getParticle(), amount, tagCompound); } public boolean isParticleEqual(ParticleStack other) { @@ -115,7 +116,7 @@ public class ParticleStack { } private boolean isParticleStackTagEqual(ParticleStack other) { - return tag == null ? other.tag == null : other.tag != null && tag.equals(other.tag); + return tagCompound == null ? other.tagCompound == null : other.tagCompound != null && tagCompound.equals(other.tagCompound); } public static boolean areParticleStackTagsEqual(ParticleStack stack1, ParticleStack stack2) { @@ -147,8 +148,8 @@ public class ParticleStack { int code = 1; code = 31 * code + getParticle().hashCode(); code = 31 * code + amount; - if (tag != null) { - code = 31 * code + tag.hashCode(); + if (tagCompound != null) { + code = 31 * code + tagCompound.hashCode(); } return code; } diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index 17048856..e3edbb0c 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -65,11 +65,11 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I TileEntity tileEntity = world.getTileEntity(x, y, z); if (itemStack.hasTagCompound()) { - NBTTagCompound nbtTagCompound = (NBTTagCompound)itemStack.getTagCompound().copy(); - nbtTagCompound.setInteger("x", x); - nbtTagCompound.setInteger("y", y); - nbtTagCompound.setInteger("z", z); - tileEntity.readFromNBT(nbtTagCompound); + final NBTTagCompound tagCompound = (NBTTagCompound) itemStack.getTagCompound().copy(); + tagCompound.setInteger("x", x); + tagCompound.setInteger("y", y); + tagCompound.setInteger("z", z); + tileEntity.readFromNBT(tagCompound); world.markBlockForUpdate(x, y, z); } } @@ -87,9 +87,9 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I if (tileEntity == null) { WarpDrive.logger.error("Missing tile entity for " + this + " at " + world + " " + x + " " + y + " " + z); } else if (tileEntity instanceof TileEntityAbstractBase) { - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - ((TileEntityAbstractBase) tileEntity).writeItemDropNBT(nbtTagCompound); - itemStack.setTagCompound(nbtTagCompound); + final NBTTagCompound tagCompound = new NBTTagCompound(); + ((TileEntityAbstractBase) tileEntity).writeItemDropNBT(tagCompound); + itemStack.setTagCompound(tagCompound); } } world.setBlockToAir(x, y, z); @@ -100,10 +100,10 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) { ItemStack itemStack = super.getPickBlock(target, world, x, y, z, entityPlayer); TileEntity tileEntity = world.getTileEntity(x, y, z); - NBTTagCompound nbtTagCompound = new NBTTagCompound(); + final NBTTagCompound tagCompound = new NBTTagCompound(); if (tileEntity instanceof TileEntityAbstractBase) { - ((TileEntityAbstractBase) tileEntity).writeItemDropNBT(nbtTagCompound); - itemStack.setTagCompound(nbtTagCompound); + ((TileEntityAbstractBase) tileEntity).writeItemDropNBT(tagCompound); + itemStack.setTagCompound(tagCompound); } return itemStack; } diff --git a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java index 92cb8a33..b9ed865e 100644 --- a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java @@ -62,11 +62,11 @@ public class ItemBlockAbstractBase extends ItemBlock { return ((IBlockBase) field_150939_a).getRarity(itemStack, super.getRarity(itemStack)); } - private String getStatus(final NBTTagCompound nbtTagCompound, final int metadata) { - TileEntity tileEntity = field_150939_a.createTileEntity(null, metadata); + private String getStatus(final NBTTagCompound tagCompound, final int metadata) { + final TileEntity tileEntity = field_150939_a.createTileEntity(null, metadata); if (tileEntity instanceof TileEntityAbstractBase) { - if (nbtTagCompound != null) { - tileEntity.readFromNBT(nbtTagCompound); + if (tagCompound != null) { + tileEntity.readFromNBT(tagCompound); } return ((TileEntityAbstractBase) tileEntity).getStatus(); diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractEnergy.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractEnergy.java index 210d07d1..ca7c5c76 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractEnergy.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractEnergy.java @@ -30,6 +30,9 @@ import net.minecraftforge.common.util.ForgeDirection; @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2") }) public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfaced implements IEnergyHandler, IEnergySink, IEnergySource, cr0s.warpdrive.api.computer.IEnergy { + + public static final String ENERGY_TAG = "energy"; + private boolean addedToEnergyNet = false; private long energyStored_internal = 0; public static final double EU_PER_INTERNAL = 1.0D; @@ -38,6 +41,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa public static final int IC2_sourceTier_max = 20; protected int IC2_sinkTier = 3; protected int IC2_sourceTier = 3; + protected boolean isEnergyLostWhenBroken = true; private static final int SCAN_INTERVAL_TICKS = 20; private int scanTickCount = SCAN_INTERVAL_TICKS; @@ -146,7 +150,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa energyStored_internal -= amount_internal; } - public String getEnergyStatus() { + private String getEnergyStatus() { if (energy_getMaxStorage() == 0) { return ""; } @@ -425,22 +429,24 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa // Forge overrides @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - energyStored_internal = tag.getLong("energy"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + energyStored_internal = tagCompound.getLong(ENERGY_TAG); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setLong("energy", energy_getEnergyStored()); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setLong(ENERGY_TAG, energy_getEnergyStored()); } @Override - public NBTTagCompound writeItemDropNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound = super.writeItemDropNBT(nbtTagCompound); - nbtTagCompound.removeTag("energy"); - return nbtTagCompound; + public NBTTagCompound writeItemDropNBT(NBTTagCompound tagCompound) { + tagCompound = super.writeItemDropNBT(tagCompound); + if (isEnergyLostWhenBroken) { + tagCompound.removeTag(ENERGY_TAG); + } + return tagCompound; } // WarpDrive overrides @@ -469,9 +475,9 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa for (ForgeDirection from : ForgeDirection.VALID_DIRECTIONS) { boolean energyReceiverFound = false; if (canConnectEnergy(from)) { - TileEntity tileEntity = worldObj.getTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ); - if (tileEntity != null && tileEntity instanceof IEnergyReceiver) { - IEnergyReceiver energyReceiver = (IEnergyReceiver) tileEntity; + final TileEntity tileEntity = worldObj.getTileEntity(xCoord + from.offsetX, yCoord + from.offsetY, zCoord + from.offsetZ); + if (tileEntity instanceof IEnergyReceiver) { + final IEnergyReceiver energyReceiver = (IEnergyReceiver) tileEntity; if (energyReceiver.canConnectEnergy(from.getOpposite())) { energyReceiverFound = true; cofhEnergyReceivers[from.ordinal()] = energyReceiver; diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java index 09e403fc..656c1e71 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java @@ -152,20 +152,20 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); if ( WarpDriveConfig.isOpenComputersLoaded && FMLCommonHandler.instance().getEffectiveSide().isServer() ) { if (OC_node == null) { OC_constructor(); } if (OC_node != null && OC_node.host() == this) { - OC_node.load(tag.getCompoundTag("oc:node")); - } else if (tag.hasKey("oc:node")) { + OC_node.load(tagCompound.getCompoundTag("oc:node")); + } else if (tagCompound.hasKey("oc:node")) { WarpDrive.logger.error(this + " OC node failed to construct or wrong host, ignoring NBT node data read..."); } if (OC_fileSystem != null && OC_fileSystem.node() != null) { - OC_fileSystem.node().load(tag.getCompoundTag("oc:fs")); + OC_fileSystem.node().load(tagCompound.getCompoundTag("oc:fs")); } else if (OC_hasResource) { WarpDrive.logger.error(this + " OC filesystem failed to construct or wrong node, ignoring NBT filesystem data read..."); } @@ -173,28 +173,28 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); if (WarpDriveConfig.isOpenComputersLoaded) { if (OC_node != null && OC_node.host() == this) { final NBTTagCompound nbtNode = new NBTTagCompound(); OC_node.save(nbtNode); - tag.setTag("oc:node", nbtNode); + tagCompound.setTag("oc:node", nbtNode); } if (OC_fileSystem != null && OC_fileSystem.node() != null) { final NBTTagCompound nbtFileSystem = new NBTTagCompound(); OC_fileSystem.node().save(nbtFileSystem); - tag.setTag("oc:fs", nbtFileSystem); + tagCompound.setTag("oc:fs", nbtFileSystem); } } } @Override - public NBTTagCompound writeItemDropNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound = super.writeItemDropNBT(nbtTagCompound); - nbtTagCompound.removeTag("oc:node"); - nbtTagCompound.removeTag("oc:fs"); - return nbtTagCompound; + public NBTTagCompound writeItemDropNBT(NBTTagCompound tagCompound) { + tagCompound = super.writeItemDropNBT(tagCompound); + tagCompound.removeTag("oc:node"); + tagCompound.removeTag("oc:fs"); + return tagCompound; } @Override diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java index 4fe38c53..f278bc5a 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java @@ -534,16 +534,16 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - setBeamFrequency(tag.getInteger(BEAM_FREQUENCY_TAG)); - legacyVideoChannel = tag.getInteger("cameraFrequency") + tag.getInteger(IVideoChannel.VIDEO_CHANNEL_TAG); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + setBeamFrequency(tagCompound.getInteger(BEAM_FREQUENCY_TAG)); + legacyVideoChannel = tagCompound.getInteger("cameraFrequency") + tagCompound.getInteger(IVideoChannel.VIDEO_CHANNEL_TAG); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger(BEAM_FREQUENCY_TAG, beamFrequency); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger(BEAM_FREQUENCY_TAG, beamFrequency); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityLaserMedium.java b/src/main/java/cr0s/warpdrive/block/TileEntityLaserMedium.java index a602de77..9f30d2f6 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityLaserMedium.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityLaserMedium.java @@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityLaserMedium extends TileEntityAbstractEnergy { + private int ticks = 0; public TileEntityLaserMedium() { @@ -34,13 +35,13 @@ public class TileEntityLaserMedium extends TileEntityAbstractEnergy { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); } // IEnergySink methods implementation diff --git a/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorControlPoint.java b/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorControlPoint.java index 54049f5a..326f6722 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorControlPoint.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorControlPoint.java @@ -99,17 +99,17 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); isEnabled = !tagCompound.hasKey("isEnabled") || tagCompound.getBoolean("isEnabled"); controlChannel = tagCompound.getInteger(CONTROL_CHANNEL_TAG); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setBoolean("isEnabled", isEnabled); - tag.setInteger(CONTROL_CHANNEL_TAG, controlChannel); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setBoolean("isEnabled", isEnabled); + tagCompound.setInteger(CONTROL_CHANNEL_TAG, controlChannel); } @Override @@ -120,8 +120,8 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { - NBTTagCompound tagCompound = packet.func_148857_g(); + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { + final NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java index cd1c73ab..d2751f8e 100644 --- a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java @@ -424,14 +424,14 @@ public class TileEntityShipScanner extends TileEntityAbstractInterfaced implemen } // Compute target area - Transformation transformation = new Transformation(jumpShip, worldObj, targetX - jumpShip.coreX, targetY - jumpShip.coreY, targetZ - jumpShip.coreZ, rotationSteps); - ChunkCoordinates targetLocation1 = transformation.apply(jumpShip.minX, jumpShip.minY, jumpShip.minZ); - ChunkCoordinates targetLocation2 = transformation.apply(jumpShip.maxX, jumpShip.maxY, jumpShip.maxZ); - ChunkCoordinates targetLocationMin = new ChunkCoordinates( + final Transformation transformation = new Transformation(jumpShip, worldObj, targetX - jumpShip.coreX, targetY - jumpShip.coreY, targetZ - jumpShip.coreZ, rotationSteps); + final ChunkCoordinates targetLocation1 = transformation.apply(jumpShip.minX, jumpShip.minY, jumpShip.minZ); + final ChunkCoordinates targetLocation2 = transformation.apply(jumpShip.maxX, jumpShip.maxY, jumpShip.maxZ); + final ChunkCoordinates targetLocationMin = new ChunkCoordinates( Math.min(targetLocation1.posX, targetLocation2.posX) - 1, Math.max(0, Math.min(targetLocation1.posY, targetLocation2.posY) - 1), Math.min(targetLocation1.posZ, targetLocation2.posZ) - 1); - ChunkCoordinates targetLocationMax = new ChunkCoordinates( + final ChunkCoordinates targetLocationMax = new ChunkCoordinates( Math.max(targetLocation1.posX, targetLocation2.posX) + 1, Math.min(255, Math.max(targetLocation1.posY, targetLocation2.posY) + 1), Math.max(targetLocation1.posZ, targetLocation2.posZ) + 1); @@ -494,7 +494,7 @@ public class TileEntityShipScanner extends TileEntityAbstractInterfaced implemen } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); schematicFileName = tagCompound.getString("schematic"); targetX = tagCompound.getInteger("targetX"); @@ -525,7 +525,7 @@ public class TileEntityShipScanner extends TileEntityAbstractInterfaced implemen } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setString("schematic", schematicFileName); tagCompound.setInteger("targetX", targetX); diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityAbstractMiner.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityAbstractMiner.java index 865bf41e..44369e35 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityAbstractMiner.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityAbstractMiner.java @@ -98,14 +98,14 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser { // NBT DATA @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - enableSilktouch = tag.getBoolean("enableSilktouch"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + enableSilktouch = tagCompound.getBoolean("enableSilktouch"); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setBoolean("enableSilktouch", enableSilktouch); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setBoolean("enableSilktouch", enableSilktouch); } } diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java index cc731c36..8931977a 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java @@ -556,32 +556,32 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner { } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger("radiusX", radiusX); - tag.setInteger("radiusZ", radiusZ); - tag.setBoolean("breakLeaves", breakLeaves); - tag.setBoolean("tapTrees", tapTrees); - tag.setInteger("currentState", currentState); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger("radiusX", radiusX); + tagCompound.setInteger("radiusZ", radiusZ); + tagCompound.setBoolean("breakLeaves", breakLeaves); + tagCompound.setBoolean("tapTrees", tapTrees); + tagCompound.setInteger("currentState", currentState); } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - radiusX = tag.getInteger("radiusX"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + radiusX = tagCompound.getInteger("radiusX"); if (radiusX == 0) { radiusX = 1; } radiusX = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusX); - radiusZ = tag.getInteger("radiusZ"); + radiusZ = tagCompound.getInteger("radiusZ"); if (radiusZ == 0) { radiusZ = 1; } radiusZ = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusZ); - breakLeaves = tag.getBoolean("breakLeaves"); - tapTrees = tag.getBoolean("tapTrees"); - currentState = tag.getInteger("currentState"); + breakLeaves = tagCompound.getBoolean("breakLeaves"); + tapTrees = tagCompound.getBoolean("tapTrees"); + currentState = tagCompound.getInteger("currentState"); if (currentState == STATE_HARVEST || currentState == STATE_TAP || currentState == STATE_PLANT) { bScanOnReload = true; } diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java index 010cb01f..ef33b710 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java @@ -361,21 +361,21 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - layerOffset = tag.getInteger("layerOffset"); - mineAllBlocks = tag.getBoolean("mineAllBlocks"); - currentState = tag.getInteger("currentState"); - currentLayer = tag.getInteger("currentLayer"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + layerOffset = tagCompound.getInteger("layerOffset"); + mineAllBlocks = tagCompound.getBoolean("mineAllBlocks"); + currentState = tagCompound.getInteger("currentState"); + currentLayer = tagCompound.getInteger("currentLayer"); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger("layerOffset", layerOffset); - tag.setBoolean("mineAllBlocks", mineAllBlocks); - tag.setInteger("currentState", currentState); - tag.setInteger("currentLayer", currentLayer); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger("layerOffset", layerOffset); + tagCompound.setBoolean("mineAllBlocks", mineAllBlocks); + tagCompound.setInteger("currentState", currentState); + tagCompound.setInteger("currentLayer", currentLayer); } // OpenComputer callback methods diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java index 3de6d77a..4c96cdc9 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java @@ -101,18 +101,18 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - videoChannel = tag.getInteger("frequency") + tag.getInteger(VIDEO_CHANNEL_TAG); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + videoChannel = tagCompound.getInteger("frequency") + tagCompound.getInteger(VIDEO_CHANNEL_TAG); if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) { WarpDrive.logger.info(this + " readFromNBT"); } } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger(VIDEO_CHANNEL_TAG, videoChannel); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger(VIDEO_CHANNEL_TAG, videoChannel); if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) { WarpDrive.logger.info(this + " writeToNBT"); } @@ -126,8 +126,8 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { - NBTTagCompound tagCompound = packet.func_148857_g(); + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { + final NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java index 4027d4f3..ee1a22c7 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java @@ -34,9 +34,9 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { public byte tier = 1; // cloaking field tier, 1 or 2 // inner coils color map - final float[] innerCoilColor_r = { 1.00f, 1.00f, 1.00f, 1.00f, 0.75f, 0.25f, 0.00f, 0.00f, 0.00f, 0.00f, 0.50f, 1.00f }; - final float[] innerCoilColor_g = { 0.00f, 0.25f, 0.75f, 1.00f, 1.00f, 1.00f, 1.00f, 1.00f, 0.50f, 0.25f, 0.00f, 0.00f }; - final float[] innerCoilColor_b = { 0.25f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.50f, 1.00f, 1.00f, 1.00f, 1.00f, 0.75f }; + private final float[] innerCoilColor_r = { 1.00f, 1.00f, 1.00f, 1.00f, 0.75f, 0.25f, 0.00f, 0.00f, 0.00f, 0.00f, 0.50f, 1.00f }; + private final float[] innerCoilColor_g = { 0.00f, 0.25f, 0.75f, 1.00f, 1.00f, 1.00f, 1.00f, 1.00f, 0.50f, 0.25f, 0.00f, 0.00f }; + private final float[] innerCoilColor_b = { 0.25f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.50f, 1.00f, 1.00f, 1.00f, 1.00f, 0.75f }; // Spatial cloaking field parameters private final boolean[] isValidInnerCoils = { false, false, false, false, false, false }; @@ -336,17 +336,17 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - tier = tag.getByte("tier"); - isEnabled = tag.getBoolean("enabled"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + tier = tagCompound.getByte("tier"); + isEnabled = tagCompound.getBoolean("enabled"); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setByte("tier", tier); - tag.setBoolean("enabled", isEnabled); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setByte("tier", tier); + tagCompound.setBoolean("enabled", isEnabled); } public boolean validateAssembly() { diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java index aaa5ff07..5a738c34 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java @@ -67,15 +67,15 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - videoChannel = tag.getInteger("frequency") + tag.getInteger(VIDEO_CHANNEL_TAG); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + videoChannel = tagCompound.getInteger("frequency") + tagCompound.getInteger(VIDEO_CHANNEL_TAG); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger(VIDEO_CHANNEL_TAG, videoChannel); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger(VIDEO_CHANNEL_TAG, videoChannel); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java index 6858c4b3..3eb9c945 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java @@ -76,13 +76,13 @@ public class TileEntityRadar extends TileEntityAbstractEnergy { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); } private int calculateEnergyRequired(final int parRadius) { diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java index 7e13d194..05fe18b7 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java @@ -53,10 +53,10 @@ public class BlockEnergyBank extends BlockAbstractContainer { list.add(itemStack); if (tier > 0) { itemStack = new ItemStack(item, 1, tier); - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - nbtTagCompound.setByte("tier", tier); - nbtTagCompound.setInteger("energy", WarpDriveConfig.ENERGY_BANK_MAX_ENERGY_STORED[tier - 1]); - itemStack.setTagCompound(nbtTagCompound); + final NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("tier", tier); + tagCompound.setInteger("energy", WarpDriveConfig.ENERGY_BANK_MAX_ENERGY_STORED[tier - 1]); + itemStack.setTagCompound(tagCompound); list.add(itemStack); } } @@ -102,9 +102,9 @@ public class BlockEnergyBank extends BlockAbstractContainer { if (itemStack == null || itemStack.getItem() != Item.getItemFromBlock(this)) { return 1; } - NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - if (nbtTagCompound != null && nbtTagCompound.hasKey("tier")) { - return nbtTagCompound.getByte("tier"); + final NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound != null && tagCompound.hasKey("tier")) { + return tagCompound.getByte("tier"); } else { return (byte) itemStack.getItemDamage(); } diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java index 3ff6c6fc..6adaed54 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java @@ -17,7 +17,7 @@ import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -86,7 +86,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen "stabilizerEnergy", "state" }); - CC_scripts = Arrays.asList("startup"); + CC_scripts = Collections.singletonList("startup"); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java index 30d32693..4f22292d 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java @@ -128,26 +128,26 @@ public class TileEntityEnergyBank extends TileEntityAbstractEnergy { // Forge overrides @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) { - super.writeToNBT(nbtTagCompound); - nbtTagCompound.setByte("tier", tier); - nbtTagCompound.setByteArray("modeSide", modeSide); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setByte("tier", tier); + tagCompound.setByteArray("modeSide", modeSide); } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) { - super.readFromNBT(nbtTagCompound); - tier = nbtTagCompound.getByte("tier"); - modeSide = nbtTagCompound.getByteArray("modeSide"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + tier = tagCompound.getByte("tier"); + modeSide = tagCompound.getByteArray("modeSide"); if (modeSide == null || modeSide.length != 6) { modeSide = MODE_DEFAULT_SIDES.clone(); } } @Override - public NBTTagCompound writeItemDropNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound = super.writeItemDropNBT(nbtTagCompound); - return nbtTagCompound; + public NBTTagCompound writeItemDropNBT(NBTTagCompound tagCompound) { + tagCompound = super.writeItemDropNBT(tagCompound); + return tagCompound; } @Override diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java index 5f849d68..0b757565 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java @@ -107,7 +107,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); tier = tagCompound.getByte("tier"); setBeamFrequency(tagCompound.getInteger(BEAM_FREQUENCY_TAG)); @@ -116,7 +116,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setByte("tier", tier); tagCompound.setInteger(BEAM_FREQUENCY_TAG, beamFrequency); @@ -132,8 +132,8 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { - NBTTagCompound tagCompound = packet.func_148857_g(); + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { + final NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java index f5b31f23..418b4ea8 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java @@ -35,17 +35,17 @@ public class TileEntityForceField extends TileEntityAbstractBase { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - if (tag.hasKey("projector")) { - vProjector = VectorI.createFromNBT(tag.getCompoundTag("projector")); - cache_beamFrequency = tag.getInteger(IBeamFrequency.BEAM_FREQUENCY_TAG); - if (tag.hasKey("camouflageBlock")) { + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + if (tagCompound.hasKey("projector")) { + vProjector = VectorI.createFromNBT(tagCompound.getCompoundTag("projector")); + cache_beamFrequency = tagCompound.getInteger(IBeamFrequency.BEAM_FREQUENCY_TAG); + if (tagCompound.hasKey("camouflageBlock")) { try { - cache_blockCamouflage = Block.getBlockFromName(tag.getString("camouflageBlock")); - cache_metadataCamouflage = tag.getByte("camouflageMeta"); - cache_colorMultiplierCamouflage = tag.getInteger("camouflageColorMultiplier"); - cache_lightCamouflage = tag.getByte("camouflageLight"); + cache_blockCamouflage = Block.getBlockFromName(tagCompound.getString("camouflageBlock")); + cache_metadataCamouflage = tagCompound.getByte("camouflageMeta"); + cache_colorMultiplierCamouflage = tagCompound.getInteger("camouflageColorMultiplier"); + cache_lightCamouflage = tagCompound.getByte("camouflageLight"); if (Dictionary.BLOCKS_NOCAMOUFLAGE.contains(cache_blockCamouflage)) { cache_blockCamouflage = null; cache_metadataCamouflage = 0; @@ -72,7 +72,7 @@ public class TileEntityForceField extends TileEntityAbstractBase { } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); if (vProjector != null) { tagCompound.setTag("projector", vProjector.writeToNBT(new NBTTagCompound())); @@ -95,7 +95,7 @@ public class TileEntityForceField extends TileEntityAbstractBase { } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java index 935a88b5..a7549d26 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java @@ -887,7 +887,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); isDoubleSided = tagCompound.getBoolean("isDoubleSided"); @@ -914,7 +914,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setBoolean("isDoubleSided", isDoubleSided); @@ -960,7 +960,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { final NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldRelay.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldRelay.java index 942eeec0..8a11a80d 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldRelay.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldRelay.java @@ -51,13 +51,13 @@ public class TileEntityForceFieldRelay extends TileEntityAbstractForceField impl } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); setUpgrade(EnumForceFieldUpgrade.get(tagCompound.getByte("upgrade"))); } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(final NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setByte("upgrade", (byte) getUpgrade().ordinal()); } @@ -70,7 +70,7 @@ public class TileEntityForceFieldRelay extends TileEntityAbstractForceField impl } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { final NBTTagCompound tagCompound = packet.func_148857_g(); readFromNBT(tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityLift.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityLift.java index 4900ed7f..9938f3f2 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityLift.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityLift.java @@ -26,7 +26,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityLift extends TileEntityAbstractEnergy implements ILift { - final double LIFT_GRAB_RADIUS = 0.4; + private static final double LIFT_GRAB_RADIUS = 0.4D; // persistent properties private EnumLiftMode mode = EnumLiftMode.INACTIVE; @@ -139,8 +139,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy implements ILift { final List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb); if (list != null) { for (Object object : list) { - if ( object != null - && object instanceof EntityLivingBase + if ( object instanceof EntityLivingBase && energy_consume(WarpDriveConfig.LIFT_ENERGY_PER_ENTITY, true)) { ((EntityLivingBase) object).setPositionAndUpdate(xCoord + 0.5D, yCoord + 1.0D, zCoord + 0.5D); PacketHandler.sendBeamPacket(worldObj, @@ -161,8 +160,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy implements ILift { final List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb); if (list != null) { for (Object object : list) { - if ( object != null - && object instanceof EntityLivingBase + if ( object instanceof EntityLivingBase && energy_consume(WarpDriveConfig.LIFT_ENERGY_PER_ENTITY, true)) { ((EntityLivingBase) object).setPositionAndUpdate(xCoord + 0.5D, firstUncoveredY, zCoord + 0.5D); PacketHandler.sendBeamPacket(worldObj, @@ -180,29 +178,29 @@ public class TileEntityLift extends TileEntityAbstractEnergy implements ILift { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - if (tag.hasKey("mode")) { - final byte byteValue = tag.getByte("mode"); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + if (tagCompound.hasKey("mode")) { + final byte byteValue = tagCompound.getByte("mode"); mode = EnumLiftMode.get(Commons.clamp(0, 3, byteValue == -1 ? 3 : byteValue)); } - if (tag.hasKey("computerEnabled")) { - isEnabled = tag.getBoolean("computerEnabled"); // up to 1.3.30 included - } else if (tag.hasKey("isEnabled")) { - isEnabled = tag.getBoolean("isEnabled"); + if (tagCompound.hasKey("computerEnabled")) { + isEnabled = tagCompound.getBoolean("computerEnabled"); // up to 1.3.30 included + } else if (tagCompound.hasKey("isEnabled")) { + isEnabled = tagCompound.getBoolean("isEnabled"); } - if (tag.hasKey("computerMode")) { - final byte byteValue = tag.getByte("computerMode"); + if (tagCompound.hasKey("computerMode")) { + final byte byteValue = tagCompound.getByte("computerMode"); computerMode = EnumLiftMode.get(Commons.clamp(0, 3, byteValue == -1 ? 3 : byteValue)); } } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setByte("mode", (byte) mode.ordinal()); - tag.setBoolean("isEnabled", isEnabled); - tag.setByte("computerMode", (byte) computerMode.ordinal()); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setByte("mode", (byte) mode.ordinal()); + tagCompound.setBoolean("isEnabled", isEnabled); + tagCompound.setByte("computerMode", (byte) computerMode.ordinal()); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java index b74f802c..d8e2836b 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java @@ -194,25 +194,25 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple } @Override - public NBTTagCompound writeItemDropNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound = super.writeItemDropNBT(nbtTagCompound); + public NBTTagCompound writeItemDropNBT(NBTTagCompound tagCompound) { + tagCompound = super.writeItemDropNBT(tagCompound); - nbtTagCompound.removeTag("players"); + tagCompound.removeTag("players"); - nbtTagCompound.removeTag("isEnabled"); - nbtTagCompound.removeTag("command"); - nbtTagCompound.removeTag("front"); - nbtTagCompound.removeTag("right"); - nbtTagCompound.removeTag("up"); - nbtTagCompound.removeTag("back"); - nbtTagCompound.removeTag("left"); - nbtTagCompound.removeTag("down"); - nbtTagCompound.removeTag("moveFront"); - nbtTagCompound.removeTag("moveUp"); - nbtTagCompound.removeTag("moveRight"); - nbtTagCompound.removeTag("rotationSteps"); - nbtTagCompound.removeTag("nameTarget"); - return nbtTagCompound; + tagCompound.removeTag("isEnabled"); + tagCompound.removeTag("command"); + tagCompound.removeTag("front"); + tagCompound.removeTag("right"); + tagCompound.removeTag("up"); + tagCompound.removeTag("back"); + tagCompound.removeTag("left"); + tagCompound.removeTag("down"); + tagCompound.removeTag("moveFront"); + tagCompound.removeTag("moveUp"); + tagCompound.removeTag("moveRight"); + tagCompound.removeTag("rotationSteps"); + tagCompound.removeTag("nameTarget"); + return tagCompound; } @Override diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java index acb58d7e..17846155 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java @@ -1118,35 +1118,37 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - facing = ForgeDirection.getOrientation(tag.getByte("facing")); - uuid = new UUID(tag.getLong("uuidMost"), tag.getLong("uuidLeast")); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + + facing = ForgeDirection.getOrientation(tagCompound.getByte("facing")); + uuid = new UUID(tagCompound.getLong("uuidMost"), tagCompound.getLong("uuidLeast")); if (uuid.getMostSignificantBits() == 0 && uuid.getLeastSignificantBits() == 0) { uuid = UUID.randomUUID(); } - shipName = tag.getString("corefrequency") + tag.getString("shipName"); // coreFrequency is the legacy tag name - isolationRate = tag.getDouble("isolationRate"); - cooldownTime_ticks = tag.getInteger("cooldownTime"); - warmupTime_ticks = tag.getInteger("warmupTime"); - jumpCount = tag.getInteger("jumpCount"); + shipName = tagCompound.getString("corefrequency") + tagCompound.getString("shipName"); // coreFrequency is the legacy tag name + isolationRate = tagCompound.getDouble("isolationRate"); + cooldownTime_ticks = tagCompound.getInteger("cooldownTime"); + warmupTime_ticks = tagCompound.getInteger("warmupTime"); + jumpCount = tagCompound.getInteger("jumpCount"); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + if (facing != null) { - tag.setByte("facing", (byte) facing.ordinal()); + tagCompound.setByte("facing", (byte) facing.ordinal()); } if (uuid != null) { - tag.setLong("uuidMost", uuid.getMostSignificantBits()); - tag.setLong("uuidLeast", uuid.getLeastSignificantBits()); + tagCompound.setLong("uuidMost", uuid.getMostSignificantBits()); + tagCompound.setLong("uuidLeast", uuid.getLeastSignificantBits()); } - tag.setString("shipName", shipName); - tag.setDouble("isolationRate", isolationRate); - tag.setInteger("cooldownTime", cooldownTime_ticks); - tag.setInteger("warmupTime", warmupTime_ticks); - tag.setInteger("jumpCount", jumpCount); + tagCompound.setString("shipName", shipName); + tagCompound.setDouble("isolationRate", isolationRate); + tagCompound.setInteger("cooldownTime", cooldownTime_ticks); + tagCompound.setInteger("warmupTime", warmupTime_ticks); + tagCompound.setInteger("jumpCount", jumpCount); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java index f7e5a539..0cf2c52a 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java @@ -83,28 +83,28 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - setVideoChannel(tag.getInteger("cameraFrequency") + tag.getInteger(VIDEO_CHANNEL_TAG)); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + setVideoChannel(tagCompound.getInteger("cameraFrequency") + tagCompound.getInteger(VIDEO_CHANNEL_TAG)); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setInteger(VIDEO_CHANNEL_TAG, videoChannel); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger(VIDEO_CHANNEL_TAG, videoChannel); } @Override public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); + final NBTTagCompound tagCompound = new NBTTagCompound(); // (beam frequency is server side only) tagCompound.setInteger(VIDEO_CHANNEL_TAG, videoChannel); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound); } @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { - NBTTagCompound tagCompound = packet.func_148857_g(); + public void onDataPacket(final NetworkManager networkManager, final S35PacketUpdateTileEntity packet) { + final NBTTagCompound tagCompound = packet.func_148857_g(); // (beam frequency is server side only) setVideoChannel(tagCompound.getInteger(VIDEO_CHANNEL_TAG)); } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java index a0a5c2dc..9d015386 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java @@ -2,7 +2,7 @@ package cr0s.warpdrive.block.weapon; import cr0s.warpdrive.block.TileEntityAbstractInterfaced; -import java.util.Arrays; +import java.util.Collections; import net.minecraft.nbt.NBTTagCompound; @@ -14,7 +14,7 @@ public class TileEntityWeaponController extends TileEntityAbstractInterfaced { peripheralName = "warpdriveWeaponController"; addMethods(new String[] { }); - CC_scripts = Arrays.asList("startup"); + CC_scripts = Collections.singletonList("startup"); } @Override @@ -23,13 +23,13 @@ public class TileEntityWeaponController extends TileEntityAbstractInterfaced { } @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); } @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); } @Override diff --git a/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java b/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java index 5511a9e8..c255e7f0 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java @@ -134,13 +134,13 @@ public class CompatArsMagica2 implements IBlockTransformer { if (!(tileEntity instanceof IPowerNode) || nbtBase == null) { return; } - final NBTTagCompound nbtTagCompound = (NBTTagCompound) nbtBase; + final NBTTagCompound tagCompound = (NBTTagCompound) nbtBase; // powerAmounts // (no changes) // powerPathList - final NBTTagList powerPathList = nbtTagCompound.getTagList("powerPathList", Constants.NBT.TAG_COMPOUND); + final NBTTagList powerPathList = tagCompound.getTagList("powerPathList", Constants.NBT.TAG_COMPOUND); if (powerPathList != null) { for (int powerPathIndex = 0; powerPathIndex < powerPathList.tagCount(); powerPathIndex++) { final NBTTagCompound powerPathEntry = (NBTTagCompound) powerPathList.removeTag(0); @@ -172,7 +172,7 @@ public class CompatArsMagica2 implements IBlockTransformer { } powerPathList.appendTag(powerPathEntry); } - nbtTagCompound.setTag("powerPathList", powerPathList); + tagCompound.setTag("powerPathList", powerPathList); } final World targetWorld = transformation.getTargetWorld(); @@ -183,7 +183,7 @@ public class CompatArsMagica2 implements IBlockTransformer { } else if (!(tileEntityTarget instanceof IPowerNode)) { WarpDrive.logger.error("ArsMagica2 compat: invalid tile entity " + tileEntityTarget + " found at target location " + target + "."); } else { - PowerNodeRegistry.For(targetWorld).setDataCompoundForNode((IPowerNode) tileEntityTarget, nbtTagCompound); + PowerNodeRegistry.For(targetWorld).setDataCompoundForNode((IPowerNode) tileEntityTarget, tagCompound); } } } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java b/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java index 68b7e17e..55fbc9ec 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java @@ -77,19 +77,19 @@ public class CompatStargateTech2 implements IBlockTransformer { rotFacingcolors = Collections.unmodifiableMap(map); } - private static NBTTagCompound rotateVector(ITransformation transformation, NBTTagCompound tag) { - ChunkCoordinates target = transformation.apply(tag.getInteger("x"), tag.getInteger("y"), tag.getInteger("z")); - tag.setInteger("x", target.posX); - tag.setInteger("y", target.posY); - tag.setInteger("z", target.posZ); - return tag; + private static NBTTagCompound rotateVector(final ITransformation transformation, final NBTTagCompound tagCompound) { + final ChunkCoordinates target = transformation.apply(tagCompound.getInteger("x"), tagCompound.getInteger("y"), tagCompound.getInteger("z")); + tagCompound.setInteger("x", target.posX); + tagCompound.setInteger("y", target.posY); + tagCompound.setInteger("z", target.posZ); + return tagCompound; } - private static NBTTagCompound rotateFacingColors(final Byte rotationSteps, final NBTTagCompound tag) { + private static NBTTagCompound rotateFacingColors(final Byte rotationSteps, final NBTTagCompound tagCompound) { final NBTTagCompound newFacing = new NBTTagCompound(); - final Set keys = tag.func_150296_c(); + final Set keys = tagCompound.func_150296_c(); for (final String key : keys) { - NBTBase base = tag.getTag(key); + NBTBase base = tagCompound.getTag(key); if (base instanceof NBTTagByte && rotFacingcolors.containsKey(key)) { switch (rotationSteps) { case 1: diff --git a/src/main/java/cr0s/warpdrive/config/Filler.java b/src/main/java/cr0s/warpdrive/config/Filler.java index b8bb6aa8..16e8ae86 100644 --- a/src/main/java/cr0s/warpdrive/config/Filler.java +++ b/src/main/java/cr0s/warpdrive/config/Filler.java @@ -24,13 +24,13 @@ public class Filler implements IXmlRepresentableUnit { DEFAULT.name = "-default-"; DEFAULT.block = Blocks.air; DEFAULT.metadata = 0; - DEFAULT.nbtTagCompound = null; + DEFAULT.tagCompound = null; } private String name; public Block block; public int metadata; - public NBTTagCompound nbtTagCompound = null; + public NBTTagCompound tagCompound = null; @Override public String getName() { @@ -67,17 +67,17 @@ public class Filler implements IXmlRepresentableUnit { } // Get nbt attribute, default to null/none - nbtTagCompound = null; + tagCompound = null; String stringNBT = element.getAttribute("nbt"); if (!stringNBT.isEmpty()) { try { - nbtTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); + tagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); } catch (NBTException exception) { throw new InvalidXmlException("Invalid nbt for block " + nameBlock); } } - name = nameBlock + "@" + metadata + "{" + nbtTagCompound + "}"; + name = nameBlock + "@" + metadata + "{" + tagCompound + "}"; return true; } @@ -85,7 +85,7 @@ public class Filler implements IXmlRepresentableUnit { public void setBlock(World world, int x, int y, int z) { JumpBlock.setBlockNoLight(world, x, y, z, block, metadata, 2); - if (nbtTagCompound != null) { + if (tagCompound != null) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity == null) { WarpDrive.logger.error("No TileEntity found for Filler %s at (%d %d %d)", @@ -97,9 +97,9 @@ public class Filler implements IXmlRepresentableUnit { NBTTagCompound nbtTagCompoundTileEntity = new NBTTagCompound(); tileEntity.writeToNBT(nbtTagCompoundTileEntity); - for (Object key : nbtTagCompound.func_150296_c()) { + for (Object key : tagCompound.func_150296_c()) { if (key instanceof String) { - nbtTagCompoundTileEntity.setTag((String) key, nbtTagCompound.getTag((String) key)); + nbtTagCompoundTileEntity.setTag((String) key, tagCompound.getTag((String) key)); } } @@ -122,7 +122,7 @@ public class Filler implements IXmlRepresentableUnit { return object instanceof Filler && (block == null || block.equals(((Filler)object).block)) && metadata == ((Filler)object).metadata - && (nbtTagCompound == null || nbtTagCompound.equals(((Filler)object).nbtTagCompound)); + && (tagCompound == null || tagCompound.equals(((Filler)object).tagCompound)); } @Override @@ -132,6 +132,6 @@ public class Filler implements IXmlRepresentableUnit { @Override public int hashCode() { - return Block.getIdFromBlock(block) * 16 + metadata + (nbtTagCompound == null ? 0 : nbtTagCompound.hashCode() * 4096 * 16); + return Block.getIdFromBlock(block) * 16 + metadata + (tagCompound == null ? 0 : tagCompound.hashCode() * 4096 * 16); } } diff --git a/src/main/java/cr0s/warpdrive/config/Loot.java b/src/main/java/cr0s/warpdrive/config/Loot.java index 58768e6e..4864d9df 100644 --- a/src/main/java/cr0s/warpdrive/config/Loot.java +++ b/src/main/java/cr0s/warpdrive/config/Loot.java @@ -24,7 +24,7 @@ public class Loot implements IXmlRepresentableUnit { DEFAULT.name = "-default-"; DEFAULT.item = Items.stick; DEFAULT.damage = 0; - DEFAULT.nbtTagCompound = null; + DEFAULT.tagCompound = null; DEFAULT.quantityMin = 0; DEFAULT.quantityMax = 0; } @@ -32,7 +32,7 @@ public class Loot implements IXmlRepresentableUnit { private String name; public Item item; public int damage; - public NBTTagCompound nbtTagCompound = null; + public NBTTagCompound tagCompound = null; public int quantityMin; public int quantityMax; @@ -71,11 +71,11 @@ public class Loot implements IXmlRepresentableUnit { } // Get nbt attribute, default to null/none - nbtTagCompound = null; + tagCompound = null; final String stringNBT = element.getAttribute("nbt"); if (!stringNBT.isEmpty()) { try { - nbtTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); + tagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); } catch (NBTException exception) { throw new InvalidXmlException("Invalid nbt for item " + nameItem); } @@ -103,7 +103,7 @@ public class Loot implements IXmlRepresentableUnit { } } - name = nameItem + "@" + damage + "{" + nbtTagCompound + "}"; + name = nameItem + "@" + damage + "{" + tagCompound + "}"; return true; } @@ -111,8 +111,8 @@ public class Loot implements IXmlRepresentableUnit { public ItemStack getItemStack(final Random rand) { final int quantity = quantityMin + (quantityMax > quantityMin ? rand.nextInt(quantityMax - quantityMin) : 0); final ItemStack itemStack = new ItemStack(item, quantity, damage); - if (nbtTagCompound != null) { - NBTTagCompound nbtTagCompoundNew = (NBTTagCompound) nbtTagCompound.copy(); + if (tagCompound != null) { + NBTTagCompound nbtTagCompoundNew = (NBTTagCompound) tagCompound.copy(); itemStack.setTagCompound(nbtTagCompoundNew); } return itemStack; @@ -128,7 +128,7 @@ public class Loot implements IXmlRepresentableUnit { return object instanceof Loot && (item == null || item.equals(((Loot) object).item)) && damage == ((Loot) object).damage - && (nbtTagCompound == null || nbtTagCompound.equals(((Loot) object).nbtTagCompound)); + && (tagCompound == null || tagCompound.equals(((Loot) object).tagCompound)); } @Override @@ -138,6 +138,6 @@ public class Loot implements IXmlRepresentableUnit { @Override public int hashCode() { - return Item.getIdFromItem(item) * 16 + damage + (nbtTagCompound == null ? 0 : nbtTagCompound.hashCode() * 32768 * 16); + return Item.getIdFromItem(item) * 16 + damage + (tagCompound == null ? 0 : tagCompound.hashCode() * 32768 * 16); } } diff --git a/src/main/java/cr0s/warpdrive/config/structures/AbstractStructureInstance.java b/src/main/java/cr0s/warpdrive/config/structures/AbstractStructureInstance.java index fbe5145a..6058e1af 100644 --- a/src/main/java/cr0s/warpdrive/config/structures/AbstractStructureInstance.java +++ b/src/main/java/cr0s/warpdrive/config/structures/AbstractStructureInstance.java @@ -51,15 +51,15 @@ public abstract class AbstractStructureInstance extends WorldGenerator { return result; } - public AbstractStructureInstance(NBTTagCompound tag) { + public AbstractStructureInstance(final NBTTagCompound tagCompound) { // FIXME to be implemented // get deployable - // String deployableName = tag.getString("wd_structureName"); + // String deployableName = tagCompound.getString("wd_structureName"); // get variables values /* - final NBTTagCompound tagVariables = tag.getCompoundTag("wd_variables"); + final NBTTagCompound tagVariables = tagCompound.getCompoundTag("wd_variables"); final NBTTagList names = tagVariables.getTagList("x", 0); for (final Entry entry : tagVariables.getTagList("x", 0)) { tagVariables.setDouble(entry.getKey(), entry.getValue()); diff --git a/src/main/java/cr0s/warpdrive/config/structures/AsteroidFieldInstance.java b/src/main/java/cr0s/warpdrive/config/structures/AsteroidFieldInstance.java index e3358b78..064193f1 100644 --- a/src/main/java/cr0s/warpdrive/config/structures/AsteroidFieldInstance.java +++ b/src/main/java/cr0s/warpdrive/config/structures/AsteroidFieldInstance.java @@ -17,8 +17,8 @@ public class AsteroidFieldInstance extends AbstractStructureInstance { super(asteroidField, random); } - public AsteroidFieldInstance(final NBTTagCompound tag) { - super(tag); + public AsteroidFieldInstance(final NBTTagCompound tagCompound) { + super(tagCompound); // TODO not implemented } diff --git a/src/main/java/cr0s/warpdrive/config/structures/OrbInstance.java b/src/main/java/cr0s/warpdrive/config/structures/OrbInstance.java index 79514b27..e140fa39 100644 --- a/src/main/java/cr0s/warpdrive/config/structures/OrbInstance.java +++ b/src/main/java/cr0s/warpdrive/config/structures/OrbInstance.java @@ -56,8 +56,8 @@ public class OrbInstance extends AbstractStructureInstance { schematicName = orb.schematicName; } - public OrbInstance(NBTTagCompound tag) { - super(tag); + public OrbInstance(final NBTTagCompound tagCompound) { + super(tagCompound); // TODO not implemented } diff --git a/src/main/java/cr0s/warpdrive/data/AcceleratorControlParameter.java b/src/main/java/cr0s/warpdrive/data/AcceleratorControlParameter.java index 480ceb33..6bfcf47d 100644 --- a/src/main/java/cr0s/warpdrive/data/AcceleratorControlParameter.java +++ b/src/main/java/cr0s/warpdrive/data/AcceleratorControlParameter.java @@ -17,23 +17,23 @@ public class AcceleratorControlParameter { this.controlChannel = controlChannel; } - public AcceleratorControlParameter(final NBTTagCompound nbtTagCompound) { - readFromNBT(nbtTagCompound); + public AcceleratorControlParameter(final NBTTagCompound tagCompound) { + readFromNBT(tagCompound); } - private void readFromNBT(final NBTTagCompound nbtTagCompound) { - controlChannel = nbtTagCompound.getInteger(IControlChannel.CONTROL_CHANNEL_TAG); - isEnabled = !nbtTagCompound.hasKey("isEnabled") || nbtTagCompound.getBoolean("isEnabled"); - threshold = nbtTagCompound.getDouble("threshold"); - description = nbtTagCompound.getString("description"); + private void readFromNBT(final NBTTagCompound tagCompound) { + controlChannel = tagCompound.getInteger(IControlChannel.CONTROL_CHANNEL_TAG); + isEnabled = !tagCompound.hasKey("isEnabled") || tagCompound.getBoolean("isEnabled"); + threshold = tagCompound.getDouble("threshold"); + description = tagCompound.getString("description"); } - public NBTTagCompound writeToNBT(final NBTTagCompound nbtTagCompound) { - nbtTagCompound.setInteger(IControlChannel.CONTROL_CHANNEL_TAG, controlChannel); - nbtTagCompound.setBoolean("isEnabled", isEnabled); - nbtTagCompound.setDouble("threshold", threshold); - nbtTagCompound.setString("description", description); - return nbtTagCompound; + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setInteger(IControlChannel.CONTROL_CHANNEL_TAG, controlChannel); + tagCompound.setBoolean("isEnabled", isEnabled); + tagCompound.setDouble("threshold", threshold); + tagCompound.setString("description", description); + return tagCompound; } // Hash based collections need a stable hashcode, so we use a unique id instead diff --git a/src/main/java/cr0s/warpdrive/data/CelestialObject.java b/src/main/java/cr0s/warpdrive/data/CelestialObject.java index 8d2c7216..d7608c64 100644 --- a/src/main/java/cr0s/warpdrive/data/CelestialObject.java +++ b/src/main/java/cr0s/warpdrive/data/CelestialObject.java @@ -54,7 +54,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti private String displayName; private String description; - private NBTTagCompound nbtTagCompound; + private NBTTagCompound tagCompound; private boolean isVirtual; public int dimensionId; @@ -182,13 +182,13 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti if (listElements.size() > 1) { throw new InvalidXmlException(String.format("Celestial object %s can only have up to one nbt element", id)); } - nbtTagCompound = null; + tagCompound = null; if (listElements.size() == 1) { final Element elementName = listElements.get(0); final String stringNBT = elementName.getTextContent(); if (!stringNBT.isEmpty()) { try { - nbtTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); + tagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(stringNBT); } catch (NBTException exception) { throw new InvalidXmlException(String.format("Invalid nbt for Celestial object %s", id)); } @@ -412,7 +412,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti @Override public NBTTagCompound getTag() { - return nbtTagCompound; + return tagCompound; } @Override @@ -566,22 +566,22 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti && (Math.abs(z - parentCenterZ) <= borderRadiusZ); } - public void readFromNBT(NBTTagCompound nbtTagCompound) { + public void readFromNBT(final NBTTagCompound tagCompound) { isParentResolved = false; - id = nbtTagCompound.getString("id"); + id = tagCompound.getString("id"); - parentId = nbtTagCompound.getString("parentId"); - parentCenterX = nbtTagCompound.getInteger("parentCenterX"); - parentCenterZ = nbtTagCompound.getInteger("parentCenterZ"); + parentId = tagCompound.getString("parentId"); + parentCenterX = tagCompound.getInteger("parentCenterX"); + parentCenterZ = tagCompound.getInteger("parentCenterZ"); - borderRadiusX = nbtTagCompound.getInteger("borderRadiusX"); - borderRadiusZ = nbtTagCompound.getInteger("borderRadiusZ"); + borderRadiusX = tagCompound.getInteger("borderRadiusX"); + borderRadiusZ = tagCompound.getInteger("borderRadiusZ"); - displayName = nbtTagCompound.getString("displayName"); - description = nbtTagCompound.getString("description"); + displayName = tagCompound.getString("displayName"); + description = tagCompound.getString("description"); - isVirtual = nbtTagCompound.getBoolean("isVirtual"); + isVirtual = tagCompound.getBoolean("isVirtual"); if (isVirtual) { dimensionId = 0; dimensionCenterX = 0; @@ -591,76 +591,76 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti isHyperspace = false; provider = PROVIDER_NONE; } else { - dimensionId = nbtTagCompound.getInteger("dimensionId"); - dimensionCenterX = nbtTagCompound.getInteger("dimensionCenterX"); - dimensionCenterZ = nbtTagCompound.getInteger("dimensionCenterZ"); - gravity = nbtTagCompound.getDouble("gravity"); - isBreathable = nbtTagCompound.getBoolean("isBreathable"); - isHyperspace = nbtTagCompound.getBoolean("isHyperspace"); - provider = nbtTagCompound.getString("provider"); + dimensionId = tagCompound.getInteger("dimensionId"); + dimensionCenterX = tagCompound.getInteger("dimensionCenterX"); + dimensionCenterZ = tagCompound.getInteger("dimensionCenterZ"); + gravity = tagCompound.getDouble("gravity"); + isBreathable = tagCompound.getBoolean("isBreathable"); + isHyperspace = tagCompound.getBoolean("isHyperspace"); + provider = tagCompound.getString("provider"); } // randomStructures are server side only - backgroundColor = new ColorData(nbtTagCompound.getCompoundTag("backgroundColor")); - baseStarBrightness = nbtTagCompound.getFloat("baseStarBrightness"); - vanillaStarBrightness = nbtTagCompound.getFloat("vanillaStarBrightness"); - opacityCelestialObjects = nbtTagCompound.getFloat("opacityCelestialObjects"); - colorFog = new ColorData(nbtTagCompound.getCompoundTag("colorFog")); - factorFog = new ColorData(nbtTagCompound.getCompoundTag("factorFog")); + backgroundColor = new ColorData(tagCompound.getCompoundTag("backgroundColor")); + baseStarBrightness = tagCompound.getFloat("baseStarBrightness"); + vanillaStarBrightness = tagCompound.getFloat("vanillaStarBrightness"); + opacityCelestialObjects = tagCompound.getFloat("opacityCelestialObjects"); + colorFog = new ColorData(tagCompound.getCompoundTag("colorFog")); + factorFog = new ColorData(tagCompound.getCompoundTag("factorFog")); - final NBTTagList nbtTagListRenderData = nbtTagCompound.getTagList("renderData", NBT.TAG_COMPOUND); - final int countRender = nbtTagListRenderData.tagCount(); + final NBTTagList tagListRenderData = tagCompound.getTagList("renderData", NBT.TAG_COMPOUND); + final int countRender = tagListRenderData.tagCount(); setRenderData = new LinkedHashSet<>(countRender); for (int indexRenderData = 0; indexRenderData < countRender; indexRenderData++) { - final NBTTagCompound tagCompoundRenderData = nbtTagListRenderData.getCompoundTagAt(indexRenderData); + final NBTTagCompound tagCompoundRenderData = tagListRenderData.getCompoundTagAt(indexRenderData); setRenderData.add(new RenderData(tagCompoundRenderData)); } } - public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setString("id", id); + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setString("id", id); - nbtTagCompound.setString("parentId", parentId); - nbtTagCompound.setInteger("parentCenterX", parentCenterX); - nbtTagCompound.setInteger("parentCenterZ", parentCenterZ); + tagCompound.setString("parentId", parentId); + tagCompound.setInteger("parentCenterX", parentCenterX); + tagCompound.setInteger("parentCenterZ", parentCenterZ); - nbtTagCompound.setInteger("borderRadiusX", borderRadiusX); - nbtTagCompound.setInteger("borderRadiusZ", borderRadiusZ); + tagCompound.setInteger("borderRadiusX", borderRadiusX); + tagCompound.setInteger("borderRadiusZ", borderRadiusZ); if (displayName != null && !displayName.isEmpty()) { - nbtTagCompound.setString("displayName", displayName); + tagCompound.setString("displayName", displayName); } if (description != null && !description.isEmpty()) { - nbtTagCompound.setString("description", description); + tagCompound.setString("description", description); } - nbtTagCompound.setBoolean("isVirtual", isVirtual); + tagCompound.setBoolean("isVirtual", isVirtual); if (!isVirtual) { - nbtTagCompound.setInteger("dimensionId", dimensionId); - nbtTagCompound.setInteger("dimensionCenterX", dimensionCenterX); - nbtTagCompound.setInteger("dimensionCenterZ", dimensionCenterZ); - nbtTagCompound.setDouble("gravity", gravity); - nbtTagCompound.setBoolean("isBreathable", isBreathable); - nbtTagCompound.setBoolean("isHyperspace", isHyperspace); - nbtTagCompound.setString("provider", provider); + tagCompound.setInteger("dimensionId", dimensionId); + tagCompound.setInteger("dimensionCenterX", dimensionCenterX); + tagCompound.setInteger("dimensionCenterZ", dimensionCenterZ); + tagCompound.setDouble("gravity", gravity); + tagCompound.setBoolean("isBreathable", isBreathable); + tagCompound.setBoolean("isHyperspace", isHyperspace); + tagCompound.setString("provider", provider); } // randomStructures are server side only - nbtTagCompound.setTag("backgroundColor", backgroundColor.writeToNBT(new NBTTagCompound())); - nbtTagCompound.setFloat("baseStarBrightness", baseStarBrightness); - nbtTagCompound.setFloat("vanillaStarBrightness", vanillaStarBrightness); - nbtTagCompound.setFloat("opacityCelestialObjects", opacityCelestialObjects); - nbtTagCompound.setTag("colorFog", colorFog.writeToNBT(new NBTTagCompound())); - nbtTagCompound.setTag("factorFog", factorFog.writeToNBT(new NBTTagCompound())); + tagCompound.setTag("backgroundColor", backgroundColor.writeToNBT(new NBTTagCompound())); + tagCompound.setFloat("baseStarBrightness", baseStarBrightness); + tagCompound.setFloat("vanillaStarBrightness", vanillaStarBrightness); + tagCompound.setFloat("opacityCelestialObjects", opacityCelestialObjects); + tagCompound.setTag("colorFog", colorFog.writeToNBT(new NBTTagCompound())); + tagCompound.setTag("factorFog", factorFog.writeToNBT(new NBTTagCompound())); final NBTTagList nbtTagListRenderData = new NBTTagList(); for (final RenderData renderData : setRenderData) { nbtTagListRenderData.appendTag(renderData.writeToNBT(new NBTTagCompound())); } - nbtTagCompound.setTag("renderData", nbtTagListRenderData); - return nbtTagCompound; + tagCompound.setTag("renderData", nbtTagListRenderData); + return tagCompound; } @Override @@ -669,7 +669,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (object instanceof CelestialObject) { CelestialObject celestialObject = (CelestialObject) object; return dimensionId == celestialObject.dimensionId @@ -736,21 +736,21 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti } } - ColorData(final NBTTagCompound nbtTagCompound) { - readFromNBT(nbtTagCompound); + ColorData(final NBTTagCompound tagCompound) { + readFromNBT(tagCompound); } - public void readFromNBT(NBTTagCompound nbtTagCompound) { - red = nbtTagCompound.getFloat("red"); - green = nbtTagCompound.getFloat("green"); - blue = nbtTagCompound.getFloat("blue"); + public void readFromNBT(final NBTTagCompound tagCompound) { + red = tagCompound.getFloat("red"); + green = tagCompound.getFloat("green"); + blue = tagCompound.getFloat("blue"); } - public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setFloat("red", red); - nbtTagCompound.setFloat("green", green); - nbtTagCompound.setFloat("blue", blue); - return nbtTagCompound; + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setFloat("red", red); + tagCompound.setFloat("green", green); + tagCompound.setFloat("blue", blue); + return tagCompound; } } @@ -814,16 +814,16 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti } } - RenderData(final NBTTagCompound nbtTagCompound) { - readFromNBT(nbtTagCompound); + RenderData(final NBTTagCompound tagCompound) { + readFromNBT(tagCompound); } - public void readFromNBT(NBTTagCompound nbtTagCompound) { - red = nbtTagCompound.getFloat("red"); - green = nbtTagCompound.getFloat("green"); - blue = nbtTagCompound.getFloat("blue"); - alpha = nbtTagCompound.getFloat("alpha"); - texture = nbtTagCompound.getString("texture"); + public void readFromNBT(final NBTTagCompound tagCompound) { + red = tagCompound.getFloat("red"); + green = tagCompound.getFloat("green"); + blue = tagCompound.getFloat("blue"); + alpha = tagCompound.getFloat("alpha"); + texture = tagCompound.getString("texture"); if (texture == null || texture.isEmpty()) { texture = null; resourceLocation = null; @@ -832,24 +832,24 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti isAdditive = false; } else { resourceLocation = new ResourceLocation(texture); - periodU = nbtTagCompound.getDouble("periodU"); - periodV = nbtTagCompound.getDouble("periodV"); - isAdditive = nbtTagCompound.getBoolean("isAdditive"); + periodU = tagCompound.getDouble("periodU"); + periodV = tagCompound.getDouble("periodV"); + isAdditive = tagCompound.getBoolean("isAdditive"); } } - public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setFloat("red", red); - nbtTagCompound.setFloat("green", green); - nbtTagCompound.setFloat("blue", blue); - nbtTagCompound.setFloat("alpha", alpha); + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setFloat("red", red); + tagCompound.setFloat("green", green); + tagCompound.setFloat("blue", blue); + tagCompound.setFloat("alpha", alpha); if (texture != null) { - nbtTagCompound.setString("texture", texture); - nbtTagCompound.setDouble("periodU", periodU); - nbtTagCompound.setDouble("periodV", periodV); - nbtTagCompound.setBoolean("isAdditive", isAdditive); + tagCompound.setString("texture", texture); + tagCompound.setDouble("periodU", periodU); + tagCompound.setDouble("periodV", periodV); + tagCompound.setBoolean("isAdditive", isAdditive); } - return nbtTagCompound; + return tagCompound; } } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/data/ChunkData.java b/src/main/java/cr0s/warpdrive/data/ChunkData.java index bb807d8a..a0a75a93 100644 --- a/src/main/java/cr0s/warpdrive/data/ChunkData.java +++ b/src/main/java/cr0s/warpdrive/data/ChunkData.java @@ -53,7 +53,7 @@ public class ChunkData { timeUnloaded = 0L; } - public void load(final NBTTagCompound nbtTagCompoundChunk) { + public void load(final NBTTagCompound tagCompoundChunk) { // check consistency assert(!isLoaded); @@ -74,14 +74,14 @@ public class ChunkData { isModified = false; // check version - if (nbtTagCompoundChunk.hasKey(TAG_CHUNK_MOD_DATA)) { - final NBTTagCompound nbtTagCompound = nbtTagCompoundChunk.getCompoundTag(TAG_CHUNK_MOD_DATA); - final int version = nbtTagCompound.getInteger(TAG_VERSION); + if (tagCompoundChunk.hasKey(TAG_CHUNK_MOD_DATA)) { + final NBTTagCompound tagCompound = tagCompoundChunk.getCompoundTag(TAG_CHUNK_MOD_DATA); + final int version = tagCompound.getInteger(TAG_VERSION); assert (version == 0 || version == 1); // load from NBT data if (version == 1) { - final NBTTagList nbtTagList = nbtTagCompound.getTagList(TAG_AIR, Constants.NBT.TAG_COMPOUND); + final NBTTagList nbtTagList = tagCompound.getTagList(TAG_AIR, Constants.NBT.TAG_COMPOUND); if (nbtTagList.tagCount() != CHUNK_SIZE_SEGMENTS) { if (nbtTagList.tagCount() != 0) { WarpDrive.logger.error(String.format("Chunk %s (%d %d %d) loaded with invalid data, restoring default", @@ -170,7 +170,7 @@ public class ChunkData { } } - public void save(NBTTagCompound nbtTagCompoundChunk) { + public void save(final NBTTagCompound tagCompoundChunk) { // check consistency // (unload happens before saving) @@ -189,9 +189,9 @@ public class ChunkData { } // save to NBT data - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - nbtTagCompoundChunk.setTag(TAG_CHUNK_MOD_DATA, nbtTagCompound); - nbtTagCompound.setInteger(TAG_VERSION, 1); + final NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompoundChunk.setTag(TAG_CHUNK_MOD_DATA, tagCompound); + tagCompound.setInteger(TAG_VERSION, 1); NBTTagList nbtTagList = new NBTTagList(); @@ -200,7 +200,7 @@ public class ChunkData { final int[] intData = new int[SEGMENT_SIZE_BLOCKS]; final byte[] byteTick = new byte[SEGMENT_SIZE_BLOCKS]; for (int indexSegment = 0; indexSegment < CHUNK_SIZE_SEGMENTS; indexSegment++) { - final NBTTagCompound nbtTagCompoundInList = new NBTTagCompound(); + final NBTTagCompound tagCompoundInList = new NBTTagCompound(); // skip empty segment if (dataAirSegments[indexSegment] != null) { @@ -230,19 +230,19 @@ public class ChunkData { if (countEmptyBlocks == SEGMENT_SIZE_BLOCKS) { countEmptySegments++; } else { - nbtTagCompoundInList.setIntArray(TAG_AIR_SEGMENT_DATA, intData.clone()); - nbtTagCompoundInList.setByteArray(TAG_AIR_SEGMENT_DELAY, byteTick.clone()); - nbtTagCompoundInList.setByte(TAG_AIR_SEGMENT_Y, (byte) indexSegment); + tagCompoundInList.setIntArray(TAG_AIR_SEGMENT_DATA, intData.clone()); + tagCompoundInList.setByteArray(TAG_AIR_SEGMENT_DELAY, byteTick.clone()); + tagCompoundInList.setByte(TAG_AIR_SEGMENT_Y, (byte) indexSegment); } } else { countEmptySegments++; } - nbtTagList.appendTag(nbtTagCompoundInList); + nbtTagList.appendTag(tagCompoundInList); } // ignore tag if all segments are empty if (countEmptySegments != CHUNK_SIZE_SEGMENTS) { - nbtTagCompound.setTag(TAG_AIR, nbtTagList); + tagCompound.setTag(TAG_AIR, nbtTagList); } // mark as saved diff --git a/src/main/java/cr0s/warpdrive/data/ForceFieldRegistry.java b/src/main/java/cr0s/warpdrive/data/ForceFieldRegistry.java index 707a58da..7eca1350 100644 --- a/src/main/java/cr0s/warpdrive/data/ForceFieldRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/ForceFieldRegistry.java @@ -43,8 +43,8 @@ public class ForceFieldRegistry { Set setToIterate = new HashSet<>(); int range2; int maxRange2 = ForceFieldSetup.FORCEFIELD_RELAY_RANGE * ForceFieldSetup.FORCEFIELD_RELAY_RANGE; - for (GlobalPosition globalPosition : setGlobalPositions) { - WorldServer world = globalPosition.getWorldServerIfLoaded(); + for (final GlobalPosition globalPosition : setGlobalPositions) { + final WorldServer world = globalPosition.getWorldServerIfLoaded(); if (world != null) { // skip if it's in another dimension if (world != worldSource) { @@ -52,8 +52,9 @@ public class ForceFieldRegistry { } // confirm frequency and split by groups - TileEntity tileEntity = world.getTileEntity(globalPosition.x, globalPosition.y, globalPosition.z); - if ((tileEntity instanceof IBeamFrequency) && ((IBeamFrequency)tileEntity).getBeamFrequency() == beamFrequency) { + final TileEntity tileEntity = world.getTileEntity(globalPosition.x, globalPosition.y, globalPosition.z); + if ( (tileEntity instanceof IBeamFrequency) + && ((IBeamFrequency)tileEntity).getBeamFrequency() == beamFrequency ) { if (tileEntity instanceof TileEntityForceFieldRelay) { // add relays in range as start point range2 = (globalPosition.x - x) * (globalPosition.x - x) + (globalPosition.y - y) * (globalPosition.y - y) + (globalPosition.z - z) * (globalPosition.z - z); diff --git a/src/main/java/cr0s/warpdrive/data/JumpBlock.java b/src/main/java/cr0s/warpdrive/data/JumpBlock.java index 325dbb32..6714a75a 100644 --- a/src/main/java/cr0s/warpdrive/data/JumpBlock.java +++ b/src/main/java/cr0s/warpdrive/data/JumpBlock.java @@ -95,7 +95,7 @@ public class JumpBlock { } block = filler.block; blockMeta = filler.metadata; - blockNBT = (filler.nbtTagCompound != null) ? (NBTTagCompound) filler.nbtTagCompound.copy() : null; + blockNBT = (filler.tagCompound != null) ? (NBTTagCompound) filler.tagCompound.copy() : null; this.x = x; this.y = y; this.z = z; diff --git a/src/main/java/cr0s/warpdrive/data/Vector3.java b/src/main/java/cr0s/warpdrive/data/Vector3.java index f52391d9..43e9d59d 100644 --- a/src/main/java/cr0s/warpdrive/data/Vector3.java +++ b/src/main/java/cr0s/warpdrive/data/Vector3.java @@ -520,23 +520,23 @@ public class Vector3 implements Cloneable { } - public static Vector3 createFromNBT(NBTTagCompound nbtTagCompound) { + public static Vector3 createFromNBT(final NBTTagCompound tagCompound) { Vector3 vector = new Vector3(); - vector.readFromNBT(nbtTagCompound); + vector.readFromNBT(tagCompound); return vector; } - public void readFromNBT(NBTTagCompound nbtTagCompound) { - x = nbtTagCompound.getDouble("x"); - y = nbtTagCompound.getDouble("y"); - z = nbtTagCompound.getDouble("z"); + public void readFromNBT(final NBTTagCompound tagCompound) { + x = tagCompound.getDouble("x"); + y = tagCompound.getDouble("y"); + z = tagCompound.getDouble("z"); } - public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setDouble("x", x); - nbtTagCompound.setDouble("y", y); - nbtTagCompound.setDouble("z", z); - return nbtTagCompound; + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setDouble("x", x); + tagCompound.setDouble("y", y); + tagCompound.setDouble("z", z); + return tagCompound; } public static Vector3 UP() { diff --git a/src/main/java/cr0s/warpdrive/data/VectorI.java b/src/main/java/cr0s/warpdrive/data/VectorI.java index 0a660ffb..52bf1529 100644 --- a/src/main/java/cr0s/warpdrive/data/VectorI.java +++ b/src/main/java/cr0s/warpdrive/data/VectorI.java @@ -278,23 +278,23 @@ public class VectorI implements Cloneable { } - public static VectorI createFromNBT(NBTTagCompound nbtTagCompound) { + public static VectorI createFromNBT(final NBTTagCompound tagCompound) { VectorI vector = new VectorI(); - vector.readFromNBT(nbtTagCompound); + vector.readFromNBT(tagCompound); return vector; } - public void readFromNBT(final NBTTagCompound nbtTagCompound) { - x = nbtTagCompound.getInteger("x"); - y = nbtTagCompound.getInteger("y"); - z = nbtTagCompound.getInteger("z"); + public void readFromNBT(final NBTTagCompound tagCompound) { + x = tagCompound.getInteger("x"); + y = tagCompound.getInteger("y"); + z = tagCompound.getInteger("z"); } - public NBTTagCompound writeToNBT(final NBTTagCompound nbtTagCompound) { - nbtTagCompound.setInteger("x", x); - nbtTagCompound.setInteger("y", y); - nbtTagCompound.setInteger("z", z); - return nbtTagCompound; + public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { + tagCompound.setInteger("x", x); + tagCompound.setInteger("y", y); + tagCompound.setInteger("z", z); + return tagCompound; } // Square roots are evil, avoid them at all cost diff --git a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java index 59458541..2abcf465 100644 --- a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java +++ b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java @@ -132,37 +132,37 @@ public class EntityParticleBunch extends Entity { } @Override - protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) { - // energy = nbtTagCompound.getInteger("energy"); - vectorNextPosition = Vector3.createFromNBT(nbtTagCompound.getCompoundTag("nextPosition")); - if (nbtTagCompound.hasKey("turningPoint")) { - vectorTurningPoint = Vector3.createFromNBT(nbtTagCompound.getCompoundTag("turningPoint")); + protected void readEntityFromNBT(final NBTTagCompound tagCompound) { + // energy = tagCompound.getInteger("energy"); + vectorNextPosition = Vector3.createFromNBT(tagCompound.getCompoundTag("nextPosition")); + if (tagCompound.hasKey("turningPoint")) { + vectorTurningPoint = Vector3.createFromNBT(tagCompound.getCompoundTag("turningPoint")); } } @Override - protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) { - // nbtTagCompound.setDouble("energy", energy); - nbtTagCompound.setTag("nextPosition", vectorNextPosition.writeToNBT(new NBTTagCompound())); + protected void writeEntityToNBT(final NBTTagCompound tagCompound) { + // tagCompound.setDouble("energy", energy); + tagCompound.setTag("nextPosition", vectorNextPosition.writeToNBT(new NBTTagCompound())); if (vectorTurningPoint != null) { - nbtTagCompound.setTag("turningPoint", vectorTurningPoint.writeToNBT(new NBTTagCompound())); + tagCompound.setTag("turningPoint", vectorTurningPoint.writeToNBT(new NBTTagCompound())); } } @Override - public void writeToNBT(NBTTagCompound p_70109_1_) { - super.writeToNBT(p_70109_1_); + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); } // prevent saving entity to chunk @Override - public boolean writeMountToNBT(NBTTagCompound p_98035_1_) { + public boolean writeMountToNBT(final NBTTagCompound tagCompound) { return false; } // prevent saving entity to chunk @Override - public boolean writeToNBTOptional(NBTTagCompound p_70039_1_) { + public boolean writeToNBTOptional(final NBTTagCompound tagCompound) { return false; } diff --git a/src/main/java/cr0s/warpdrive/event/AbstractSequencer.java b/src/main/java/cr0s/warpdrive/event/AbstractSequencer.java index 9a00a21d..9428139f 100644 --- a/src/main/java/cr0s/warpdrive/event/AbstractSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/AbstractSequencer.java @@ -43,8 +43,8 @@ public abstract class AbstractSequencer { abstract public boolean onUpdate(); - abstract protected void readFromNBT(NBTTagCompound nbttagcompound); + abstract protected void readFromNBT(final NBTTagCompound tagCompound); - abstract protected void writeToNBT(NBTTagCompound nbttagcompound); + abstract protected void writeToNBT(final NBTTagCompound tagCompound); } diff --git a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java index 17137888..ecc51f32 100644 --- a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java @@ -1524,12 +1524,12 @@ public class JumpSequencer extends AbstractSequencer { } @Override - protected void readFromNBT(NBTTagCompound nbttagcompound) { + protected void readFromNBT(final NBTTagCompound tagCompound) { WarpDrive.logger.error(this + " readFromNBT()"); } @Override - protected void writeToNBT(NBTTagCompound nbttagcompound) { + protected void writeToNBT(final NBTTagCompound tagCompound) { WarpDrive.logger.error(this + " writeToNBT()"); } diff --git a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java index e3f96787..e3011561 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java +++ b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java @@ -23,7 +23,6 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.util.StatCollector; -import net.minecraft.util.Vec3; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; @@ -76,88 +75,88 @@ public class ItemTuningDriver extends Item implements IWarpTool { } } - public static int getVideoChannel(ItemStack itemStack) { + public static int getVideoChannel(final ItemStack itemStack) { if (!(itemStack.getItem() instanceof ItemTuningDriver)) { return -1; } if (!itemStack.hasTagCompound()) { return -1; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt.hasKey(IVideoChannel.VIDEO_CHANNEL_TAG)) { - return nbt.getInteger(IVideoChannel.VIDEO_CHANNEL_TAG); + final NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound.hasKey(IVideoChannel.VIDEO_CHANNEL_TAG)) { + return tagCompound.getInteger(IVideoChannel.VIDEO_CHANNEL_TAG); } return -1; } - public static ItemStack setVideoChannel(ItemStack itemStack, int videoChannel) { + public static ItemStack setVideoChannel(final ItemStack itemStack, final int videoChannel) { if (!(itemStack.getItem() instanceof ItemTuningDriver) || videoChannel == -1) { return itemStack; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt == null) { - nbt = new NBTTagCompound(); + NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); } - nbt.setInteger(IVideoChannel.VIDEO_CHANNEL_TAG, videoChannel); - itemStack.setTagCompound(nbt); + tagCompound.setInteger(IVideoChannel.VIDEO_CHANNEL_TAG, videoChannel); + itemStack.setTagCompound(tagCompound); return itemStack; } - public static int getBeamFrequency(ItemStack itemStack) { + public static int getBeamFrequency(final ItemStack itemStack) { if (!(itemStack.getItem() instanceof ItemTuningDriver)) { return -1; } if (!itemStack.hasTagCompound()) { return -1; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt.hasKey(IBeamFrequency.BEAM_FREQUENCY_TAG)) { - return nbt.getInteger(IBeamFrequency.BEAM_FREQUENCY_TAG); + final NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound.hasKey(IBeamFrequency.BEAM_FREQUENCY_TAG)) { + return tagCompound.getInteger(IBeamFrequency.BEAM_FREQUENCY_TAG); } return -1; } - public static ItemStack setBeamFrequency(ItemStack itemStack, int beamFrequency) { + public static ItemStack setBeamFrequency(final ItemStack itemStack, final int beamFrequency) { if (!(itemStack.getItem() instanceof ItemTuningDriver) || beamFrequency == -1) { return itemStack; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt == null) { - nbt = new NBTTagCompound(); + NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); } - nbt.setInteger(IBeamFrequency.BEAM_FREQUENCY_TAG, beamFrequency); - itemStack.setTagCompound(nbt); + tagCompound.setInteger(IBeamFrequency.BEAM_FREQUENCY_TAG, beamFrequency); + itemStack.setTagCompound(tagCompound); return itemStack; } - public static int getControlChannel(ItemStack itemStack) { + public static int getControlChannel(final ItemStack itemStack) { if (!(itemStack.getItem() instanceof ItemTuningDriver)) { return -1; } if (!itemStack.hasTagCompound()) { return -1; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt.hasKey(IControlChannel.CONTROL_CHANNEL_TAG)) { - return nbt.getInteger(IControlChannel.CONTROL_CHANNEL_TAG); + final NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound.hasKey(IControlChannel.CONTROL_CHANNEL_TAG)) { + return tagCompound.getInteger(IControlChannel.CONTROL_CHANNEL_TAG); } return -1; } - public static ItemStack setControlChannel(ItemStack itemStack, int controlChannel) { + public static ItemStack setControlChannel(final ItemStack itemStack, final int controlChannel) { if (!(itemStack.getItem() instanceof ItemTuningDriver) || controlChannel == -1) { return itemStack; } - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt == null) { - nbt = new NBTTagCompound(); + NBTTagCompound tagCompound = itemStack.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); } - nbt.setInteger(IControlChannel.CONTROL_CHANNEL_TAG, controlChannel); - itemStack.setTagCompound(nbt); + tagCompound.setInteger(IControlChannel.CONTROL_CHANNEL_TAG, controlChannel); + itemStack.setTagCompound(tagCompound); return itemStack; } - public static ItemStack setValue(ItemStack itemStack, final int dye) { + public static ItemStack setValue(final ItemStack itemStack, final int dye) { switch (itemStack.getItemDamage()) { case MODE_VIDEO_CHANNEL : return setVideoChannel(itemStack, dye); case MODE_BEAM_FREQUENCY : return setBeamFrequency(itemStack, dye); @@ -166,22 +165,14 @@ public class ItemTuningDriver extends Item implements IWarpTool { } } - // server side version of EntityLivingBase.rayTrace - private static final double BLOCK_REACH_DISTANCE = 5.0D; // this is a client side hardcoded value, applicable to creative players - private static MovingObjectPosition getInteractingBlock(World world, EntityPlayer entityPlayer, final double distance) { - Vec3 vec3Position = Vec3.createVectorHelper(entityPlayer.posX, entityPlayer.posY + entityPlayer.eyeHeight, entityPlayer.posZ); - Vec3 vec3Look = entityPlayer.getLook(1.0F); - Vec3 vec3Target = vec3Position.addVector(vec3Look.xCoord * distance, vec3Look.yCoord * distance, vec3Look.zCoord * distance); - return world.func_147447_a(vec3Position, vec3Target, false, false, true); - } - @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { - if (world.isRemote || !(itemStack.getItem() instanceof ItemTuningDriver)) { + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer entityPlayer) { + if ( world.isRemote + || !(itemStack.getItem() instanceof ItemTuningDriver) ) { return itemStack; } // check if a block is in players reach - MovingObjectPosition movingObjectPosition = getInteractingBlock(world, entityPlayer, BLOCK_REACH_DISTANCE); + final MovingObjectPosition movingObjectPosition = Commons.getInteractingBlock(world, entityPlayer); if (movingObjectPosition.typeOfHit != MovingObjectType.MISS) { return itemStack; } diff --git a/src/main/java/cr0s/warpdrive/network/MessageClientSync.java b/src/main/java/cr0s/warpdrive/network/MessageClientSync.java index e082d574..1842cdff 100644 --- a/src/main/java/cr0s/warpdrive/network/MessageClientSync.java +++ b/src/main/java/cr0s/warpdrive/network/MessageClientSync.java @@ -21,28 +21,28 @@ import net.minecraftforge.common.util.Constants.NBT; public class MessageClientSync implements IMessage, IMessageHandler { - private NBTTagCompound nbtTagCompound; + private NBTTagCompound tagCompound; public MessageClientSync() { // required on receiving side } public MessageClientSync(final EntityPlayerMP entityPlayerMP, final CelestialObject celestialObject) { - nbtTagCompound = new NBTTagCompound(); - nbtTagCompound.setTag("celestialObjects" , CelestialObjectManager.writeClientSync(entityPlayerMP, celestialObject)); - nbtTagCompound.setTag("items_breathingHelmet", Dictionary.writeItemsToNBT(Dictionary.ITEMS_BREATHING_HELMET)); - nbtTagCompound.setTag("items_flyInSpace" , Dictionary.writeItemsToNBT(Dictionary.ITEMS_FLYINSPACE)); - nbtTagCompound.setTag("items_noFallDamage" , Dictionary.writeItemsToNBT(Dictionary.ITEMS_NOFALLDAMAGE)); + tagCompound = new NBTTagCompound(); + tagCompound.setTag("celestialObjects" , CelestialObjectManager.writeClientSync(entityPlayerMP, celestialObject)); + tagCompound.setTag("items_breathingHelmet", Dictionary.writeItemsToNBT(Dictionary.ITEMS_BREATHING_HELMET)); + tagCompound.setTag("items_flyInSpace" , Dictionary.writeItemsToNBT(Dictionary.ITEMS_FLYINSPACE)); + tagCompound.setTag("items_noFallDamage" , Dictionary.writeItemsToNBT(Dictionary.ITEMS_NOFALLDAMAGE)); } @Override public void fromBytes(ByteBuf buffer) { - nbtTagCompound = ByteBufUtils.readTag(buffer); + tagCompound = ByteBufUtils.readTag(buffer); } @Override public void toBytes(ByteBuf buffer) { - ByteBufUtils.writeTag(buffer, nbtTagCompound); + ByteBufUtils.writeTag(buffer, tagCompound); } @Override @@ -56,17 +56,17 @@ public class MessageClientSync implements IMessage, IMessageHandler