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

"/item" has odd replacement behavior on players in Creative if triggered from an "inventory_changed" advancement

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21.2 Pre-Release 3, 1.21.3
    • None
    • Confirmed
    • Creative
    • Advancements, Commands
    • Low
    • Platform

      Description:
      In the following situation:

      • A "/item" command (that modifies slot X) is contained within a reward function of an "inventory_changed" criteria advancement.
      • Slot X is changed on a player that has their inventory open and is in creative mode, triggering said advancement.

      The original item change on slot X that triggered the advancement overrides the modification made by the "/item" command (even though, logically, the "/item" command happens after, and should affect the final item).

      Furthermore, if the reward function of said advancement contains a command to revoke the same advancement and the same situation occurs:
      For as long as the player stays in creative and keeps their inventory open: The item generated by the "/item" command and the item from the inventory original change will "fight" repeatedly in slot X. Once the player exits creative mode or their inventory, the item generated by the "/item" command will finally occupy slot X.

      To Reproduce:

      1. Create a world with the attached datapack.
      2. Attempt to put any item from the creative inventory in the first hotbar slot.
      3. Observe that the slot rapidly switches between a slimeball and the item placed in the slot until you exit your inventory.

      The attached datapack contains the advancement 'example:inv_change' which triggers on inventory change, and has the following reward function:

      execute unless items entity @s hotbar.0 slime_ball run item replace entity @s hotbar.0 with slime_ball[item_name='{"text":"example"}']
      advancement revoke @s only example:inv_change

      A video is attached demonstrating the bug behavior.

      Note:
      If the "/item" command is replaced with "/clear", the item in the first hotbar slot is simply cleared as what is logically expected.

        1. Minecraft 2024.10.27 - 14.36.33.05.mp4
          8.78 MB
          Ryan Taylor

            Unassigned Unassigned
            GlobbyLikesSlime Ryan Taylor
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              CHK: