[CLOSED, intended, no workaround] PlayerInteractEvent not firing on right click air?

Discussion in 'Spigot Plugin Development' started by OxKitsune, Apr 25, 2017.

Thread Status:
Not open for further replies.
  1. Hey, I'm using this code in a PlayerInteractEvent
    Code (Text):
    if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
        if(e.getHand() == EquipmentSlot.HAND){
           //Do stuff
        }
    }
    And whenever I try to right click air (without an item in my hand, it does with an item in my hand) it doesn't fire, it does fire when I right click a block. I did some research and found on the spigot JIRA that this is because the client doesn't send a packet to spigot when you right click air without an item in your hand. Is this true? If so, is there a workaround?

    EDIT: Source (thanks to @WAS)
     
    #1 OxKitsune, Apr 25, 2017
    Last edited: Apr 25, 2017
  2. WAS

    WAS

    Right click air is like a fake action lol. If you are facing a direction of air that goes on for a long while, right click air won't register. Lol Problem I have with my bandages plugin. Can't heal if looking off into sky or nothing. Gotta look at the ground or a wall.. Lol I'm not sure how the Action.RIGHT_CLICK_AIR works, but it doesn't work as you'd assume.
     
  3. It does when you have an item in your hand, so I thought it might be possible without an item.
     
  4. WAS

    WAS

    Well that's odd, does it work with a left click, like an attack?
     
  5. Yes, it works for everything except rightclick air >.<
    EDIT: Take a look at this:
     
  6. WAS

    WAS

    Yeah I see that here too. Thinking on it I don't know how you would get a workaround for this.
     
  7. That's where I got it, I'll try to find a workaround and post it here if I find one.
     
  8. I have also heard that It might be due to it being cancelled as soon as it triggers. So maybe a Ignorecancelled=false in the eventhandler annotation may help.
     
  9. NathanWolf

    Supporter

    The client does not send anything to the server when right-clicking on air without an item in your hand. Don't think you'll find a work-around, sorry :(
     
  10. I'll try this now and I'll post back results.
     
  11. Nope not working ;_;
     
  12. Okay, I thought so, I'll close the thread now.
     
Thread Status:
Not open for further replies.