Open rogerwindberg opened 1 year ago
Without actually looking at the Extended player inventory code, I don't this issue is specific to the mod. The current code simply doesn't take into account whether an item is equipped or not, and that applies to an unmodded inventory as well.
It would probably be sufficient to check whether an item is equipped before adding it to the recycle item list.
The Player class has an "isItemEquipped" method that I imagine should do the trick.
Has this been implemented? If not it needs to be. That's super dangerous. Also, ignore anything in the hotbar.
@ZenDragonX has not yet been implemented. I tried to do it myself but I couldn't.
Hey there,
I'm sorry if this suggestion is off, but I don't fully understand these mods & have no experience with them. But I saw your post on the discord and checked it out.
If the armor is equipped, maybe you can try excluding equipped items?
It should be something like:
// adding items to recycler
var playerEquipped = global::Player.m_localPlayer.GetInventory().GetEquippedItems()
.Select(item => item.GetHashCode());
foreach (var item in itemsToRecycle)
{
if (playerEquipped.Contains(item.GetHashCode)) continue; // skip equipped item
// add item to recycler
...
}
@jpw1991, can u fix this and submit a pull request?
@rogerwindberg I'll try
I think I fixed it. Check screenshots. I'll open a PR:
I also added some code just now to filter out the hotbar items
The mod has conflict with the Extended Player Inventory, the equipped armors are appearing in the "Recycle" tab and we may recycle by mistake.
I believe that a simple solution would be to take the ID of the armor fields from the Extended Player Inventory mod and add it to a Recycle blacklist.
I'm not sure how to do this but I've already changed some Open Source Valheim mods. If you give me a direction where to start and an idea of how to go about it, maybe I can help.