1

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.

1 Answer 1

1

When testing for NBT, you need to put the correct data type for numbers.

The HurtTime tag is a Short value, so you must specify so by suffixing your number with an s:

{HurtTime:10s}

You must log in to answer this question.

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