Am having trouble with the commands in my function file. This is how it works. The file checks for any player that has levels from 100-199 and gives him health boost 0. If the player has 200-299 levels it gives health boost 2. Finaly if the player has 300+ levels it gives health boost 3. The issue i have is that i cannot make it work backwards. I added a command that removes the effect when it goes from a higher level lets say from 301 to 298 and i hoped that the file would first remove the effect and then add the lower effect back but it seems that it does the oposite or both at the same time. So is there a way to make this work backwards?
execute if entity @a[tag=!heart,level=100..199] run effect give @a[tag=!heart,level=100..199] minecraft:health_boost 999999 0 true
execute if entity @a[tag=!heart,level=..99] run effect clear @a[tag=!heart,level=..99] minecraft:health_boost
tag @a[level=100..199] add heart
tag @a[level=..99] remove heart
#
execute if entity @a[tag=!heart2,level=200..299] run effect give @a[tag=!heart2,level=200..299] minecraft:health_boost 999999 2 true
tag @a[level=200..299] add heart2
tag @a[level=..199] remove heart2
#
execute if entity @a[tag=!heart3,level=300..] run effect give @a[tag=!heart3,level=300..] minecraft:health_boost 999999 4 true
tag @a[level=300..] add heart3
tag @a[level=..299] remove heart3
I somehow missed the first reply and only saw the tag health boost one i tested it and it works perfectly. I had no idea about the attribute command i thought you could give more health to players via custom armor items. Thank you for your help.
Am having trouble with the commands in my function file. This is how it works. The file checks for any player that has levels from 100-199 and gives him health boost 0. If the player has 200-299 levels it gives health boost 2. Finaly if the player has 300+ levels it gives health boost 3. The issue i have is that i cannot make it work backwards. I added a command that removes the effect when it goes from a higher level lets say from 301 to 298 and i hoped that the file would first remove the effect and then add the lower effect back but it seems that it does the oposite or both at the same time. So is there a way to make this work backwards?
This should get the intended affect:
execute as @a[level=..99] run attribute @s minecraft:generic.max_health base set 20
execute as @a[level=100..199] run attribute @s minecraft:generic.max_health base set 24
execute as @a[level=200..299] run attribute @s minecraft:generic.max_health base set 32
execute as @a[level=300..] run attribute @s minecraft:generic.max_health base set 40
If you want to stick with tags, I think this would work
tag @a[level=..99,tag=heart] add heartn
tag @a[level=..199,tag=heart2] add heartn
tag @a[level=..299,tag=heart3] add heartn
effect clear @a[tag=heartn] minecraft:health_boost
tag @a[tag=heartn] remove heart
tag @a[tag=heartn] remove heart2
tag @a[tag=heartn] remove heart3
tag @a remove heartn
#
effect give @a[tag=!heart,level=100..199] minecraft:health_boost 999999 0 true
tag @a[level=100..199] add heart
#
effect give @a[tag=!heart2,level=200..299] minecraft:health_boost 999999 2 true
tag @a[level=200..299] add heart2
tag @a[level=200..299] remove heart
#
effect give @a[tag=!heart3,level=300..] minecraft:health_boost 999999 4 true
tag @a[level=300..] add heart3
tag @a[level=300..] remove heart 2
I somehow missed the first reply and only saw the tag health boost one i tested it and it works perfectly. I had no idea about the attribute command i thought you could give more health to players via custom armor items. Thank you for your help.