Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-217290

Advancement inventory_changed with item count of 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 21w08b, 21w10a, 21w11a, 21w14a, 21w15a, 21w17a, 21w18a
    • None
    • Community Consensus

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

            Unassigned Unassigned
            AHL AHL
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: