Hey there!
I'm working on a datapack, and I need some help!
As you might know there are block and/or item groups in minecraft like #wool which contains all 16 types of wool, or #oak_logs which contains oak log, oak wood, stripped oak log and stripped oak wood.
And there is this command: /execute as @a[nbt={SelectedItem:{id:"minecraft:stone"}}] run... which executes as all players holding a stone in their mainhand.
So I wanna know if there is a possibility to do this with item groups like /execute as @a[nbt={SelectedItem:{id:"#minecraft:wool"}}] run... to do something like say "It's wool!" if you have some wool in your hand. And not to do 16 commands one for every wool colour.
It would be so nice and helpfull if someone can answer me my question!
Thanks
I'm working on a datapack, and I need some help!
As you might know there are block and/or item groups in minecraft like #wool which contains all 16 types of wool, or #oak_logs which contains oak log, oak wood, stripped oak log and stripped oak wood.
And there is this command: /execute as @a[nbt={SelectedItem:{id:"minecraft:stone"}}] run... which executes as all players holding a stone in their mainhand.
So I wanna know if there is a possibility to do this with item groups like /execute as @a[nbt={SelectedItem:{id:"#minecraft:wool"}}] run... to do something like say "It's wool!" if you have some wool in your hand. And not to do 16 commands one for every wool colour.
It would be so nice and helpfull if someone can answer me my question!
Thanks
6
You can use a predicate (wiki article here). For instance, if you want to test for wool and are using the namespace "example", you could create a file at /data/example/predicates/holding_wool.json and put this in it:
And then run a command like this:
/execute as @a[predicate=example:holding_wool] run ...
{
"condition": "minecraft:entity_properties",
"entity":"this",
"predicate": {
"equipment": {
"mainhand": {
"tag": "minecraft:wool"
}
}
}
}
And then run a command like this:
/execute as @a[predicate=example:holding_wool] run ...
Thank you I think this may help me! :D
Alternatively, if the condition "match_tool" equals to selectitem, you can do this instead
Thanks for reminding me about predicates
{
"condition": "minecraft:match_tool",
"predicate": {
"tag": "minecraft:wool"
}
} Thanks for reminding me about predicates
Also thanks to you ^^
Pretty sure tags for block/entity nbt doesnt exist in general, as it has to be /data friendly.
For example, if you were to select the player with the item group "#minecraft:wool" in their hand, executing /data get entity <player> SelectedItem will get you: "SelectedItem:{id:"#minecraft:wool"}" which isnt helpful at all.
Additionally the different types of wool have their own ids e.g. orange wool = orange_wool.
For example, if you were to select the player with the item group "#minecraft:wool" in their hand, executing /data get entity <player> SelectedItem will get you: "SelectedItem:{id:"#minecraft:wool"}" which isnt helpful at all.
Additionally the different types of wool have their own ids e.g. orange wool = orange_wool.
Thanks for your answer but sadly I dont really understand what you mean :/
I know that they all have their own id but I want to check if a player has any item of a group in his hand.
I know that they all have their own id but I want to check if a player has any item of a group in his hand.
