Action.RIGHT_CLICK_AIR not working in 1.7.2

Discussion in 'Plugin Development' started by Zach_1919, Dec 9, 2013.

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

    Zach_1919

    I am developing a plugin where a player needs to right click in order to make something happen. I would like them to be able to right click wherever they please, whether it be on a block or in the air. My if statement looks like this:
    Code:java
    1. if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))

    It is strange because I have used this in numerous plugins in the past. Right now, it only works to right click the block. If I right click air, it doesn't do anything. Help?
     
  2. Offline

    NathanWolf

    That might be a bug- you could probably work around it for now by also checking for the CLICK_BLOCK events, and seeing the if block is an air block.

    I assume this works because my plugin still has functional right-clicks, but I think I also check for blocks (and allow right-click on any non-interactive block)
     
  3. Offline

    theEvilReaper

    @EventHandler
    public void RightClick(PlayerInteractEvent e){
    Player p = e.getPlayer();
    if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.LEFT_CLICK_BLOCK)) {

    so works it on my server in my plugin
     
  4. Offline

    Zach_1919

  5. Offline

    Twisted_Panda

  6. Offline

    AoH_Ruthless

    Actually, it's not. Notice he uses ==, while you use .equals(). Try switching them.
     
  7. Offline

    Zach_1919

    Twisted_Panda Yep I registered it.

    AoH_Ruthless Yeah sorry I have actually tried both and both come to the same result:

    I have found that with nothing in your hand, right clicking a block works, and right clicking air doesn't. With something in your hand, though, both work.
     
  8. Offline

    Twisted_Panda

    Full code please.
     
  9. Offline

    AoH_Ruthless

    Zach_1919
    Never mind, I was being dumb. Either operand works; can we see your whole event?
     
  10. Offline

    Twisted_Panda

    Zach_1919
    try this
    Code:
    Action a = e.getAction();
    if (a == Action.RIGHT_CLICK_BLOCK || a == Action.RIGHT_CLICK_AIR) {
     
  11. Offline

    AoH_Ruthless

    Twisted_Panda
    I already mentioned that. He said it made no difference.
    Also I tested it, but == and .equals() function the same (at least for what I was doing)
     
  12. Offline

    bob7

    I get the same thing. It seems the player needs something in his hands in order to fire the Right_click_Air event.
     
  13. Offline

    Windy Day

    Yeah, I think the client doesn't send anything to the server if they right click air without something in their hands.
     
  14. Offline

    Twisted_Panda

    Wait you're trying air?
     
Thread Status:
Not open for further replies.

Share This Page