How do I test for a mob being attacked?
//ads -- adsterra.com -- native banner
?>
I don't know what to try. It might be a /scoreboard command or a /testfor command. I am not sure.
Best Answer
A mob's HurtTime tag will be set to 10 when struck, decreasing by 1 per tick. You can label mobs with a value of 10 to be those who were struck, and remove the label once it reaches 9 (or a value of 1 if you want to continue targeting that mob during those ticks).
/scoreboard players tag @e[type=Creeper] add struck {HurtTime:10s}
/scoreboard players tag @e[type=Creeper,tag=struck] remove struck {HurtTime:9s}
/say Creepers recently struck: @e[type=Creeper,tag=struck]
Pictures about "How do I test for a mob being attacked?"



How do you check entity hits in Minecraft?
The command for summoning is pretty simple. "/summon mob". Players just need to fill in the mob name, though there are a few exceptions. The command remains the same for both Minecraft Java and Bedrock Edition, and is one of the simplest to use.Minecraft: How to detect when a mob dies [1.16+]
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pew Nguyen, RODNAE Productions, RODNAE Productions, RODNAE Productions
