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

Inventory_changed advancement trigger captures intermediate inventory states

XMLWordPrintable

    • Confirmed
    • (Unassigned)

      Because the inventory_changed advancement reward is given so fast (more frequently than once per tick), it can capture intermediate inventory states when a player moves an item within their inventory. Hopefully, the explanation below provides a thorough explanation.

      STEPS TO RECREATE:

      1. Place a shulker_box in your world at 0 0 0 and replace your first hotbar slot with an item (with the rest of your inventory being clear).
      2. Create an advancement with the inventory_changed advancement trigger which rewards a function that prints a message to the chat and removes the advancement.
        say inventory changed
        advancement revoke @s only [advancement]
        
      1. Open your inventory and move the item to a different slot in the hotbar.

      The "inventory changed" message will be printed to the chat twice instead of once.

      ANALYSIS:

      When the function file is then replaced with one that merges the player's inventory into the shulker box 

      data modify block 0 0 0 Items set from entity @s Inventory  

      and repeat step 3 we notice that there are two items in the shulker box instead of one. One item is in the starting slot before the inventory change and the other is in the destination slot. The advancement function reward is triggering so fast that it is capturing a state of the inventory where the item in the initial slot is not yet updated. This is likely why the advancement triggers twice in the earlier demonstration. The first trigger captures the inventory change associated with moving the item in the initial slot to the destination slot, and the final trigger captures the inventory change associated with updating the initial slot.

       

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

              Created:
              Updated: