Jump to content

Recommended Posts

Posted

When you wear the full set you're supposed to get speed 2 and Regeneration 3, It shows up on the left of the inventory and gives me the speed 2 but the regeneration effect doesn't work.

 

Armor:

 

@Override

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

{

if(player.getCurrentArmor(3) != null && player.getCurrentArmor(3).getItem().equals(PItems.phoenixHelmet) && player.getCurrentArmor(2) != null && player.getCurrentArmor(2).getItem().equals(PItems.phoenixChestplate) && player.getCurrentArmor(1) != null && player.getCurrentArmor(1).getItem().equals(PItems.phoenixLeggings) && player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem().equals(PItems.phoenixBoots))

{

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

player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 1, 2));

}

}

 

Posted

That's because you are applying the potion effect every tick.

 

If you knew how Regeneration worked, you would see the problem immediately.  Regeneration heals the player when the time remaining % 10 equals 0.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

In other words, you have to apply the potion effect for at least 10 ticks, and preferably not every single tick.

 

Also note that many potions apply their effect every n ticks where n goes down as the potion level increases, so Regen I may be every 50 ticks, Regen II every 25 ticks, and Regen III every 10 ticks. I didn't pull those numbers from the code, but you can suss out the actual values by looking in the potion classes and calculating them based on the fun formula there. Hope you know how bit operators work ;)

 

If you don't want to allow the Regen potion to have a long duration but still be effective, you could consider foregoing potion effects altogether and just healing the player directly every so often in the armor tick. E.g.:

// this would heal 1/2 heart every 10 ticks
if (player.ticksExisted % 10 == 9) {
  player.heal(0.5F);
}

Posted

A couple other potions have a "waver" or transition period at certain values (night vision kind of blinks at less than 20-40 ticks, I forget the exact value).  I actually utilize that for a smoke block, forcing the player's remaining blindness amount to be 18 ticks.  Gives a vision radius of about 8-12 blocks rather than the typical 4.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.