Using a loot table to enable an entity to drop a custom-named potion successfully creates the so named potion.
{
"function": "set_name",
"name": {
"text": "Spectral Potion"
}
},{
"function": "set_name",
"name": {
"text": "Spectral Potion"
}
},Then, using an advancement to target said named potion fails to recognize the potion's name and so fails to activate the advancement when consumed.
"criteria": {
"drinkspectralfxn": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"nbt": "{display:{Name:\"Spectral Potion\"}}"
}
}
}
},"criteria": {
"drinkspectralfxn": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"nbt": "{display:{Name:\"Spectral Potion\"}}"
}
}
}
},
Comments 7
Thank you for your helpful reply.
Actually, changing Name to lowercase in the advancement JSON didn't fix it (it works the same lower case or upper case), however...
That suggestion got me experimenting "outside the box" with the criteria conditions syntax, and discovered that the following will trigger the advancement, --but breaks the specificity of the condition. Consuming ANY item with this code triggers the advancement. As is, in 1.13, the Advancement JSON is still unable to successfully use item with nbt tag display name as a condition.
"criteria": {
"drinkspectralfxn2": {
"trigger": "minecraft:consume_item",
"conditions": {
"nbt": "{display:{name:\"Spectral Potion\"}}"
}
}
},"criteria": {
"drinkspectralfxn2": {
"trigger": "minecraft:consume_item",
"conditions": {
"nbt": "{display:{name:\"Spectral Potion\"}}"
}
}
},
I get the feeling that advancement structure is ignoring the Name altogether.
You should throw the item on the ground and /data get its Item.tag.display.Name, you'll see it's mostly likely "{\"text\":\"\Spectral Potion"}" rather than "\"Spectral Potion\"".
I edited my previous comment of 14 minutes ago as the "fix" I posted was in error. The JSON still is still unable to successfully use item with nbt tag display name as a condition.
Replying to [Mod] tryasher's coment, looking with an NBT Editor, the nbt name of the potion is in fact
{"text":"Spectral Potion"}
However, testing for such in the advancement JSON still fails
"criteria": {
"drinkspectralfxn2": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"nbt": "{display:{Name:\"text\":\"Spectral Potion\"}}"
}
}
}
},"criteria": {
"drinkspectralfxn2": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"nbt": "{display:{Name:\"text\":\"Spectral Potion\"}}"
}
}
}
},Also, in naming the potion in the loot table, changing "text": "Spectral Potion" to simply "Spectral Potion" breaks the loot table. It requires that the name include the text specifier.
This doesn't seem to be the intended behavior of Minecraft.
The intended behavior is that users can custom name items, and then use functions to target said items based on name, but the advancement json is unable to target consumed items based on name.
Your latest advancement contains invalid NBT: you're opening the Name tag correctly at the first quotation mark, but are ending the tag prematurely at the second quotation mark (just before the colon). The nested string is also invalid JSON as you are missing opening and closing brackets. As well, nested quotes will need to be escaped further to prevent NBT-based errors:
"nbt": "{display:{Name:\"{\\\"text\\\":\\\"Spectral Potion\\\"}\"}}""nbt": "{display:{Name:\"{\\\"text\\\":\\\"Spectral Potion\\\"}\"}}"
Name should probably be lower case in the advancement JSON.