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 '19 at 9:57

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.