How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate]

How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate] - Books On The Table

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]"

How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate] - Side view of adult Hispanic guy with dreadlocks in sunglasses and casual clothes with backpack and smart watch drinking yummy beverage from vivid yellow can while standing with eyes closed on street in downtown
How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate] - Confident adult Hispanic male traveler in sunglasses and casual clothes with backpack opening can of drink while walking along pavement against blurred cars driving along street and empty crosswalk in downtown
How can I /testfor a mob's health in Minecraft Java 1.11? [duplicate] - White and Black Wooden Sign Board





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