Iron Backpacks

Iron Backpacks

54M Downloads

Nested backpacks do not update contents

Hazerd opened this issue ยท 5 comments

commented

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):

  1. Create two new backpacks (thus named "Nesting" and "Nested").
  2. Attach a Nesting Upgrade or Advanced Nesting Upgrade to the "Nesting" backpack.
  3. Insert the "Nested" backpack into the "Nesting" backpack.
  4. Open the "Nesting" backpack and right-click the "Nested" backpack to open it.
  5. Insert or remove items from the "Nested" backpack and close the inventory.
  6. 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)
commented

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.

commented

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.

commented

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.

commented

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).

commented

Implemented a non-ideal fix. I'll look into the issue more later, but it's been a pain and taken a while, and I wanted to get a fix out soon. Expect a build up on CF momentarily.