I have the following command:
execute as @a
[nbt={SelectedItem:{id:"minecraft:snowball",components:{"minecraft:custom_data":{inv:1b}}}}]
at @s run effect give @s minecraft:invisibility 1 0 true
It checks if the player has an item with specific custom data in their main hand. But I need to check if the item is in their secondary hand (or in any other slot), and unfortunately, my knowledge of command blocks in Minecraft version 1.21.10 does not allow me to understand why this command doesn't work.
I tried using Inventory slots and Items instead of SelectedItem, but my attempts were unsuccessful.