Issues with Cardboard Box and CompactStorage Chest
witchica opened this issue ยท 3 comments
I am the creator of CompactStorage and I have been receiving alot of issues stating that when the chest is picked up with the Mekanism Cardboard Box that when replaced the chest is empty and the size is wrong. I have looked at the code for the chest and the cardboard box and cannot see any issues as to why this could be happening and wondered if you would mind helping me out to fix the issue, because at this point in time I'm not sure whether it's on Mekanisms side or CompactStorages side.
From what I can tell when you click on the chest with the box it reads the NBT and stores it and then when it's placed again the NBT is returned to the tile entity. Which on my end is here but looking at the code I can't see anything wrong on your or my end. From my debugging it seems that it doesn't have a NBT Tab at all, as seen here. That is the error that occurs.
I hope someone can shed light on what is happening here.
Thanks ๐
Pretty sure I know what's happening.
BlockCardboardBox replaces itself with the stored block/TE here.
Note it first does a world.setBlock to restore the block/TE, then readFromNBT on the TE to restore the TE state, then block.onBlockPlacedBy with a NBT-less itemstack.
So the TE state would already be correct after the call to your tiles readFromNBT, but then your onBlockPlacedBy clears size/items/color because it's called with a NBT-less itemstack.
Not sure what the proper way to handle that is, I guess a possible approach would be to check if you're actually dealing with a freshly created chest TE in onBlockPlacedBy and only reset to defaults if chest.invX/invY are 0?
@ArtForz I will look into that thanks for your help
Whoops, linked the wrong file (that's where the existing block is saved and replaced with the cardboard box). The replace-cardboardbox-with-stored-block code I intended to link to is here.