abluescarab / tModLoader-WingSlot

This mod adds a dedicated wing slot to the inventory.
GNU General Public License v3.0
16 stars 9 forks source link

Fix mod for 0.11.5, Add GetEquipSlotItem and similar mod.Calls #32

Closed direwolf420 closed 4 years ago

direwolf420 commented 4 years ago

This PR provides three new mod.Calls getequipslotitem, getvanityslotitem and getvisibleitem, with each returning an Item. Called on demand, not in PostSetupContent because WingSlotPlayer isn't initialized yet.

Example:

Item wingItem = null;
if (ModLoader.GetMod("WingSlot") is Mod wingSlot && wingSlot != null) {
    wingItem = (Item)wingSlot.Call("getvisibleitem", player.whoAmI);
}
for (int j = 3; j < 8 + player.extraAccessorySlots; j++)
{
    Item item = player.armor[j];
    if (!item.IsAir && item.wingSlot > 0)
    {
        wingItem = item;
    }
}
if (wingItem != null) //stuff
abluescarab commented 4 years ago

Looks great! Thanks for fixing for 0.11.5, as well.