Mojira Archive
MC-217290

Advancement inventory_changed with item count of 0

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).

Works As Intended

AHL

2021-02-28, 03:27 AM

2021-05-20, 01:29 PM

2021-05-06, 11:02 AM

1

2

Community Consensus

21w08b - 21w18a21w08b, 21w10a, 21w11a, 21w14a, 21w15a, 21w17a, 21w18a

-