Skip to content

Commit

Permalink
Added 5 tick cooldown timer for oak double chest formation, to fix ra…
Browse files Browse the repository at this point in the history
…re cases of the old double chest crash. Does not affect double chest formation speed for any other wood type.
  • Loading branch information
Kittychanley committed Jan 23, 2016
1 parent 01754a3 commit 47ff9aa
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Common/com/bioxx/tfc/TileEntities/TEChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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++;

Expand Down

0 comments on commit 47ff9aa

Please sign in to comment.