Jump to content

How to give Entities a health boost if special Armour is worn?


Bedrock_Miner

Recommended Posts

Heyho Guys!

I created some armour which should give the player (or Mob) which is wearing it a health boost. The problem is: If I use the potion Effect to manage this, the extra hearts never regenerate because they are resetted if I re-apply the potion effect every Tick. How can I fix this issue to create an armour that increases your maximum health?

Link to comment
Share on other sites

Hey Bedrock_Miner,

 

you told that the regen effect doesnt apply fast enough because it gets reseted every tick.

 

The solution?

In your onArmorUpdate() method make a int-variable that counts ticks. Make it increase on every tick by 1 and

when it hits lets say 200 (10 secs) then you reapply the regen-effect. Then reset the counter again to 0.

 

 

 

Link to comment
Share on other sites

Guest Abrynos

Just give the entity a regeneration effect level 5000. That would easily fill the hearts up it only has to be there for maybe 10 ticks or so

Link to comment
Share on other sites

  • 2 weeks later...

Try this.  check if potion is active, if no then add else combine.

 

if (!player.isPotionActive(potion.id))

    player.addPotionEffect(new PotionEffect(potion.id, duration, amplifier, isAmbient));

else {

    PotionEffect potionEffect = player.getActivePotionEffect(potion);

    if (potionEffect.getDuration() < duration)

        potionEffect.combine(new PotionEffect(potion.id, duration, amplifier, isAmbient));

    }

}

Link to comment
Share on other sites

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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.