diff --git a/common/buildcraft/core/BCRegistry.java b/common/buildcraft/core/BCRegistry.java index 7c93c09d..29b69d6c 100644 --- a/common/buildcraft/core/BCRegistry.java +++ b/common/buildcraft/core/BCRegistry.java @@ -50,41 +50,53 @@ public final class BCRegistry { return false; } + private boolean isInvalidRecipeElement(Object o) { + if (o == null) { + return true; + } + if (o instanceof Block && !Utils.isRegistered((Block) o)) { + return true; + } + if (o instanceof Item && !Utils.isRegistered((Item) o)) { + return true; + } + if (o instanceof ItemStack && !Utils.isRegistered((ItemStack) o)) { + return true; + } + + return false; + } + @SuppressWarnings({"rawtypes", "unchecked"}) public void registerTileEntity(Class clas, String ident) { GameRegistry.registerTileEntity(CompatHooks.INSTANCE.getTile(clas), ident); } public void addCraftingRecipe(ItemStack result, Object... recipe) { + if (isInvalidRecipeElement(result)) { + return; + } + for (Object o : recipe) { - if (o == null) { - return; - } - if (o instanceof Block && !Utils.isRegistered((Block) o)) { - return; - } - if (o instanceof Item && !Utils.isRegistered((Item) o)) { - return; - } - if (o instanceof ItemStack && !Utils.isRegistered((ItemStack) o)) { + if (isInvalidRecipeElement(o)) { return; } } + GameRegistry.addRecipe(new ShapedOreRecipe(result, recipe)); } public void addShapelessRecipe(ItemStack result, Object... recipe) { + if (isInvalidRecipeElement(result)) { + return; + } + for (Object o : recipe) { - if (o instanceof Block && Block.getIdFromBlock((Block) o) < 0) { - return; - } - if (o instanceof Item && Item.getIdFromItem((Item) o) < 0) { - return; - } - if (o instanceof ItemStack && ((ItemStack) o).getItem() == null) { + if (isInvalidRecipeElement(o)) { return; } } + GameRegistry.addRecipe(new ShapelessOreRecipe(result, recipe)); } diff --git a/common/buildcraft/robotics/EntityRobot.java b/common/buildcraft/robotics/EntityRobot.java index 07ebb200..3ae8d4c8 100644 --- a/common/buildcraft/robotics/EntityRobot.java +++ b/common/buildcraft/robotics/EntityRobot.java @@ -120,9 +120,6 @@ public class EntityRobot extends EntityRobotBase implements public float itemActiveStage = 0; public long lastUpdateTime = 0; - private SafeTimeTracker expensiveVerificationsTracker = new SafeTimeTracker(10); - private boolean isMovingOutOfStuck; - private DockingStation currentDockingStation; private List wearables = new ArrayList(); @@ -360,44 +357,6 @@ public class EntityRobot extends EntityRobotBase implements getRegistry().killRobot(this); } - // The commented out part is the part which unstucks robots. - // It has been known to cause a lot of issues in 7.1.11. - // If you want to try and fix it, go ahead. - // Right now it will simply stop them from moving. - - /* - if (expensiveVerificationsTracker.markTimeIfDelay(worldObj)) { - int collisions = 0; - - int bx = (int) Math.floor(posX); - int by = (int) Math.floor(posY); - int bz = (int) Math.floor(posZ); - - if (by >= 0 && by < worldObj.getActualHeight() && !BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz)) { - List clist = new ArrayList(); - - Block block = worldObj.getBlock(bx, by, bz); - block.addCollisionBoxesToList(worldObj, bx, by, bz, getBoundingBox(), clist, this); - collisions = clist.size(); - } - - if (collisions > 0) { - isMovingOutOfStuck = true; - motionX = 0.0F; - motionY = 0.05F; - motionZ = 0.0F; - } else if (isMovingOutOfStuck) { - isMovingOutOfStuck = false; - - board.abortDelegateAI(); - - motionY = 0.0F; - - } - } - - if (!isMovingOutOfStuck) { - */ if (linkedDockingStation == null || linkedDockingStation.isInitialized()) { this.worldObj.theProfiler.startSection("bcRobotAI"); mainAI.cycle(); diff --git a/common/buildcraft/transport/FacadePluggable.java b/common/buildcraft/transport/FacadePluggable.java index 00247f23..136682d4 100644 --- a/common/buildcraft/transport/FacadePluggable.java +++ b/common/buildcraft/transport/FacadePluggable.java @@ -173,8 +173,8 @@ public class FacadePluggable extends PipePluggable implements IFacadePluggable { int flags = data.readUnsignedByte(); meta = flags & 0x0F; - transparent = (flags & 0x80) > 0; - renderAsHollow = (flags & 0x40) > 0; + transparent = (flags & 0x80) != 0; + renderAsHollow = (flags & 0x40) != 0; } private void prepareStates() { diff --git a/common/buildcraft/transport/PipePluggableState.java b/common/buildcraft/transport/PipePluggableState.java index 969e1d90..1b3c52cd 100644 --- a/common/buildcraft/transport/PipePluggableState.java +++ b/common/buildcraft/transport/PipePluggableState.java @@ -23,15 +23,18 @@ public class PipePluggableState implements ISerializable { public void setPluggables(PipePluggable[] pluggables) { this.pluggables = pluggables; - this.pluggableMatrix.clean(); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - this.pluggableMatrix.setConnected(dir, pluggables[dir.ordinal()] != null); - } } @Override public void writeData(ByteBuf data) { + this.pluggableMatrix.clean(); + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + this.pluggableMatrix.setConnected(dir, pluggables[dir.ordinal()] != null); + } + this.pluggableMatrix.writeData(data); + for (PipePluggable p : pluggables) { if (p != null) { data.writeShort(PipeManager.pipePluggables.indexOf(p.getClass())); @@ -43,6 +46,7 @@ public class PipePluggableState implements ISerializable { @Override public void readData(ByteBuf data) { this.pluggableMatrix.readData(data); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if (this.pluggableMatrix.isConnected(dir)) { try { diff --git a/common/buildcraft/transport/pluggable/LensPluggable.java b/common/buildcraft/transport/pluggable/LensPluggable.java index ea04c8c1..f44786b9 100644 --- a/common/buildcraft/transport/pluggable/LensPluggable.java +++ b/common/buildcraft/transport/pluggable/LensPluggable.java @@ -169,7 +169,7 @@ public class LensPluggable extends PipePluggable { @Override public void readData(ByteBuf data) { int flags = data.readUnsignedByte(); - color = (flags & 31) - 1; + color = (flags & 0x1F) - 1; isFilter = (flags & 0x20) > 0; } diff --git a/common/buildcraft/transport/utils/BitSetCodec.java b/common/buildcraft/transport/utils/BitSetCodec.java index c4eccb7d..e7021ed1 100644 --- a/common/buildcraft/transport/utils/BitSetCodec.java +++ b/common/buildcraft/transport/utils/BitSetCodec.java @@ -14,19 +14,20 @@ public class BitSetCodec { public byte encode(BitSet set) { byte result = 0; for (byte i = 0; i < 8; i++) { - result <<= 1; - result |= set.get(i) ? 1 : 0; + result |= set.get(i) ? (1 << i) : 0; } return result; } public void decode(byte data, BitSet target) { byte localData = data; + int t = 1; target.clear(); + for (byte i = 0; i < 8; i++) { - target.set(7 - i, (localData & 1) != 0); - localData >>= 1; + target.set(i, (localData & t) != 0); + t <<= 1; } } } diff --git a/common/buildcraft/transport/utils/TextureMatrix.java b/common/buildcraft/transport/utils/TextureMatrix.java index e7fc594e..56ae9d7f 100644 --- a/common/buildcraft/transport/utils/TextureMatrix.java +++ b/common/buildcraft/transport/utils/TextureMatrix.java @@ -37,14 +37,14 @@ public class TextureMatrix { } public void writeData(ByteBuf data) { - for (int iconIndexe : iconIndexes) { - data.writeByte(iconIndexe); + for (int iconIndex : iconIndexes) { + data.writeByte(iconIndex); } } public void readData(ByteBuf data) { for (int i = 0; i < iconIndexes.length; i++) { - int icon = data.readByte(); + int icon = data.readUnsignedByte(); if (iconIndexes[i] != icon) { iconIndexes[i] = icon; dirty = true; diff --git a/common/buildcraft/transport/utils/WireMatrix.java b/common/buildcraft/transport/utils/WireMatrix.java index 51da4f95..ba3fce42 100644 --- a/common/buildcraft/transport/utils/WireMatrix.java +++ b/common/buildcraft/transport/utils/WireMatrix.java @@ -17,8 +17,6 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.transport.PipeWire; public class WireMatrix { - - //private final boolean[] _hasWire = new boolean[IPipe.WireColor.values().length]; private final BitSet hasWire = new BitSet(PipeWire.values().length); private final BitSetCodec bitSetCodec = new BitSetCodec(); @@ -94,7 +92,7 @@ public class WireMatrix { bitSetCodec.decode(data.readByte(), hasWire); for (int i = 0; i < PipeWire.values().length; i++) { wires[i].readData(data); - wireIconIndex[i] = data.readByte(); + wireIconIndex[i] = data.readUnsignedByte(); } } }