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?
Minecraft – Can command blocks detect punches with certain items
minecraft-commandsminecraft-java-edition
Best Answer
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.
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.