Minecraft Java Edition – How to Detect When a Player Holds a Tagged Item with NBT Data

minecraft-commandsminecraft-java-edition

My command is

execute at @a[ scores={fire_mage=1..},tag=mage:1b] run summon minecraft:fireball ^ ^1 ^1

However this command does not detect the tag and shows an error for tag.

Best Answer

For holding, there's a tag named SelectedItem, and you can use it in /execute at @a[nbt={SelectedItem:{tag:{mage:1b}}}] run summon minecraft:fireball ^ ^1 ^1