Ejecting and launching a passenger

Discussion in 'Plugin Development' started by AstramG, Aug 23, 2013.

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

    AstramG

    Hello, I'm trying to eject and launch the passenger of player. However, it doesn't appear to be working, everything is being issued and there are no errors in the console, here is my code.
    Code:
    if (ss.ironGolems.contains(player.getName())) {
                if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
                    if (player.getPassenger() != null) {
                        player.setPassenger(null);
                        player.getPassenger().setVelocity(player.getLocation().getDirection().multiply(1.8)); //Customizable distance
                    }
                }
            }
     
  2. Offline

    The_Doctor_123

    You need to eject the passenger from the vehicle.

    Code:
    boolean wasPlayerRiding = someEntity.eject();
    // Ejects rider if there is one.
    
     
  3. Offline

    AstramG

  4. Offline

    The_Doctor_123

    XD No problem. Just saw the method one day when looking through the API. Comes in handy to find random junk..
     
  5. Offline

    AstramG

    This still doesn't seem to be working though
    Code:
    if (ss.ironGolems.contains(player.getName())) {
                if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
                    if (player.getPassenger() != null) {
                        player.getPassenger().eject();
                        player.getPassenger().setVelocity(player.getLocation().getDirection().multiply(1.8)); //Customizable distance
                    }
                }
            }
     
  6. Offline

    The_Doctor_123

    Yeah, you need to eject the player from the VEHICLE not the rider. J:
     
  7. Offline

    AstramG

    The_Doctor_123 Even more fail. I can't code after midnight, I'm not a rebel like that. D:
     
Thread Status:
Not open for further replies.

Share This Page