Minecraft 1.18.2: How To Run a Command When a Player Holds a Certain Item
The command:
Run the command when a player holds a regular item:
execute at @p[nbt={SelectedItem:{id:"minecraft:diamond_sword"}}] run effect give @p minecraft:strength 1 2
Run the command when a player holds a item with a tag:
give @p minecraft:diamond_sword{diamond:1}
execute at @p[nbt={SelectedItem:{id:"minecraft:diamond_sword",tag:{diamond:1}}}] run effect give @p minecraft:strength 1 2
Become A Member - / @vivtorsing
My Discord - / discord
Thanks for watching