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

"hasitem" doesn't check items in the cursor, unlike /clear

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.20.10.20 Preview, 1.20.10
    • 1.18.20.23 Beta, 1.18.20.21 Beta, 1.18.31
    • None
    • Confirmed
    • Windows
    • 719644

      Background

      When the player is rearranging their inventory, they can pick up an item onto the cursor.

      The /clear command, when given a maxCount of zero, doesn't actually clear any items, but instead counts how many items the player has.

      Using /clear in this way includes items that are being held by the cursor.

      The bug

      The new hasitem selector argument does not include items that are being held by the cursor. Therefore, behavior achievable with /clear cannot be replicated using this feature. It is critically important that all use cases of /clear are replicable, because Bedrock is still using the old outdated 1.12-style /execute command that makes it impossible to use /clear in functions.

      How to reproduce

      Create a repeating command block with this command:

      /give @a[hasitem={item=apple,quantity=0}] diamond

      Power it and add an apple to your inventory. Now open your inventory and pick up the apple.
      Expected behavior
      Player doesn't get anymore diamonds, since you have an apple
      Actual behavior
      Player continues getting diamonds so long as the apple is on the cursor

      Notes
      You'll also probably notice annoying ghost apples that appear when you try to place it down. Please fix that too

            tryashtar [Mod] tryashtar
            Votes:
            6 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: