Solved Detecting when player is passenger of an entity

Discussion in 'Plugin Development' started by TheMintyMate, May 29, 2014.

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

    TheMintyMate

    I have been working on a mess-around plugin which uses the setPassenger() feature. I have come across the need to detect if a player is a passenger of an entity. How do you suggest I go about doing this?
    Thanks for all advise,
    - Minty
     
  2. Offline

    metalhedd

    Code:text
    1.  
    2. if (player.getVehicle() == null) {
    3. // player is not riding anything
    4. } else {
    5. // player is riding the entity returned by player.getVehicle()
    6. }
    7.  
     
    TheMintyMate likes this.
  3. Offline

    TheMintyMate

    metalhedd
    Am I wrong in thinking that getVehicle() refers to stuff like mine carts?
    Thanks :)
    - Minty
     
  4. Offline

    metalhedd

    getVehicle() returns whatever the entity is riding, whether it's a minecart or a pig, doesn't matter.
     
  5. Offline

    TheMintyMate

Thread Status:
Not open for further replies.

Share This Page