Ivaylo-Lafchiev / ValheimRecycle

Valheim mod for recovering crafting materials from crafted/upgraded items.
MIT License
1 stars 3 forks source link

Extended Player Inventory conflict #11

Open rogerwindberg opened 1 year ago

rogerwindberg commented 1 year ago

The mod has conflict with the Extended Player Inventory, the equipped armors are appearing in the "Recycle" tab and we may recycle by mistake.

image

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.

Ivaylo-Lafchiev commented 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.

ZenDragonX commented 1 year ago

Has this been implemented? If not it needs to be. That's super dangerous. Also, ignore anything in the hotbar.

rogerwindberg commented 1 year ago

@ZenDragonX has not yet been implemented. I tried to do it myself but I couldn't.

jpw1991 commented 1 year ago

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
                ...
            }
rogerwindberg commented 1 year ago

@jpw1991, can u fix this and submit a pull request?

jpw1991 commented 1 year ago

@rogerwindberg I'll try

jpw1991 commented 1 year ago

I think I fixed it. Check screenshots. I'll open a PR:

image

image

jpw1991 commented 1 year ago

I also added some code just now to filter out the hotbar items