Bedrock_Miner Posted August 19, 2014 Posted August 19, 2014 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? Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Gandalf560 Posted August 20, 2014 Posted August 20, 2014 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. Quote
Bedrock_Miner Posted August 20, 2014 Author Posted August 20, 2014 Well, I have added this Feature already, the effect is re-applied every 8 seconds, but everytime this happens, the additional hearts are emptied. If I have 2 extra hearts (both filled) and I re-apply the health boost effect, they are emptied. Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Guest Abrynos Posted August 21, 2014 Posted August 21, 2014 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 Quote
Bedrock_Miner Posted August 21, 2014 Author Posted August 21, 2014 Actually I don't want the Entity to be healed, so this doesn't work. Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Eternaldoom Posted August 21, 2014 Posted August 21, 2014 Get the entitys current health before you reapply the effect, and set the health to it afterward. Quote Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
DotSplat Posted September 4, 2014 Posted September 4, 2014 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)); } } Quote
Recommended Posts
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.