Arrow Teleportation

Discussion in 'Plugin Development' started by CoderRevolq, Apr 12, 2014.

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

    CoderRevolq

    How do I make it so when I shoot a bow, whereever it lands, it tp's the user to that location. Example I have a bow in my inventory, I shoot it at a wall and when the arrow hits I get teleported to that, please help!
     
  2. Offline

    Gater12

    CoderRevolq
    Listen for ProjectileHitEvent -> Check if it's an arrow and the shooter is a player -> Teleport player to the projectile's location.
     
  3. Offline

    CoderRevolq

    Gater12 Can you go more in depth on how to do it? Like how to check if the projectile hits and all that?
     
  4. Offline

    ImDeJay

    CoderRevolq

    I dont have the time right now, but i will in the morning, but i can help you with this

    i've already made a plugin that does exactly what you want, when you shoot an arrow, when it lands the player is teleported to that location

    so if no body has answered you by in the morning ill help you in depth.
     
  5. Offline

    Konkz

    Minermax7 likes this.
  6. Offline

    ShearsSheep

    Code:java
    1. if (projectile instanceof Arrow) {
    2. Arrow a = (Arrow) projectile;
    3. if (arrow.getShooter() instanceof Player) {
    4. Player p = (Player) a.getShooter();
    5.  
    6. p.teleport(arrow);

    I'm pretty sure that's about it. And its
    Code:java
    1. ProjectileHitEvent
     
  7. Offline

    FabeGabeMC

  8. Offline

    unon1100

    FabeGabeMC You can use the teleport() method to either teleport(Entity) or teleport(Location)
     
  9. FabeGabeMC Doesn't matter either way. You can teleport entities to locations or other entities. :)
     
  10. Offline

    FabeGabeMC

    unon1100 AdamQpzm okie dokie. Just pointing out. lol but thanks for reminding me that. Mistakes have been made! lol
     
    ShearsSheep and AdamQpzm like this.
Thread Status:
Not open for further replies.

Share This Page