getLocation

Discussion in 'Plugin Development' started by ProStriker123, Dec 5, 2014.

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

    ProStriker123

    Lol sorry for this question but i forgot how can i spawn the entity behind me?????????????
    final Villager villager = (Villager) online.getLocation().getWorld().spawnEntity(online.getLocation().subtract(5, 5, 5), EntityType.VILLAGER);
     
  2. Offline

    mine-care

    ProStriker123 this will spawn him 5 blocks back, five blocks to the righ/left and 5 blocks under the ground...
    you need to get the direction of the player and add(0,-5,0);
     
  3. mine-care
    I've always wondered: why do people add negative numbers rather than subtracting?
     
  4. Offline

    mine-care

    Assist thats a good questin but for my case there is a good answer as well.
    In the past i worked with a big project that involved spawning stuff behind players front of them on them ect. So i used the add method a lot! i found it handy to use add for negative nums other than subtract so i used it ( big mistake) and by then i pretend like subtract doesnt exist :p
    Also as you can see here:
    http://jd.bukkit.org/rb/doxygen/d4/dd8/Location_8java_source.html
    those two methods are exacly the same when used without a vector object with the only difference that the symbols (- & + ) are different, it is the same method with a slight difference.
    Also as i mentioned above, on that huge project i had to use a +5 on x and -5 on y so instead of xalling add and subtract, i used the add method with negative values. :)
    Hope i solved your question.
     
    Assist likes this.
  5. mine-care
    Well that's a good answer. I know there's no difference to them, I was just wondering why people do it. :p
     
    mine-care likes this.
  6. Offline

    ProStriker123

    send me example i cannot understand it its not works for me
     
  7. Offline

    mine-care

    ProStriker123 hmm, i am not willing to spoonfeed you code...
    But the structure is:
    1. get players location
    2. add what i said in my previus post
    3. spawn the vilager there.
     
  8. Offline

    ProStriker123

    *Facepalm* its not works for meh

    *Bump* I need a NPC that will be behind me and its will move anywhere i look as when he behind me plz halp me surr...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
  9. Offline

    XgXXSnipz

  10. ProStriker123 Please show the code you currently have that's not working.
     
Thread Status:
Not open for further replies.

Share This Page