Am making a small datapack and i have trouble with giving health boost on the player. Unlike other effects having the command /effect give @a[level=100..199] minecraft:health_boost 60 0 true always activating will keep reseting the life of the extra hearts. Is there a way to make it so when the player has from 100 to 199 levels the player will have the health boost effect?
It could be a two-stage event using TAGS (in this specific order):
Step 1:
Look for somebody that doesn't have the tag "KING", has levels 100..199 and apply the effect.
execute if score @a[tag=!KING] matches 100..199 run EFFECT
Step 2:
Tag the person that has 100..199 levels as "KING"
This way the next time this command runs, it won't reset the effect. This is because they should have the tag in place. Once run again it is looking for somebody without it, hence it won't apply the second time around.
If you want to reset the effect after something happens simply remove the tag.
Step 3: OPTIONAL
detect player that has tag KING and ..99 levels remove tag
Your first command didn't work but thanks to your instructions i managed to make something that works.
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
This by itself works perfectly but i run in to another problem. What am trying to do is to have the player have a certain amount of health boost effect based on their levels so i added some extra commands and made this.
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
It works fine as long as you keep getting levels but when you remove levels from the player so in survival it would be when enchanting, the smaller health boost effect cannot replace the bigger one so am stuck atm on how i can have the effects switch.
I tried to remove the effect when the player's level decreases in order to have less hearts but it doesn't give back the effect after it seems that the commands give first the effect and then remove it
Am making a small datapack and i have trouble with giving health boost on the player. Unlike other effects having the command /effect give @a[level=100..199] minecraft:health_boost 60 0 true always activating will keep reseting the life of the extra hearts. Is there a way to make it so when the player has from 100 to 199 levels the player will have the health boost effect?
It could be a two-stage event using TAGS (in this specific order):
Step 1:
Look for somebody that doesn't have the tag "KING", has levels 100..199 and apply the effect.
Step 2:
Tag the person that has 100..199 levels as "KING"
This way the next time this command runs, it won't reset the effect. This is because they should have the tag in place. Once run again it is looking for somebody without it, hence it won't apply the second time around.
If you want to reset the effect after something happens simply remove the tag.
Step 3: OPTIONAL
detect player that has tag KING and ..99 levels remove tag
Hope this works out for you!
Your first command didn't work but thanks to your instructions i managed to make something that works.
This by itself works perfectly but i run in to another problem. What am trying to do is to have the player have a certain amount of health boost effect based on their levels so i added some extra commands and made this.
It works fine as long as you keep getting levels but when you remove levels from the player so in survival it would be when enchanting, the smaller health boost effect cannot replace the bigger one so am stuck atm on how i can have the effects switch.
I tried to remove the effect when the player's level decreases in order to have less hearts but it doesn't give back the effect after it seems that the commands give first the effect and then remove it