Solved Get a nearby player and launch it in the air ?

Discussion in 'Plugin Development' started by chikenlitle99, Aug 4, 2014.

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

    chikenlitle99

    Hi, how i get a nearby player and launch it in the air, i don't have idea about how do this :'(
     
  2. Offline

    Bobit

    Getting a nearby player should be easy, just go through the list of players, then find which ones are "nearby" a certain location.
    Launching them into the air requires use of vectors, which are complicated, but if you want them to just stop moving and shoot straight up, this will work fine:
    Code:java
    1. p.setVelocity(new Vector(0, 0.4*theApproximateHeightInJumpsYouWantThemToGoUp, 0));
    2.  
     
  3. Offline

    chikenlitle99

    ok, "Getting a nearby player"
     
  4. Offline

    KaitouKidFTW

    Code:java
    1. player.getNearbyEntities(5D, 5D, 5D);
     
  5. Offline

    DevilMental

    chikenlitle99
    To launch a player/entity nearby in the air, use :
    Code:java
    1.  
    2. for (Entity entity : player.getNearbyEntities(5D, 5D, 5D)){
    3. entity.setVelocity(new Vector(0.0, 1.5, 0.0));
    4. }
    5.  

    It can work with players and entities.
     
  6. Offline

    chikenlitle99

  7. Offline

    Bobit

    Note that that will launch every nearby entity within a 5 block radius.
     
  8. DevilMental Please don't spoon feed, this guy clearly wanted code and wasn't looking for help.
     
  9. Offline

    Bobit

    What about what I did? I gave him half the code, because getting into vectors really wouldn't help him that much (i still don't understand them fully), but getting the players was something he needed to be able to figure out on his own.
     
  10. Bobit Yours was not so bad, although I don't really think vectors are too difficult to understand. :p
     
  11. Offline

    Bobit

    Thing I don't get about them, is how something like:
    new Vector(0, 1, 1) works. I originally assumed it was the same as new Vector(0, 0.5, 0.5) but with more power, but after seeing my fireballs curve instead of change direction, I'm not so sure.
     
Thread Status:
Not open for further replies.

Share This Page