Fix conflict with EquipmentAndQuickSlots mod #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.