Jump to content

[1.8.9] Equip/unequip armor onto player


Tral1s

Recommended Posts

Hi, I'm attempting to make an armor hotswap mod where if the player right clicks a piece of armor it will replace the armor they currently have on with it. (For example, right clicking diamond boots to replace leather boots that are currently equipped)

I found a thread which talks about how to do this in 1.13+, but I want to achieve this in 1.8.9. The answer there was use 

Minecraft.getInstance().player.inventory.armorInventory.set(armorIndex, itemStack);

But in forge 1.8.9 the closest I can get is this:

Minecraft.getMinecraft().thePlayer.inventory.armorInventory

Which is just an ArmorStack array. How do I change the armor? Will simply updating the array do the trick? 

 

Thanks, 

- Tral1s (First time modder, 3d year programmer)

Link to comment
Share on other sites

So I tried it again, and it worked! (For some reason it crashed the first time). All you have to do is 

Minecraft.getMinecraft().thePlayer.inventory.armorInventory[armorIndex] = itemStack;

and it places it, regardless of what it is.... So I managed to put a barrier on my legs... because I'm that skilled.

Screenshot (102).png

Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.