[Stupid Question] Move Player

Discussion in 'Plugin Development' started by Zero9195, Jan 31, 2011.

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

    Zero9195

    Hi everyone, its me again ;)
    I'm still programming my first plugins, and I have (again) a new problem. I don't know how to move a player, e.g. upwards together with some Blocks. This is the command i tried and it doesn't work. Thanks for helping me out (again)
    Code:
    
    player.getLocation().setY(player.getLocation().getY() + 2 );
    
    Have to go to school now, but if anyone helps me out I will release a first Testversion this evening ;)
    Greetings,
    Zero9195
     
  2. Offline

    BrandRoses

    getLocation() returns a copy of the entity location, to actually have the server update the location you will need to call teleportTo(), for example:
    Code:
    Location loc = player.getLocation();
    loc.setY(loc.getY() + 2);
    player.teleportTo(loc);
    
     
  3. Offline

    robhol

    If you want to teleport to an arbitrary point, the Location constructor takes a World argument, x,y,z (as doubles), and optionally yaw and pitch (also doubles)
     
  4. Offline

    Zero9195

    Ah thank you for help ;)
     
Thread Status:
Not open for further replies.

Share This Page