Tough As Nails

Tough As Nails

21M Downloads

Setting max health with other mod

Terrails opened this issue ยท 3 comments

commented

I have an feature in my mod with which I set max value of health but I'm having problems with ToughAsNails installed, players get stuck in a respawn loop when I setBaseValue() of SharedMonsterAttributes.MAX_HEALTH the code basically looks likes this:

IAttributeInstance health = event.player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
health.setBaseValue(5);

The code is in the respawn event but the players just get stuck in death loop, they can press respawn button but it brings them back to it. I tested the code in vanilla only and it worked perfectly. If there is some kind of setMaxHealth method in ToughAsNails I could than just check if the mod is loaded and use it but I didn't find any method.

commented

Looks like I figured it out by applying a modifier but the problem is to when I set the amountIn with the IAttributeInstance#applyModifier to 20 (10 hearts) it actually goes to 40 (20 hearts), its like ToughAsNails adds its own 10 hearts and I can't remove it, if I change the difficulty the hearts change their value like ToughAsNails does it but with +10 hearts.

commented

Never mind fixed it!