Jump to content

Detecting if the character has a specific armor equiped


Recommended Posts

Assuming you are doing this with a blockActivated() or itemRightClick(), you can use the player parameter to do this:


int id = player.inventory.armorInSlot(slot).itemID;
if(id == myItem.itemID)
//do stuff


Vanilla code.

Link to comment
Share on other sites

If you are using eclipse, right click in the file, go to source, select Override/Implement methods, go to the Item head, and select onArmorTickUpdate() and it will override it for you in your file. Then you add your code there.

Link to comment
Share on other sites

You just need to subscribe to the Event "RenderPlayerEvent.Specials.Post". This will secure that your glow will be rendered AFTER (use .Pre if you want it before) everything else. You can do this like this:

import cpw.mods.fml.common.Mod.EventHandler;
import net.minecraftforge.client.event.RenderPlayerEvent.Post;

class YourRenderer {
public void renderGlow(Post renderEvent)
Player p = renderEvent.entityPlayer;
boolean isHelmet = (p.getCurrentArmor(0).getItem() instanceof YourArmorClass);

Put the method whereever you want, preferably in a new class that will handle all your rendering stuff or something. All you have to do is creating a new Instance of this class in your @Mod-class I guess (at least that's how I understood the @EventHandler thingy). This means in your @Mod file there is a variable declared:

class bla {
private YourRenderer myRenderer = new YourRenderer(); //Instance


That done myRenderer is now ready to receive events of type RenderPlayerEvent.Specials.Post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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