TransWikia.com

Minecraft target selector select by built-in tag | e.g. Inventory item with tag "wool"

Arqade Asked by Chris F Carroll on June 9, 2021

We want to check whether someone has wool in their Inventory. We can test if they have minecraft:white_wool or minecraft:pink_wool etc etc with :

/data get entity @s[nbt={Inventory:[{id:"minecraft:white_wool"}]}]

But there’s supposed to be a built-in tag called wool that includes all the wools, so we tried things like:

/data get entity @s[nbt={Inventory:[{tag:{wool:1}}]}]
/data get entity @s[nbt={Inventory:[{tag:{"minecraft:wool":1}}]}]
/data get entity @s[nbt={Inventory:[{tag:{"#minecraft:wool":1}}]}]

but they got nothing. How can we select someone holding any kind of wool?

One Answer

The reason that your NBT checks don't work is because the id tag stores only the exact ID. The NBT processor does not know or care about any item tags that the item may belong to, all it notices is that your provided string (#minecraft:wool) does not match the actual value that's there (minecraft:white_wool).

The NBT checks don't have access to data pack tags. This means that the only way to accomplish your task is to test for each individual ID, or use a predicate, which requires a data pack:

{
    "condition": "entity_properties",
    "entity": "this",
    "predicate": {
        "equipment": {
            "mainhand": {
                "tag": "minecraft:wool"
            }
        }
    }
}

As I always say, a data pack is not unusual. In fact, it is actually becoming a new normal for writing commands and other actions, and command blocks are dwindling in use. So you should really become used to creating data packs, because they are much wider in terms of what you can do.

Answered by ExpertCoder14 on June 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP