Sophisticated Backpacks

Sophisticated Backpacks

89M Downloads

Backpack inventory wipes after interacting with some Create contraptions

Stormpuls3 opened this issue ยท 7 comments

commented

Describe the bug
Title on the tin. Backpack inventory seems to be getting wiped after being used as a replacement for a chest on some Create contraptions. At first I suspected it was a weird UUID change, but after testing I determined the UUID seemed to remain the same.

Does not crash the game.

Using Sophisticated Backpacks 1.18.2-3.15.1.505.
The only other mod causing conflicts, best I can tell, is Create, ver. 0.4d.

To Reproduce
Steps to reproduce the behavior:
For my tests I exclusively used a hand-crank powered drill.

  1. Open backpack.
  2. Place any items as sacrifice.
  3. Close backpack and attach to stickied chassis.
  4. In this case, use handcranks to extend drill; even a single space will do.
  5. Remove backpack from chassis and place anywhere.
  6. Check backpack inventory, only to find an empty slate.

Expected behavior
I figured the backpack would function like it does everywhere else, retaining its inventory and even filling up from the effects of the drill.

It should be noted that the inventory was the only thing being wiped clean; the UUID seemed to remain the same and any backpack upgrades were untouched, including the crafting upgrade's grid (and presumably any other additional grids from other upgrades.) The results were also the same regardless of backpack tier or whether a backpack had upgrades or not.

Screenshots
N/A

Versions
Forge 39.0.64
Sophisticated Backpacks 1.18.2-3.15.1.505
Create 0.4d

commented

I am not that much familiar with Create, could you share your setup as a screenshot or something so that I can easier recreate this?

commented

never mind was able to recreate, and it appears it's enough to just move the backpack and then when you take it away and replace it items are gone

commented

and even easier - after moving just pick it up then move it to a different slot in your inventory and try to open it from there and items are gone. That looks like some incorrect interaction in how items are saved, it's probably trying to access inventory of backpack at the previous position and is unsuccessful and thus returns no items in inventory and that gets saved. Will have to do a bit more debugging but there's clearly an issue somewhere in there.

commented

Took a look at this in debug and there's apparently code in Create that deletes all inventory of an item handler after move. There's probably another code somewhere in create that's supposed to fill it in again, but I am afraid that won't work with sophisticated backpacks. Will likely take one more look at this, but it's pretty likely someone from create mod will need to take a look at this instead.

commented

I actually saw someone in the Create Discord having almost identical issues with a different mod this morning and began to suspect as much. I'll try to put a report in with them and hope they can resolve it.

commented

It appears that the Create authors have no interest in a "contraption storage API", so this is the way to go if you want to add support from your side. If you don't, I guess I'll have to extract this out into a separate mod.

commented

Have you found anything? I didn't see this issue being reported on Create's repo.

If I'm understanding the code correctly, Create wipes the contraption inventory after forming blocks, because at that point any attached inventories should have been cloned (serialized and deserialized) and placed into the world again. But since your backpacks don't actually contain the items and are just linking to the real storage which persists (de)serialization that clears the new backpack too...

Now I'm not sure whether this whole "clearing the contraption inventory" is even necessary as the contraption should stop existing the moment it returns to being blocks in the world. But I probably won't get around to investigate further until next week.