PlayerInteractEvent - Is right click air with not item in hand not work on purpose?

Discussion in 'Plugin Development' started by NonameSL, Jul 11, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    NonameSL

    I did a few testing and found out that Action.RIGHT_CLICK_AIR is only called whenever a player right clicks air with an item in hand.

    Is this on purpose?How can I call a RIGHT_CLICK_AIR PlayerInteractEvent when a player has no item in hand?
     
  2. Offline

    quentin27230

    Code:java
    1. <your variable Player>.getInventory().getItemInHand().getType().getId() == 0)
     
  3. Offline

    NonameSL

    quentin27230 Nope. Fun fact - I did some research, and apperantly the problem is in line 837 in NetServerHandler:
    Code:
     ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
            boolean flag = false;
            int i = par1Packet15Place.getXPosition();
            int j = par1Packet15Place.getYPosition();
            int k = par1Packet15Place.getZPosition();
            int l = par1Packet15Place.getDirection();
     
            if (par1Packet15Place.getDirection() == 255)
            {
                if (itemstack == null) //<--- LOOK! ITS HERE!
                {
                    return;
                }
     
                // CraftBukkit start
                int itemstackAmount = itemstack.stackSize;
                org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.playerEntity, org.bukkit.event.block.Action.RIGHT_CLICK_AIR, itemstack);
    As you can seem ItemStack itemstack is the current item that the player is holding. and in line 837 it says if(itemstack==null){return;}
    And that is not good. Dammit bukkit team, Y U NO CHANGE THAT? There were two changing requests in atlassasin.bukkit.org.
     
  4. Offline

    Niknea

    NonameSL just add an of statement checking the item. I've done it several times.
     
  5. Offline

    NonameSL

    Niknea NOPE, because as you can see in the NetServerHandler.java, the returning of the void if the itemstack is null is called before calling the event.
     
Thread Status:
Not open for further replies.

Share This Page