Jump to content

Recommended Posts

Posted

hey, i updated my mod to 1.7.2, it had a armor effect function

but it doesnt work anymore

 

public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack)

{

ItemStack flipper = player.getCurrentArmor(1);

 

if (flipper != null )

{

if (flipper.getItem() == armorMod.Flippers)

{

if (player.isInWater())

{

player.motionX *= 1.2;

player.motionZ *= 1.2;

player.jumpMovementFactor *= 1.2;

}

else

{

player.motionX *= 0.2;

player.motionZ *= 0.2;

}

}

}

}

Posted

onArmorTickUpdate was renamed to onArmorTick. Seriously people, use the @Override annotation. It's one simple line for a whole lot of error protection.

 

Also, the ticking armor is only called when you are wearing the item, and it's called for that item, so you don't need to getCurrentArmor or null check unless you are checking slots other than the one ticking. You can even do this:

 

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
if (this == armorMod.Flippers) {
// do stuff
}
}

That's the beauty of non-static class methods - they can only be called with an actual object of that class, so you are always safe from null and can use "this", because the Item in question is the one calling the method.

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.