Is there a way for command blocks to detect when a certain item hits a mob? Like could I have a command block detect when I hit a mob with a stick and then use /execute to make it explode?

  • 1
    What have you tried thus far?
    – Joachim
    Jun 2, 2019 at 9:57

1 Answer 1


Put this command into a repeating command block and it will summon tnt that will instantly explode on every entity that gets hurt close to a player holding a stick.

execute at @a[nbt={SelectedItem:{id:"minecraft:stick"}}] run execute at @e[distance=0.1..5,nbt={HurtTime:10s}] run summon tnt ~ ~ ~ {Fuse:0}

The command does NOT detect, HOW the entity got hurt, but it seems to often not work when the entity gets hurt by something other than a punch.

You must log in to answer this question.

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