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

You can't detect an air item in "hasitem" on main hand, but you can replace your slot with air.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.20.1 Hotfix
    • None
    • Creative
    • Unconfirmed
    • Multiple

      Fixing air to "hasitem" will resolve the problem.
      1. Hold any item like DIRT on your main hand and do the "/replaceitem entity @p slot.weapon.mainhand 1 air" command;
      2. It should replace your dirt slot with air or make it an empty slot.
      3. But when you do the "/testfor @p [hasitem=\{item=air,location=slot.weapon.mainhand}]" command;
      4. It won't detect you even if your main hand slot is empty or air.
      5. Please resolve this issue as I believe there are a lot of players out there figuring out how to detect when a player does not have an item on their main hand.

      Edit: Ignore the "\" next to the "[hasitem=" It's just a bug that keeps coming back whenever I remove it.

        1. 1.png
          1.png
          81 kB
        2. 2.png
          2.png
          94 kB

            xDanielMC xDanielMC
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: