Minecraft – How to make a command be triggered when an item is throwed

minecraft-commandsminecraft-java-edition

I would like to have a command that makes a item that when I throw it will freeze mobs for 100 s in a 200 block area (trigger a command). how can I do this?

Best Answer

Have the following commands repeating, in this order:

/scoreboard players tag @e[type=Item] add FreezeItem {Item:{id:"minecraft:ice",tag:{display:{Name:"Freeze"}}}}
/execute @e[type=Item,tag=FreezeItem] ~ ~ ~ /effect @e[type=!Player,r=200] slowness 100 50
/kill @e[type=Item,tag=FreezeItem]

You can change {Item:{id:"minecraft:ice",tag:{display:{Name:"Freeze"}}}} to the tags you want to identify the item by. Currently, it's a block of ice renamed "Freeze".

You can also change /effect @e[type=!Player,r=200] slowness 100 50 to whatever command you want to activate when the item is thrown.