Minecraft – Testing For A Mob With Less than “x” Hearts

minecraft-commandsminecraft-java-edition

I am making a boss battle, and the boss has a few different stages already implemented, I just need a detector to tell the stages when to activate. To activate the final stage, I want the mob to have less than 20 half hearts, and I try to test that with this command:

/testfor @e[type=Zombie,name=Joe,score_bossHealth_min=1,score_bossHealth_max=20]

However it does not seem to find the mob. In case I'm changing the wrong thing, this post refers to the only other variable that could be affected/affect the mob. Did I make an error in the syntax?

Best Answer

First of all, to detect health the type of the objective should be health and not dummy.

Second of all, there is an error in the syntax. You cannot use score_bossHealth_max in your selector arguments, it is invalid. To select something by a maximum score just use score_bossHealth and don't add _min or _max:

/testfor @e[type=Zombie,name=Joe,score_bossHealth_min=1,score_bossHealth=20]