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

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


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


      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

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

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