Minecraft Blogs / Tutorial

Modding Tutorial (Adding New Armor Effects!)

  • 14,404 views, 2 today
  • 33
  • 10
  • 77
Surseance's Avatar Surseance
Level 67 : High Grandmaster Modder
288
=== Armor Effects Tutorial ===

by MrXminister


Hey folks, this is my first modding tutorial so I'd appreciate if you gave me some constructive criticism/feedback! Alright, so, I realized that mo' tools and mo' armor mods are extremely common on these forums. In an attempt to vamp these up to the next level, I have a few lines of source code for ya! Here we go:

Here are some things to keep in mind for armor: 0 = boots, 1 = leggings, 2 = chest-plate, 3 = helmet
And also make sure you replace "ArmorNameHere" with your armor names!
This code belongs in your: mod_NameHere.java file!

Diamond if this was helpful!
Peace!

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(0) != null)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(0);

if (itemstack.itemID == ArmorNameHere.shiftedIndex)

{

minecraft.thePlayer.speedOnGround = 0.41999998688697815F;

}

}

return true;

}

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(0) != null)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(0);

if (itemstack.itemID == ArmorNameHere.shiftedIndex)

{

if (Keyboard.isKeyDown(minecraft.gameSettings.keyBindJump.keyCode) && minecraft.thePlayer.motionY > 0.0D)

{

minecraft.thePlayer.motionY += 0.066999999105930325D; //Change this value to how high you wnat the player to jump

minecraft.thePlayer.speedInAir = 0.0334999996F; //Change this value to set the speed while in air

}

minecraft.thePlayer.fallDistance = 0.0F;

}

}

return true;

}

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(2) != null)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(2);

if (itemstack.itemID == ArmorNameHere.shiftedIndex)

{

if (minecraft.currentScreen == null && Keyboard.isKeyDown(minecraft.gameSettings.keyBindJump.keyCode))

{

if (minecraft.thePlayer.motionY > 0.0D)

{

minecraft.thePlayer.motionY += 0.084999999105930327D;

}

else

{

minecraft.thePlayer.motionY += 0.11699999910593033D;

}

minecraft.theWorld.spawnParticle("smoke", minecraft.thePlayer.posX, minecraft.thePlayer.posY - 1.0D, minecraft.thePlayer.posZ, 0.0D, 0.0D, 0.0D);

}

if (minecraft.thePlayer.motionY < 0.0D)

{

minecraft.thePlayer.motionY /= 1.1499999761581421D;

}

if (!minecraft.thePlayer.onGround)

{



minecraft.thePlayer.motionX *= 1.0399999618530273D;

minecraft.thePlayer.motionZ *= 1.0399999618530273D;



}

minecraft.thePlayer.fallDistance = 0.0F;

hasJetpack = true;

}

else

{

hasJetpack = false;

}

}

return true;

}

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(2) != null)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(2);

if (itemstack2.itemID == ArmorNameHere.shiftedIndex)

{

minecraft.thePlayer.isImmuneToFire = true;

List list = minecraft.theWorld.getEntitiesWithinAABBExcludingEntity(minecraft.thePlayer, minecraft.thePlayer.boundingBox.expand(4D, 0.0D, 4D)); //Change the 4D to set the radius



if (list != null)

{

for (int k2 = 0; k2 < list.size(); k2++)

{

Entity entity = (Entity)list.get(k2);

if ((entity instanceof EntityLiving) && !entity.isDead)

{

entity.setOnFireFromLava(); //Or any other function you want the entity to recieve

}

}

}

}

}

return true;

}

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(0) != null) //Change two for the desired armor placement (see above)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(0);

if (itemstack.itemID == ArmorNameHere.shiftedIndex

{

minecraft.thePlayer.fallDistance = 0.0F;

}

}

return true;

}

Click to reveal


public boolean onTickInGame(float f, Minecraft minecraft)

{

if (minecraft.thePlayer.inventory.armorItemInSlot(2) != null) //Change two for the desired armor placement (see above)

{

ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(2);

if (itemstack.itemID == ArmorNameHere.shiftedIndex && minecraft.thePlayer.motionY < 0.0D)

{

minecraft.thePlayer.motionY /= 1.6000000238418579D;

minecraft.thePlayer.fallDistance = 0.0F;

}

}

return true;

}
Tags

Create an account or sign in to comment.

1
07/13/2014 4:11 pm
Level 1 : New Explorer
TheVanillaMiner
TheVanillaMiner's Avatar
Can you Private message me of how to make armor sets?
1
04/21/2014 7:40 am
Level 1 : New Explorer
XxHelloBaixX
XxHelloBaixX's Avatar
Nice
1
01/07/2014 10:04 pm
Level 55 : Grandmaster Engineer
Theironmanarmourdood
Theironmanarmourdood's Avatar
do we make a new class? or write it in our main.class?
1
01/08/2014 6:14 pm
Level 67 : High Grandmaster Modder
Surseance
Surseance's Avatar
In the Item class, there is actually an armor update method you can call; it performs given operations on a per-tick basis. You should attempt using those instead of Tick Handlers. Alternatively, you could use Event Handlers --they are pretty fantastic.
1
01/08/2014 6:50 pm
Level 55 : Grandmaster Engineer
Theironmanarmourdood
Theironmanarmourdood's Avatar
so i do that in the item class
1
01/09/2014 4:46 pm
Level 67 : High Grandmaster Modder
Surseance
Surseance's Avatar
You can. Or you can register through the Event Bus to make your own Event Handler. I believe coolAlias has a tutorial somewhere on the Minecraft forums for making an event handler. I highly suggest you check it out.
1
01/26/2014 5:20 pm
Level 55 : Grandmaster Engineer
Theironmanarmourdood
Theironmanarmourdood's Avatar
okay i created it so do i do the jetpack code in the event handler
1
01/26/2014 6:58 pm
Level 67 : High Grandmaster Modder
Surseance
Surseance's Avatar
You can. Or a TickHandler. Just so you know, you can only negate fall damage on the SERVER SIDE ONLY. Thus, when your event bus or Tick Handler is initiated, you will need to specify the side: @SideOnly(Side.SERVER)

Happy modding!
1
09/10/2013 9:27 am
Level 35 : Artisan Nether Knight
Mimix2048
Mimix2048's Avatar
This will help :)
1
08/14/2013 9:37 am
Level 32 : Artisan Electrician
TheTrollapedia
TheTrollapedia's Avatar
You my friend are a god on earth.
1
07/30/2013 4:08 pm
Level 12 : Journeyman Toast
Feniula
Feniula's Avatar
is this java?
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome