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

getItemInHand() in BlockPlaceEvent always return the item in the main hand

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Minecraft 1.9
      Spigot version git-Spigot-1a196e1-7 6c0425 (MC: 1.9) (Implementing API version 1.9-R0.1-SNAPSHOT)
      Windows 7 64Bit
      Java 1.8.0_51

      When placing a block, the getItemInHand() method in BlockPlaceEvent event (not in the Player object) always return the item in the main hand, even if the block placed from the off-hand

      Code:

      @EventHandler
      public void onBlockPlace(BlockPlaceEvent e) {
      	System.out.println("onBlockPlace() called");
      	System.out.println("onBlockPlace() item: " + e.getItemInHand().getType());
      }
      

      Result (Sand in off-hand, apple in main hand):
      [23:11:41 INFO]: onBlockPlace() called
      [23:11:41 INFO]: onBlockPlace() item: APPLE

      Result 2 (Sand in off-hand, nothing in main hand):
      [23:12:05 INFO]: onBlockPlace() called
      [23:12:05 INFO]: onBlockPlace() item: AIR

            Thinkofdeath Thinkofname
            turblob tur tur
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: