Code cleanup
This commit is contained in:
parent
dff83c44fe
commit
7f5dad1680
49 changed files with 540 additions and 527 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String> keys = tag.func_150296_c();
|
||||
final Set<String> 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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, Double> entry : tagVariables.getTagList("x", 0)) {
|
||||
tagVariables.setDouble(entry.getKey(), entry.getValue());
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -43,8 +43,8 @@ public class ForceFieldRegistry {
|
|||
Set<TileEntity> 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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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()");
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -21,28 +21,28 @@ import net.minecraftforge.common.util.Constants.NBT;
|
|||
|
||||
public class MessageClientSync implements IMessage, IMessageHandler<MessageClientSync, IMessage> {
|
||||
|
||||
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<MessageClien
|
|||
|
||||
if (WarpDriveConfig.LOGGING_CLIENT_SYNCHRONIZATION) {
|
||||
WarpDrive.logger.info(String.format("Received client synchronization packet: %s",
|
||||
messageClientSync.nbtTagCompound));
|
||||
messageClientSync.tagCompound));
|
||||
}
|
||||
|
||||
try {
|
||||
CelestialObjectManager.readClientSync(messageClientSync.nbtTagCompound.getTagList("celestialObjects", NBT.TAG_COMPOUND));
|
||||
Dictionary.ITEMS_BREATHING_HELMET = Dictionary.readItemsFromNBT(messageClientSync.nbtTagCompound.getTagList("items_breathingHelmet", NBT.TAG_STRING));
|
||||
Dictionary.ITEMS_FLYINSPACE = Dictionary.readItemsFromNBT(messageClientSync.nbtTagCompound.getTagList("items_flyInSpace" , NBT.TAG_STRING));
|
||||
Dictionary.ITEMS_NOFALLDAMAGE = Dictionary.readItemsFromNBT(messageClientSync.nbtTagCompound.getTagList("items_noFallDamage" , NBT.TAG_STRING));
|
||||
CelestialObjectManager.readClientSync(messageClientSync.tagCompound.getTagList("celestialObjects", NBT.TAG_COMPOUND));
|
||||
Dictionary.ITEMS_BREATHING_HELMET = Dictionary.readItemsFromNBT(messageClientSync.tagCompound.getTagList("items_breathingHelmet", NBT.TAG_STRING));
|
||||
Dictionary.ITEMS_FLYINSPACE = Dictionary.readItemsFromNBT(messageClientSync.tagCompound.getTagList("items_flyInSpace" , NBT.TAG_STRING));
|
||||
Dictionary.ITEMS_NOFALLDAMAGE = Dictionary.readItemsFromNBT(messageClientSync.tagCompound.getTagList("items_noFallDamage" , NBT.TAG_STRING));
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
WarpDrive.logger.error(String.format("Fails to parse client synchronization packet %s", messageClientSync.nbtTagCompound));
|
||||
WarpDrive.logger.error(String.format("Fails to parse client synchronization packet %s", messageClientSync.tagCompound));
|
||||
}
|
||||
|
||||
return new MessageClientValidation();
|
||||
|
|
|
@ -231,7 +231,7 @@ public final class EntitySphereGen extends Entity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound tag) {
|
||||
protected void readEntityFromNBT(final NBTTagCompound tagCompound) {
|
||||
// FIXME not implemented
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public final class EntitySphereGen extends Entity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound tag) {
|
||||
protected void writeEntityToNBT(final NBTTagCompound tagCompound) {
|
||||
// FIXME not implemented
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue