What I want to do:
I want to grant an advancement if the user have an item with a specific custom data in Item.components."minecraft:custom_data"{}, for example aCustomData, regardless of others custom data in the item.
An example:
If I have an enchanted book with the following content ...
give @s minecraft:enchanted_book[custom_data={aCustomData:1b,anotherCustomData:1b,aLastCustomData:1b}]
... I expect the following advancement to be granted:
{
...
"criteria": {
"aCustomData": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"components": {
"minecraft:custom_data": {
"aCustomData": 1
}
}
}
]
}
}
}
}
What happen:
Nothing happen, the advancement is not granted. Maybe because the given item have extra elements in "minecraft:custom_data" (i.e. anotherCustomData:1b,aLastCustomData:1b).
It seems it check if all the content inside "minecraft:custom_data" of the item is the same than the one described in the advancement, instead of checking only the custom data described in "minecraft:custom_data" of the advancement.
If I instead give myself this item:
give @s minecraft:enchanted_book[custom_data={aCustomData:1b}]
Then the advancement described above is granted.
What I expected:
The advancement should be granted if the specified custom data in the advancement match the value of the same custom data in the item, regardless of other custom datas in this item (that are not specified/required by the advancement).
Linked issues
duplicates 1
Attachments
Comments 2
Thank you for your report!
We're tracking this issue in MC-272893, so this ticket is being resolved and linked as a duplicate.
That ticket has already been resolved as working as intended, which means this is not considered a bug and won't be fixed. Please do not leave a comment on the linked ticket.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
If I remember correctly, this used to be possible with NBT.
It's very useful if several datapacks have the same advancement and that this one should be obtained if the player picks up specifics item available in all these datapacks.
For example, all items in these datapacks have the following custom_data data goldenEnchantedBook:1b :
Then with only one same advancement in all datapacks ...
... it will be granted for all items that have at least the goldenEnchantedBook custom data value to 1!