It seems that the reference to the inventory item is broken at some point, so the items.RemoveAt(i+1) call only affects the items list locally, and not in the Inventory. The references to the items within the list are intact though, so modifying the counts still works. This means that adding one stack to another successfully updates the counts, but the removal of the item from the list fails, therefore items have been duplicated.
I fixed this by decrementing the counts to 0, and then calling the Inventory.RemoveItem(string, int) method which is only needed because it removes stacks of 0 or less.
This resolves the duplication! Maybe not the cleanest but this is my first time touching Valheim mods. Hopefully this at least helps solve the issue.
This solves the issue with partial stacks multiplying when the EquipmentAndQuickSlots mod is installed.
These bugs are mentioned on the mod page: https://www.nexusmods.com/valheim/mods/584?tab=bugs
It seems that the reference to the inventory item is broken at some point, so the items.RemoveAt(i+1) call only affects the items list locally, and not in the Inventory. The references to the items within the list are intact though, so modifying the counts still works. This means that adding one stack to another successfully updates the counts, but the removal of the item from the list fails, therefore items have been duplicated.
I fixed this by decrementing the counts to 0, and then calling the Inventory.RemoveItem(string, int) method which is only needed because it removes stacks of 0 or less.
This resolves the duplication! Maybe not the cleanest but this is my first time touching Valheim mods. Hopefully this at least helps solve the issue.