How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate]
I'm making a map for 1.11, and I need to test for a zombie with a certain health. I tried:
/testfor @e[type=zombie] {CustomName:"HEROBRINE",Health:9s}
But it didn't work.
Best Answer
The Health
tag's datatype was changed from Short to Float in 1.9, while the old HealF
tag was removed. To declare a Float, you append the numerical value with an "f". You can also check the custom name with the name
parameter in the selector instead of detecting it through raw NBT data:
/testfor @e[type=zombie,name=HEROBRINE] {Health:9f}
However, because the datatype is Float, it is highly unlikely that its health will be exactly 9.0. If at any point the mob takes a fraction of health, it essentially becomes impossible to detect the health of non-player entities.
Pictures about "How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate]"
MCPE Tutorials | Mob Death Detection Using Command Block
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Ylanite Koppens, Andrea Piacquadio, Andrea Piacquadio, Karolina Grabowska