From 47ff9aa7e369ea36cbe9f4ddb4d21429394fcd29 Mon Sep 17 00:00:00 2001 From: Kittychanley Date: Sat, 23 Jan 2016 16:59:25 -0600 Subject: [PATCH] Added 5 tick cooldown timer for oak double chest formation, to fix rare cases of the old double chest crash. Does not affect double chest formation speed for any other wood type. --- .../com/bioxx/tfc/TileEntities/TEChest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Common/com/bioxx/tfc/TileEntities/TEChest.java b/src/Common/com/bioxx/tfc/TileEntities/TEChest.java index 9edb17508..caa8c403c 100644 --- a/src/Common/com/bioxx/tfc/TileEntities/TEChest.java +++ b/src/Common/com/bioxx/tfc/TileEntities/TEChest.java @@ -30,12 +30,15 @@ public class TEChest extends TileEntityChest implements IInventory public int type; /** Server sync counter (once per 20 ticks) */ private int ticksSinceSync; + public int cooldown = 5; + private boolean typeSynced; public boolean isDoubleChest; public TEChest() { } + public TEChest(int i, boolean isDouble) { type = i; @@ -159,6 +162,8 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) type = pkt.func_148857_g().getInteger("woodtype"); // Reset the check flag in case the client has desynced from the server this.adjacentChestChecked = false; + this.typeSynced = true; + this.cooldown = 0; } @Override @@ -179,7 +184,7 @@ public boolean checkType(IBlockAccess access, int x, int y, int z) if (te instanceof TEChest) { TEChest chest = (TEChest) access.getTileEntity(x, y, z); - if(chest.type == this.type) + if (chest.type == this.type && this.cooldown == 0 && chest.cooldown == 0) return true; } return false; @@ -286,6 +291,25 @@ public void updateEntity() //super.updateEntity(); TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord); + + if (type == 0 && !typeSynced) // Cooldown only required for oak chests + { + if (cooldown == 0) + { + this.adjacentChestChecked = false; + this.isDoubleChest = false; + typeSynced = true; + } + else if (cooldown > 0) + { + cooldown--; + } + } + else if (cooldown != 0) + { + cooldown = 0; + } + this.checkForAdjacentChests(); this.ticksSinceSync++;