Nested backpacks do not update contents
Hazerd opened this issue ยท 5 comments
Issue Description:
While a backpack is placed inside another, and changes to the internal backpack's inventory is not saved when it is closed.
What happens:
Items added to the nested backpack are lost. Items removed from the nested backpack are duplicated.
What you expected to happen:
The nested backpack should retain whatever inventory it had when closed.
Steps to reproduce (important):
- Create two new backpacks (thus named "Nesting" and "Nested").
- Attach a Nesting Upgrade or Advanced Nesting Upgrade to the "Nesting" backpack.
- Insert the "Nested" backpack into the "Nesting" backpack.
- Open the "Nesting" backpack and right-click the "Nested" backpack to open it.
- Insert or remove items from the "Nested" backpack and close the inventory.
-
Repeat step 4 and notice the "Nested" backpack was reverted to the state from step 3
Affected Versions (Do not use "latest"):
- IronBackpacks: 1.10.2-2.2.5
- Minecraft: 1.10.2
- Forge: 12.18.2.2099 (Current Recommended) 12.18.2.2107 (Current Latest)
I haven't looked at the code myself yet, nor am I good enough at Java to even begin looking into making a commit for this. But I have an idea towards why it may be happening.
Could the NBT of the "Nesting" backpack not be getting updated to reflect the changes to the "Nested" backpack?
It doesn't happen however with backpacks stored inside other inventories such as chests or backpack items from other mods, only inside this mod's backpacks with the Nesting Upgrade.
So, after much searching, I found out that this was broken when I made the change to allowing you to open a backpack via right click from any inventory instead of just from backpacks. Hopefully, it won't take too long to pin down and fix now.
Might be nothing, but prior to that commit there was this check with a comment:
if (!ItemStack.areItemStackTagsEqual(stack, IronBackpacksHelper.getBackpack(player))) {//can't right click the same backpack you have open, causes it to not update correctly and dupe items
Could it be the same problem? One or both backpacks are not getting saved, or they're saving in the wrong order and one save is overwriting the other.
Yeah I was thinking about that. I was busy this afternoon and couldn't really work on it, but I'll try and push out a fix tomorrow morning (unless it takes me much longer than expected).