From 679c1f88dca7f877514bc080cceb7d9b5c9c8079 Mon Sep 17 00:00:00 2001 From: Robert S Date: Sat, 26 Apr 2014 11:45:14 -0400 Subject: [PATCH] Changed crate sample stack to only build server side --- .../archaic/crate/TileCrate.java | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/archaic/src/main/scala/resonantinduction/archaic/crate/TileCrate.java b/archaic/src/main/scala/resonantinduction/archaic/crate/TileCrate.java index e540ce13c..9859a1beb 100644 --- a/archaic/src/main/scala/resonantinduction/archaic/crate/TileCrate.java +++ b/archaic/src/main/scala/resonantinduction/archaic/crate/TileCrate.java @@ -103,43 +103,46 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver, public void buildSampleStack(boolean buildInv) { - ItemStack newSampleStack = null; - boolean rebuildBase = false; - - /* Creates the sample stack that is used as a collective itemstack */ - for (int slot = 0; slot < this.getSizeInventory(); slot++) + if (worldObj == null || !worldObj.isRemote) { - ItemStack slotStack = this.getInventory().getContainedItems()[slot]; - if (slotStack != null && Item.itemsList[slotStack.itemID] != null && slotStack.stackSize > 0) - { - if (newSampleStack == null) - { - newSampleStack = slotStack.copy(); - } - else - { - newSampleStack.stackSize += slotStack.stackSize; - } + ItemStack newSampleStack = null; + boolean rebuildBase = false; - if (slotStack.stackSize > slotStack.getMaxStackSize()) + /* Creates the sample stack that is used as a collective itemstack */ + for (int slot = 0; slot < this.getSizeInventory(); slot++) + { + ItemStack slotStack = this.getInventory().getContainedItems()[slot]; + if (slotStack != null && Item.itemsList[slotStack.itemID] != null && slotStack.stackSize > 0) { - rebuildBase = true; + if (newSampleStack == null) + { + newSampleStack = slotStack.copy(); + } + else + { + newSampleStack.stackSize += slotStack.stackSize; + } + + if (slotStack.stackSize > slotStack.getMaxStackSize()) + { + rebuildBase = true; + } } } - } - if (newSampleStack == null || newSampleStack.itemID == 0 || newSampleStack.stackSize <= 0) - { - this.sampleStack = this.getFilter() != null ? this.getFilter().copy() : null; - } - else - { - this.sampleStack = newSampleStack.copy(); - } + if (newSampleStack == null || newSampleStack.itemID == 0 || newSampleStack.stackSize <= 0) + { + this.sampleStack = this.getFilter() != null ? this.getFilter().copy() : null; + } + else + { + this.sampleStack = newSampleStack.copy(); + } - /* Rebuild inventory if the inventory is not valid */ - if (buildInv && this.sampleStack != null && (rebuildBase || this.getInventory().getContainedItems().length > this.getSizeInventory())) - { - this.getInventory().buildInventory(this.sampleStack); + /* Rebuild inventory if the inventory is not valid */ + if (buildInv && this.sampleStack != null && (rebuildBase || this.getInventory().getContainedItems().length > this.getSizeInventory())) + { + this.getInventory().buildInventory(this.sampleStack); + } } }