Consider the following advancement:
{
"criteria": {
"test": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [ {
"item": "minecraft:stone",
"count": 0
} ]
}
}
},
"rewards": { "experience": 1 }
}
If we follow the logic, whenever a player's inventory is changed, if they don't have any stone in it, they should be granted 1 exp point.
But what is happening is that the advancement is never triggered. The behavior is the same if we put "max" to 0 for the count.
This is a bug, since this logic can be achieved with the following advancement, meaning that the "inventory_changed" trigger is properly triggered when you remove the last of a certain item from your inventory:
{
"criteria": {
"test": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"player": [ {
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": { "nbt": "{ Inventory: [ { id: 'minecraft:stone' } ] }" }
}
} ]
}
}
},
"rewards": { "experience": 1 }
}
But this is not as flexible as the "items" condition approach (for example item tags are not available), it is heavier to process, and it is very ugly.
I included a small data pack to quickly test if the bug is fixed: when your inventory changes, if you have no stone in it, you get a message saying which method triggered the advancement (item or NBT).
Attachments
Comments 3
How the hell is it "working as intended" ?
It's totally legit to check if a player doesn't have an item anymore in their inventory: for example you can refill some blocks when they have used all.
There is a workaround to achieve the same behavior but with a lot more complicated and resource consuming method, so why not let the possibility to do it with the simplier, more resource friendly one?
This is not logic: 0 is a possible count for an item, for example by running «
execute store result storage test count int 1 run clear @s minecraft:stone 0
» you may get a value of 0.
I understand that it may not be very urgent, but why just reject it?
By the way, I didn't receive an email saying that the ticket was closed while I'm surveying it.
can confirm in 21w11a