Jump to content

[1.8] Checks whether a player wears custom armor, and what parts of the armor


Kander16

Recommended Posts

Hi, I have custom armor, and I want to 'test' wether a player wears custom made armor, and what parts of the armor that are weared. boots).

 

Lets say I have an integer "armorWeared" of '0', and when the player wears a helmet we add 3 to "armorWeared", when the player wears boots, we add 1 to "armorWeared". Total: 4

And of course also, when the player takes of the helmet the total will be 1.

 

How do I do this?

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

Where do you need to calculate the 'armorWeared' value?

It is easy, you can just add up them when it is needed in most case.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

It sounds like you just want to know if your player is wearing ALL of the pieces at once to then do something, no? In that case, whenever you want to do that special thing, simply check each piece of worn equipment on the player:

ItemStack helm = player.getCurrentArmor(3); // etc. for each piece, then check each:
if (helm != null && helm.getItem() == YourMod.yourCustomHelm && // etc., all the other pieces) {
// do your special thing here
}

 

If, for whatever reason, you actually need to know which specific parts of your custom armor are being worn at all times without manually checking the player's armor slots all the time (which isn't really that big of a deal), then I recommend storing that information in IExtendedEntityProperties, but you really have to ask yoursef:

 

"Why do I need this information, and why is the current method of getting that information not sufficient for my needs?"

 

In 99% of cases, you will find that the current methods (see above) are more than sufficient.

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.

Guest
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.