Jump to content

Armor Effects


nickname121341

Recommended Posts

Hello, I'm new in modding and I wanted to make it so that when putting on armor, the effect of potions was given, but all the lessons are for older versions of Minecraft and they do not work on 1.15.1
Could you help me, thanks in advance.

(I do not know English very well and therefore translated via Google Translate. Sorry If there are grammatical errors)

Link to comment
Share on other sites

1 hour ago, nickname121341 said:

Hello, I'm new in modding and I wanted to make it so that when putting on armor, the effect of potions was given

You could listen to the LivingEquipmentChangeEvent event, check if the equipped armor is of a specific type, and if so apply the effect to the entity. Then you would also have to detect if the entity unequipped the armor, and if so remove the effect.

 

Alternatively, if the armor in question is your own mods custom armor, you could override onArmorTick() and periodically reapply the potion effect.

 

Here is a recent post (although for 1.16) discussing a similar issue: link

Edited by vemerion
Link to comment
Share on other sites

3 minutes ago, nickname121341 said:

I used LivingEquipmentChangeEvent and no errors were found in the code, but for some reason, when I put on the armor, minecraft crashes.

I would advise against copying code you don't fully understand, since it will most likely introduce bugs. First of all, remove 'value = Dist.CLIENT', since you cannot add potion effects on the client (I believe this was also discussed in the thread I linked).

 

Second, have you tried debugging / checking the logs to find out where and why it crashes? It is very hard for me to stare at a PNG of code trying to detect what is wrong.

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.