Minor change to crates in attempt to fix a waila issue
This commit is contained in:
parent
e73d80b982
commit
6d68efe697
2 changed files with 22 additions and 11 deletions
|
@ -33,7 +33,6 @@ public class InventoryCrate extends ExternalInventory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.onInventoryChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,27 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
|
||||||
private ItemStack filterStack;
|
private ItemStack filterStack;
|
||||||
|
|
||||||
private long updateTick = 1;
|
private long updateTick = 1;
|
||||||
|
private boolean doUpdate = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if (!worldObj.isRemote && ticks % updateTick == 0)
|
if (!worldObj.isRemote)
|
||||||
|
{
|
||||||
|
this.writeToNBT(new NBTTagCompound());
|
||||||
|
if (ticks % updateTick == 0)
|
||||||
{
|
{
|
||||||
//Send desc packet, done already in onInventoryChanged()
|
|
||||||
onInventoryChanged();
|
|
||||||
updateTick = 5 + worldObj.rand.nextInt(50);
|
updateTick = 5 + worldObj.rand.nextInt(50);
|
||||||
|
doUpdate = true;
|
||||||
}
|
}
|
||||||
|
if (doUpdate)
|
||||||
|
{
|
||||||
|
doUpdate = false;
|
||||||
|
PacketHandler.sendPacketToClients(getDescriptionPacket(), this.worldObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the slot count for the crate meta */
|
/** Gets the slot count for the crate meta */
|
||||||
|
@ -87,6 +97,11 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
|
||||||
/** Builds the sample stack using the inventory as a point of reference. Assumes all items match
|
/** Builds the sample stack using the inventory as a point of reference. Assumes all items match
|
||||||
* each other, and only takes into account stack sizes */
|
* each other, and only takes into account stack sizes */
|
||||||
public void buildSampleStack()
|
public void buildSampleStack()
|
||||||
|
{
|
||||||
|
buildSampleStack(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildSampleStack(boolean buildInv)
|
||||||
{
|
{
|
||||||
ItemStack newSampleStack = null;
|
ItemStack newSampleStack = null;
|
||||||
boolean rebuildBase = false;
|
boolean rebuildBase = false;
|
||||||
|
@ -122,7 +137,7 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rebuild inventory if the inventory is not valid */
|
/* Rebuild inventory if the inventory is not valid */
|
||||||
if (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);
|
||||||
}
|
}
|
||||||
|
@ -202,11 +217,8 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
|
||||||
public void onInventoryChanged()
|
public void onInventoryChanged()
|
||||||
{
|
{
|
||||||
super.onInventoryChanged();
|
super.onInventoryChanged();
|
||||||
|
|
||||||
if (worldObj != null && !worldObj.isRemote)
|
if (worldObj != null && !worldObj.isRemote)
|
||||||
{
|
doUpdate = true;
|
||||||
PacketHandler.sendPacketToClients(getDescriptionPacket(), this.worldObj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -304,7 +316,7 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
/* Re-Build sample stack for saving */
|
/* Re-Build sample stack for saving */
|
||||||
this.buildSampleStack();
|
this.buildSampleStack(false);
|
||||||
ItemStack stack = this.getSampleStack();
|
ItemStack stack = this.getSampleStack();
|
||||||
/* Save sample stack */
|
/* Save sample stack */
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
|
|
Loading…
Reference in a new issue