Topic category: User side tutorials
I finally figured out a way to do this! :D
This was done in MCreator 1.7.3 (as my mod is for MC 1.7.10). For newer versions this should still work, but I'm not promising for now.
This tutorial is for potion effects as set bonuses, but if you search for the code and imports you can do loads of things!
1. Create your armor as normal.
2. Open your armor element in the Code tab.
3. At the start of your code, you should see a bunch of lines that say 'import -something-'. Right beneath those, you should add:
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
4. Scroll down and find the lines that say public void onArmorTick() (or something similar). There is a different one for each piece of armor, but we only need one (I used the leggings armor here).
5. Add the following code inside the brackets, replacing the names appropriately. You should replace 'AssassinArmor' with the name of your armor mod element on the three lines..
if (entity.getCurrentArmor(2) != null && entity.getCurrentArmor(2).getItem().equals(mcreator_assassinArmor.body)) {
if (entity.getCurrentArmor(3) != null && entity.getCurrentArmor(3).getItem().equals(mcreator_assassinArmor.helmet)) {
if (entity.getCurrentArmor(0) != null && entity.getCurrentArmor(0).getItem().equals(mcreator_assassinArmor.boots)) {
///This is where we put the potion effects
}
}
}
6. Where the writing in bold is above, add the following line:
entity.addPotionEffect(new PotionEffect(1, 15, 1));
Replace the numbers to your liking. The first number is the potion effect to give (a list is here). The second number is the duration in ticks (20 ticks = 1 second). The last is the amplifier (this is one higher than the level you want, for example I put 1 meaning I will get a level 2 effect.
The above example gives Speed 2. You can copy and edit this line to add more effects.
Save and enjoy!!
You don't need custom code for this. You can simply have a procedure for 'on helmet (or any armour piece of your set) tick event' that checks for the other pieces using the procedure block that determines this, and if all pieces are present, it applies the bonus.
Nice ^^
big oof
You can don't to all this. You can just put 4 "if" blocks together (each one with one of the armor piece) and than make what you want at the end.
Actually putting four if statements returns me an error, however the compilation fails even if I use the code above.
Edit: I got it to work, 0 is the boots, 1 for leggings, 2 for chestplate and 3 for helmet.You only need 3 if statements.
Coul'd you please send and explain me the code? I need this for Armors and i don't understand this coding relly good, because i never coded before.