Solved Teleport player 5 blocks in the direction they are facing

Discussion in 'Plugin Development' started by dragonstar50, Jun 18, 2014.

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

    dragonstar50

    Hello. I am trying to make a pvp plugin and for one of the kits I am making I am having trouble with setting up it's ability. I feel pretty stupid because teleportation is generally a basic thing in bukkit but I am having trouble with this. So what I am trying to do is make it so that when a player right clicks on their gunpowder it teleports them 5 blocks in the direction they are facing. The only part i'm having trouble with is the teleportation so if anyone knows how to do this then please help. Thanks for your time!
     
  2. Offline

    THEREDBARON24

    You could use a block iterator. make sure that you use the player's location however instead of the player itself, otherwise, you will be using the eye location. get block in the loop that is 5 blocks away (can be accomplished with a counter) make sure to break from the loop, get the location of the block, and teleport.
     
  3. Offline

    Zupsub

    Try this one:
    Code:java
    1.  
    2. Location loc = player.getLocation();
    3. Vector dir = loc.getDirection();
    4. dir.normalize();
    5. dir.multiply(5); //5 blocks a way
    6. loc.add(dir);
    7. player.teleport(loc);
    8.  
     
  4. Offline

    dragonstar50

    Zupsub
    yup that works! Thanks a ton =D
     
Thread Status:
Not open for further replies.

Share This Page