'Set health to max health if health > maxhp
I am trying to make a data pack where there is armor that gives the player attributes one of the attributes raises the players max health stored in scoreboard maxhp to be displayed in the action bar with
execute as @a store result score @s maxhp run attribute @s generic.max_health get
which works fine but when the player takes off their armor the max health and maxhp score goes back to what it would be without the armor piece but my problem is that the health of the player stays the same so that it is above the max health is there a way to detect if the players health > their max health and set it to the max health so it wont be greater than the max health?
thankyou
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|