Edit + Explanation: Turns out you have to create and manage a packet with data to send to the client yourself.
As I was creating a chest that had individual stack sizes saved and loaded for use elsewhere, I wrote an NBTTagCompound that sent the information of the array:
Forge 4.2.5
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
for ( int i = 0; i < inv.length; i++ ){
tag.setInteger("StackSize"+i, stackSize[i]);
}
return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag);
}
Forge 4.1.1:
@Override
public Packet getAuxillaryInfoPacket()
{
NBTTagCompound tag = new NBTTagCompound();
for ( int i = 0; i < inv.length; i++ ){
tag.setInteger("StackSize"+i, stackSize[i]);
}
return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag);
}
I also had to read that data and load it into the array:
@Override
public void onDataPacket(NetworkManager net, Packet132TileEntityData pkt)
{
NBTTagCompound tag = pkt.customParam1;
for ( int i = 0; i < inv.length; i++ ){
stackSize[i] = tag.getInteger("StackSize"+i);
}
}
Using these functions, I was able to get the CLIENT chest reading the right value. I chose to send an Integer because this chest handles large values of items, not single stacks.
-- Original Post --
I've made a custom chest that stores a stackSize in a separate NBT tag from the normal itemStack tags.
I save and load the integer value successfully, but the CLIENT does not recognize this.
The readFromNBT event is thrown once, while during init the tileEntity is created multiple times, at least once for CLIENT and once for SERVER.
Apparently, CLIENT chests do not perform a readFromNBT function, and thus I can not load the value on the CLIENT chest.
Right now, I can take the item out, but the CLIENT returns a stack size of 0 while the SERVER returns a proper stack size.
Is it possible to make a CLIENT tileEntity call readFromNBT? If not, is there a recommended way to let my CLIENT tileEntity know what stackSize it should be using?
Below is the output from which I inferred my current situation (all I did was load the world, open the gui and click slot 1):
InfiniChest Init (Server Side?)
InfiniChest: Read from NBT (Size 32) [slot 1]
InfiniChest Init (Client Side?)
Taking out a 0 stack. (Client?)
New Stored Amount: 0.
Taking out a 32 stack. (Server?)
New Stored Amount: 0.