Lately, I've been trying to create a custom boss in minecraft.

I want it so when its health is less than x, or when it has lost a quarter of its health, something happens.

However, when I used this:

/testfor @e[type=cave_spider,name=Joe,score_bossHealth_min=9,score_bossHealth=12]

It didn't work. Should I create a scoreboard for this or something?

1 Answer 1


From Minecraft wiki: (Commands#testfor, Chunk format#Mobs)

In your specific case, you would use @e[type=cave_spider,name=Joe]{Health:9.0f} to test for the health being 9.

The general formula is testfor @e[attribute_of_entity=value_of_entity] {attribute_to_test:value_to_test_against}

However, since health can now be decimal values and mobs can take a decimal amount of damage in certain circumstances, you would need a (large/infinite?) number of testfor statements to test every single value from 0-9.

  • I could really improve the formatting for the last bit, but i can't figure out how. apparently health is now stored as a float, and i will edit my answer to reflect this.
    – lasagne-
    Dec 22, 2016 at 1:36
  • The reason that it's not feasible to detect health as a float is because it doesn't have to end up being exactly 9.0. With the combat update, players can very easily deal a non-whole amount of damage, which essentially prevents any detection of that tag's value. Any explosions or fall damage, or any sort of damage soaking such as armor, would also stop the health from being a whole number. Not to mention that the mob would have to be lowered to exactly 9.0 health; if the mob had 10.0 health and the player dealt 2.0 damage, then 9.0 is skipped and not detected.
    – Skylinerw
    Dec 22, 2016 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .