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 |
tools/tracking
948110
6
modding-tutorial-adding-new-armor-effects
Create an account or sign in to comment.
Happy modding!