Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4697

PlayerInteractEvent#hasItem returns false for shovel

XMLWordPrintable

    • git-Spigot-f09662d-7c395d4
    • Yes

      It is really weird:

      PlayerInteractEvent#hasItem returns false for stone shovel while Material#STONE_SHOVEL#isItem returns true. See my code for clearer understanding.

      if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || !e.hasBlock() || !e.hasItem())

      { new DebugMessage("Event cancelled because of no right-click/block/item"); #fired if (e.hasBlock()) new DebugMessage("Event got block!"); #fired if (e.hasItem()) new DebugMessage("Event got item!"); #did not fire if (Material.STONE_SHOVEL.isItem()) new DebugMessage("Stone_Shovel is item!"); #fired }

       

      I added comments on which fired and which not (new DebugMessage is just a console message)

       

      Please note that this bug persists for all other shovel types.

       

            Unassigned Unassigned
            alex_qp Alex Kingston
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: