diff --git a/common/buildcraft/builders/TileConstructionMarker.java b/common/buildcraft/builders/TileConstructionMarker.java index 651b958a..ffa5efa0 100755 --- a/common/buildcraft/builders/TileConstructionMarker.java +++ b/common/buildcraft/builders/TileConstructionMarker.java @@ -118,7 +118,7 @@ public class TileConstructionMarker extends TileBuildCraft implements IBuildingI public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("direction", direction.ordinal()); + nbt.setByte("direction", (byte) direction.ordinal()); if (itemBlueprint != null) { NBTTagCompound bptNBT = new NBTTagCompound(); @@ -141,7 +141,7 @@ public class TileConstructionMarker extends TileBuildCraft implements IBuildingI public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - direction = ForgeDirection.values()[nbt.getInteger("direction")]; + direction = ForgeDirection.getOrientation(nbt.getByte("direction")); if (nbt.hasKey("itemBlueprint")) { itemBlueprint = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("itemBlueprint")); diff --git a/common/buildcraft/core/triggers/StatementParameterDirection.java b/common/buildcraft/core/triggers/StatementParameterDirection.java index 017189d9..552593ee 100644 --- a/common/buildcraft/core/triggers/StatementParameterDirection.java +++ b/common/buildcraft/core/triggers/StatementParameterDirection.java @@ -8,8 +8,6 @@ */ package buildcraft.core.triggers; - -//import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; @@ -22,29 +20,13 @@ import buildcraft.api.transport.IPipeTile; public class StatementParameterDirection implements IActionParameter, ITriggerParameter { - // static IIcon[] icons = new IIcon[ForgeDirection.values().length]; - @NetworkData public ForgeDirection direction = ForgeDirection.UNKNOWN; public StatementParameterDirection() { + } - /* - @Override - public void registerIcons(IIconRegister register) { - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - icons[d.ordinal()] = register.registerIcon("buildcraft:triggers/trigger_dir_" + d.name().toLowerCase()); - } - } - - @Override - public IIcon getIconToDraw() { - return icons[direction.ordinal()]; - } - - */ - @Override public ItemStack getItemStackToDraw() { return null; @@ -53,38 +35,38 @@ public class StatementParameterDirection implements IActionParameter, ITriggerPa @Override public IIcon getIconToDraw() { if (direction == ForgeDirection.UNKNOWN) { - return null; + return null; } else { - return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_Direction_Down + direction.ordinal()); + return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_Direction_Down + direction.ordinal()); } } @Override public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack) { do { - direction = ForgeDirection.getOrientation((direction.ordinal() + 1) % ForgeDirection.values().length); - } while (direction != ForgeDirection.UNKNOWN && !pipe.isPipeConnected(direction)); + direction = ForgeDirection.getOrientation((direction.ordinal() + 1) % 6); + } while (!pipe.isPipeConnected(direction)); } @Override public void writeToNBT(NBTTagCompound nbt) { - nbt.setInteger("direction", direction.ordinal()); + nbt.setByte("direction", (byte) direction.ordinal()); } @Override public void readFromNBT(NBTTagCompound nbt) { if (nbt.hasKey("direction")) { - direction = ForgeDirection.values()[nbt.getInteger("direction")]; + direction = ForgeDirection.getOrientation(nbt.getByte("direction")); } else { - direction = ForgeDirection.UNKNOWN; + direction = ForgeDirection.UNKNOWN; } } @Override public boolean equals(Object object) { if (object instanceof StatementParameterDirection) { - StatementParameterDirection param = (StatementParameterDirection) object; - return param.direction == this.direction; + StatementParameterDirection param = (StatementParameterDirection) object; + return param.direction == this.direction; } return false; } diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 5061cc46..f3ca0eca 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -418,7 +418,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); - orientation = ForgeDirection.getOrientation(data.getInteger("orientation")); + orientation = ForgeDirection.getOrientation(data.getByte("orientation")); progress = data.getFloat("progress"); energy = data.getInteger("energy"); heat = data.getFloat("heat"); @@ -428,7 +428,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); - data.setInteger("orientation", orientation.ordinal()); + data.setByte("orientation", (byte) orientation.ordinal()); data.setFloat("progress", progress); data.setInteger("energy", energy); data.setFloat("heat", heat); diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index 04cd491b..10882deb 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -53,7 +53,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve public SingleUseTank result = new SingleUseTank("result", LIQUID_PER_SLOT, this); public TankManager tankManager = new TankManager(tanks[0], tanks[1], result); public float animationSpeed = 1; - private int animationStage = 0; + private short animationStage = 0; private SafeTimeTracker time = new SafeTimeTracker(); private SafeTimeTracker updateNetworkTime = new SafeTimeTracker(BuildCraftCore.updateFactor); @@ -198,7 +198,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve tankManager.readFromNBT(data); - animationStage = data.getInteger("animationStage"); + animationStage = data.getShort("animationStage"); animationSpeed = data.getFloat("animationSpeed"); updateRecipe(); @@ -210,7 +210,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve tankManager.writeToNBT(data); - data.setInteger("animationStage", animationStage); + data.setShort("animationStage", animationStage); data.setFloat("animationSpeed", animationSpeed); } diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java index ba20ccff..df21b79b 100644 --- a/common/buildcraft/silicon/BlockLaser.java +++ b/common/buildcraft/silicon/BlockLaser.java @@ -121,7 +121,7 @@ public class BlockLaser extends BlockBuildCraft implements ICustomHighlight { @Override public IIcon getIcon(int i, int j) { - if (i == ForgeDirection.values()[j].getOpposite().ordinal()) { + if (i == (j ^ 1)) { return textureBottom; } else if (i == j) { return textureTop; diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 5e8af1ad..8f68849d 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -678,17 +678,22 @@ public class BlockGenericPipe extends BlockBuildCraft { if (isValid(pipe)) { pipe.container.scheduleNeighborChange(); - + pipe.container.redstoneInput = 0; + for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { ForgeDirection d = ForgeDirection.getOrientation(i); pipe.container.redstoneInputSide[i] = Math.max( world.isBlockProvidingPowerTo(x + d.offsetX, y + d.offsetY, z + d.offsetZ, i), world.getIndirectPowerLevelTo(x + d.offsetX, y + d.offsetY, z + d.offsetZ, i) ); + + if (pipe.container.redstoneInput < pipe.container.redstoneInputSide[i]) { + pipe.container.redstoneInput = pipe.container.redstoneInputSide[i]; + } } } } - + @Override public int onBlockPlaced(World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) { super.onBlockPlaced(world, x, y, z, side, par6, par7, par8, meta); diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 71139e7a..e1cccb7f 100755 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -62,8 +62,8 @@ public class ItemFacade extends ItemBuildCraft implements IFacadeItem { public FacadeState(NBTTagCompound nbt) { this.block = nbt.hasKey("block") ? (Block) Block.blockRegistry.getObject(nbt.getString("block")) : null; - this.metadata = nbt.getInteger("metadata"); - this.wire = nbt.hasKey("wire") ? PipeWire.fromOrdinal(nbt.getInteger("wire")) : null; + this.metadata = nbt.getByte("metadata"); + this.wire = nbt.hasKey("wire") ? PipeWire.fromOrdinal(nbt.getByte("wire")) : null; this.transparent = nbt.hasKey("transparent") && nbt.getBoolean("transparent"); } @@ -90,9 +90,9 @@ public class ItemFacade extends ItemBuildCraft implements IFacadeItem { if (block != null) { nbt.setString("block", Block.blockRegistry.getNameForObject(block)); } - nbt.setInteger("metadata", metadata); + nbt.setByte("metadata", (byte) metadata); if (wire != null) { - nbt.setInteger("wire", wire.ordinal()); + nbt.setByte("wire", (byte) wire.ordinal()); } nbt.setBoolean("transparent", transparent); } @@ -599,7 +599,7 @@ public class ItemFacade extends ItemBuildCraft implements IFacadeItem { ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0); NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("type", (basic ? FacadeType.Basic : FacadeType.Phased).ordinal()); + nbt.setByte("type", (byte) (basic ? FacadeType.Basic : FacadeType.Phased).ordinal()); nbt.setTag("states", FacadeState.writeArray(states)); stack.setTagCompound(nbt); diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 02660dba..2f563958 100755 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -71,6 +71,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public boolean[] pipeConnectionsBuffer = new boolean[6]; public Pipe pipe; + public int redstoneInput; public int[] redstoneInputSide = new int[ForgeDirection.VALID_DIRECTIONS.length]; protected boolean deletePipe = false; @@ -262,7 +263,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { final String key = "redstoneInputSide[" + i + "]"; - nbt.setInteger(key, redstoneInputSide[i]); + nbt.setByte(key, (byte) redstoneInputSide[i]); } if (pipe != null) { @@ -279,11 +280,21 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); + redstoneInput = 0; + for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { final String key = "redstoneInputSide[" + i + "]"; - redstoneInputSide[i] = nbt.hasKey(key) ? nbt.getInteger(key) : 0; + if (nbt.hasKey(key)) { + redstoneInputSide[i] = nbt.getByte(key); + + if (redstoneInputSide[i] > redstoneInput) { + redstoneInput = redstoneInputSide[i]; + } + } else { + redstoneInputSide[i] = 0; + } } - + coreState.pipeId = nbt.getInteger("pipeId"); pipe = BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)); bindPipe(); diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java index c87e6de4..7cd12e95 100644 --- a/common/buildcraft/transport/TravelingItem.java +++ b/common/buildcraft/transport/TravelingItem.java @@ -172,8 +172,8 @@ public class TravelingItem { setItemStack(ItemStack.loadItemStackFromNBT(data.getCompoundTag("Item"))); toCenter = data.getBoolean("toCenter"); - input = ForgeDirection.getOrientation(data.getInteger("input")); - output = ForgeDirection.getOrientation(data.getInteger("output")); + input = ForgeDirection.getOrientation(data.getByte("input")); + output = ForgeDirection.getOrientation(data.getByte("output")); byte c = data.getByte("color"); if (c != -1) { @@ -195,8 +195,8 @@ public class TravelingItem { data.setTag("Item", itemStackTag); data.setBoolean("toCenter", toCenter); - data.setInteger("input", input.ordinal()); - data.setInteger("output", output.ordinal()); + data.setByte("input", (byte) input.ordinal()); + data.setByte("output", (byte) output.ordinal()); data.setByte("color", color != null ? (byte) color.ordinal() : -1);