Posted August 19, 201411 yr 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? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
August 20, 201411 yr 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.
August 20, 201411 yr Author 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. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
August 21, 201411 yr 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
August 21, 201411 yr Author Actually I don't want the Entity to be healed, so this doesn't work. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
August 21, 201411 yr Get the entitys current health before you reapply the effect, and set the health to it afterward. Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
September 4, 201411 yr 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)); } }
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.