Jump to content

[1.7.10]How to add PotionEffect(s) to custom armor


pickaxe_engineer

Recommended Posts

Hi there

 

This little trick gives you the abillity to customize your armor even more!

 

 

Go to your armor class and override the following method:

 

public void onArmorTick(World world, EntityPlayer player, ItemStack armorPiece)

 

This method is called on every tick, the armor is weared. Insert in the method's body whatever you want. Maybe quick test if its really you're armor piece or whether the armor is complete.

 

After you'd wrote those lines of code, you want to add the potion effect (or several):

 

Insert the following line of code and adapt it to fit you're wishes:

 

player.addPotionEffect(new PotionEffect( potionID, duration, amplifier));

 

A little explanatation:

- potionID is the ID of the potion you want. You find this ID either by search through the wiki or by (in eclipse) typing 'Potion.' and let auto complete do its stuff.

- duration is the amount of ticks the potion will affect the player for. (I usually use 0, to hide the potion effect bubbles(=particles) ). Remeber: 1tick = 1/20 second

- amplifier stands for the effect level. As usual this amplifier begins with 0 to indicate the 'base' level of a potion effect.

 

The following code snipped is an example where the PotionEffect 'Speed II' is added to the player:

player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 0, 1));

 

If you wish to add several effects, repeat the addPotionEffect as often as you want.

 

 

 

Since this is my first post, I hope it fits to the rules and may I could help you.

Happy coding!

 

-pickaxe_engineer

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Link to comment
Share on other sites

Someone please move this to Tutorials or somewhere where it needs to be!

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
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.

Announcements



×
×
  • Create New...

Important Information

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