OpenComputers II

OpenComputers II

27.1k Downloads

Converting ItemStacks to NBT then JSON causes some data loss in the case of some modded inventories.

AmandaCameron opened this issue ยท 1 comments

commented

StorageDrawers uses some sliglty-odd behaviour for the ItemStacks returned from it's inventory, namely, they may be larger than 64.

For instance, our storage drawers currently have 286 copper ingots, which SD is reporting back to OC2, then when OC2 turns that into NBT, it's getting wrapped around as a uint8 with a value of 30.

Another case is that we have 191 paper in another drawer, which OC2 is reporting as -65 which I suspect is the uint8 value of 191 being converted to a signed int8 in the NBT, but I'm not sure on the math of that.

One solution may be to manually change the Count field into a long which should work for everything. I believe that the ItemStack API doesn't return an byte for size, which may be the discrepency here?

commented

Hrm, yeah, ItemStack serialization crippling the count down to byte is annoying in that case. Would mean custom serialization for ItemStack though (right now it's just ItemStack.serializeNBT()), which is a bit sad. Will think on this some more.