Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-117889

/clear command does not apply the [data] argument correctly


    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.16.220, Beta
    • Beta, 1.16.201 Hotfix
    • None
    • Confirmed
    • Multiple
    • 471822

      Steps to reproduce

      1. /clear
      2. /give @p sapling 1 0
      3. /give @p sapling 1 1
      4. /clear @p sapling 1 1

      Expected result

      You end up with 1 oak sapling in your inventory.

      Actual result

      You end up with 1 spruce sapling in your inventory.


      The /clear command has to do 2 things:
      (1) Determine that the correct item is in the inventory.
      (2) Remove the correct item from the inventory.

      The bug here is that after it correctly performs (1) it ignores the [data] argument when doing (2) and removes the first matching item type that it finds. So, in the reproduction steps above,

      • If you skip step #3 then the command in step #4 will fail, because (1) works correctly.
      • If you run step #3 before step #2 then you will get the expected result and not see the bug, apparently because (2) checks inventory slots in order from first to last.
      • If you select the hotbar slot with the spruce sapling after step #3 (i.e. hold the item in the main hand) then you will get the expected result and not see the bug, apparently because (2) always begins with whatever hotbar slot is currently selected (i.e. with the item held in the main hand), then it proceeds through the hotbar and inventory slots.

      This bug is similar to issues with /clear that were reported in earlier versions but which I cannot reproduce in the current version: MCPE-86111 and MCPE-47378.

            GoldenHelmet [Mod] GoldenHelmet
            4 Vote for this issue
            2 Start watching this issue