As simple as the title gets, I want to detect when a certain kind of mob has been hit and then execute a command accordingly. Say the mob is a cow and I wish to detect whenever a player has hit the cow. This was the code I came up with:
execute if entity @e[type=cow,nbt={HurtTime:10}] run …
On putting it in the command block, it didnt really work, I want it to detect every bit of damage done to a specific kind of a mob even a punch. Or is there any other way do execute this command other than the hurt time function?
This is for Minecraft Java Edition 1.17.