Changed crate sample stack to only build server side

This commit is contained in:
Robert S 2014-04-26 11:45:14 -04:00
parent 6d68efe697
commit 679c1f88dc

View file

@ -103,43 +103,46 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
public void buildSampleStack(boolean buildInv) public void buildSampleStack(boolean buildInv)
{ {
ItemStack newSampleStack = null; if (worldObj == null || !worldObj.isRemote)
boolean rebuildBase = false;
/* 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]; ItemStack newSampleStack = null;
if (slotStack != null && Item.itemsList[slotStack.itemID] != null && slotStack.stackSize > 0) boolean rebuildBase = false;
{
if (newSampleStack == null)
{
newSampleStack = slotStack.copy();
}
else
{
newSampleStack.stackSize += slotStack.stackSize;
}
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)
if (newSampleStack == null || newSampleStack.itemID == 0 || newSampleStack.stackSize <= 0) {
{ this.sampleStack = this.getFilter() != null ? this.getFilter().copy() : null;
this.sampleStack = this.getFilter() != null ? this.getFilter().copy() : null; }
} else
else {
{ this.sampleStack = newSampleStack.copy();
this.sampleStack = newSampleStack.copy(); }
}
/* Rebuild inventory if the inventory is not valid */ /* Rebuild inventory if the inventory is not valid */
if (buildInv && this.sampleStack != null && (rebuildBase || this.getInventory().getContainedItems().length > this.getSizeInventory())) if (buildInv && this.sampleStack != null && (rebuildBase || this.getInventory().getContainedItems().length > this.getSizeInventory()))
{ {
this.getInventory().buildInventory(this.sampleStack); this.getInventory().buildInventory(this.sampleStack);
}
} }
} }