#Give an item with a tag, and detect an item with a tag

1 messages · Page 1 of 1 (latest)

lapis leaf
#

How can I give a player an item with a certain tag, and then detect if a player is holding that item?

unborn forgeBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

static jetty
#

what version?

lapis leaf
#

1.21

static jetty
#

give item with tag => /give @s stick[minecraft:custom_data={IAmACustomTag:1b}]
detecting it => /execute if items entity @s weapon minecraft:stick[minecraft:custom_data~{IAmACustomTag:1b}]

#

if you want to detect multiple different items with that tag, use * instead of the item id

#

if you didn't know, weapon checks for both hands

lapis leaf
static jetty
#

without the minecraft: at the start

lapis leaf
#

ah ok

#

is it possible to check only for the main hand?

static jetty
#

weapon.mainhand

lapis leaf
#

ok thank you