[Bug] Backpack Gaining Other Players' Items, or Deleting Inventory When Offline
steventopper opened this issue ยท 6 comments
Version Info
- Minecraft, 1.18.2
- Forge, 40.0.52
- Packed Up, 1.0.25
- Core lib, 1.0.16b
Description of the Bug
I've been playing on the official server for the Moonlit Myths modpack, which includes PackedUp. On the first day of the server, a few days ago, we were having decent lag issues, but I made myself a gold backpack and tried to get some mining done. After an hour, the lag was so bad that I had to get off, so I went to stash things in my backpack, but I noticed that several items were in the backpack that I had not added, such as a spellbook from Ars Nouveau and cutting boards from Farmer's Delight and Pam's Harvestcraft. I put the cutting boards into my inventory and logged out.
Today, I logged in and found my backpack empty, though the cutting boards were still in my inventory. Oh well, I went back to mining for several hours. Near the end, the server started lagging heavily again, and once again I noticed several items in my backpack that were not put in there by me. I removed all of my valuables and logged off; I logged in 6 hours later to find my backpack empty once again. See screenshot for details.
I suspect that the items found in the backpack belong to other players, though I am unsure if these items are being removed or copied from other players' backpacks. I also doubt that they are from a player's inventory, a loot table, or a random list, as there have been no tools or items you would not typically find as loot, and they are mostly items that players would typically put into backpacks, such as waystones and crafting tools.
Steps to Reproduce
I'm honestly not sure, as this is one of the weirdest bugs I've seen, but here's the best I have:
- Play on a multiplayer server.
- Lag the server heavily, i.e. 6 TPS or less.
- Open your backpack to find various items that were not inserted by you.
- Log off and log back in later.
- Open your backpack to find it empty.
Update: I've confirmed that it is linked to another player's active backpack due to seeing another player move items around inside the backpack. It also appears to only be affecting my specific backpack, as others on the server are able to use backpacks without the issue occurring. I suspect it may be due to a corruption of the NBT tag, which is carried over when the backpack is upgraded, explaining why upgrading my backpack did not fix the issue.
The backpack inventories are stored in a separate system and not directly on the items. Packed Up's backpacks are simply an item with an id in their nbt that points to the inventory.
Normally, whenever a backpack without an id in its nbt is right-clicked, the inventory system just increases a global counter by one and gives the backpack that id.
From your description it seems like your backpack may have the same id as someone else's backpack. In that case both of you would simply be interacting with the same inventory.
I think of a couple ways this could have happened:
- You create your backpack and it got its inventory id, then you logged off and your player data, including the backpack with its id, were saved. After that the server may have crashed or been shut down incorrectly, thus not saving the corresponding inventory and the increased global counter. Then someone else created a backpack and got the same id.
- You and someone else requested an inventory id at the exact same time, thus the counter was read by both before one updated it, resulting in the same id. This is possible, but very unlikely.
- There's some other bug in Packed Up which I have not spotted.
Do you know if the server crashed in between you creating your backpack and logging off, and when you logged back in?
I am currently working on some other stuff and quite busy with school, so it might be a bit before I have time to properly look into the code to see whether I can find issues in Packed Up.
Thanks for the explanation, that definitely gives some insight into what might be causing this.
It very well may be due to a server crash; after looking at the chat logs, the server crashed around 4 minutes after after I crafted a golden backpack. There were also three separate times afterwards (while I was online) that all players were timed out from the server due to TPS lag.
This could also explain the empty backpack by that the other player removed everything from the backpack while I was offline. I wish that I had thought to ask the server owner for my inventory file to check the NBT tag for the ID; I will make to do so if the issue arises again.
I found a potential issue with this theory based on the chat timestamps, here are the relevant events:
- 9:50: Backpack crafted by me (the first backpack of the server after a reset)
- 9:53: Server crashes
- 11:22: I leave for the night after noticing random items in my backpack
- 12:38: Another player gets the backpack crafting advancement
Based on this, items appeared in the backpack without any other players owning a backpack at the time. This seems wildly incorrect, but all I have to go off of here are the chat logs and my terrible memory, both of which support this series of events.
Feel free to take your time dealing with this, I fully understand that this is lower priority, especially since this seems to be a very rare issue. I'll keep an eye out for it happening again and try to get more information to help get to the bottom of this.
(Server admin for this server here): Okay, this is somewhat confusing. A player here has an Obsidian Backpack, with the packedup:invIndex
value of 30
. But in the packedup\backpacks
folder there are only 26 inventory#.nbt
files. Could this be related?
Yes, this likely part of the issue.
This means a player created a backpack which then got id 30. Once they log of their inventory, including the backpack, got saved to their player file.
If after that the server crashes, the inventory associated with id 30 doesn't get saved, thus once the server starts up again someone else may then also get id 30 on their backpack.