Nearest Player With Compass

Discussion in 'Spigot Plugin Development' started by Kadioshi, May 12, 2015.

  1. How would I make a compass that checks where the nearest Player is? Not entity?
  2. A Player is an entity. ;-) So just check for nearest entities and break out of the loop once you found an entity that is a player
  3. Either you use Entity#getNearbyEntities or World#getEntities and loop through the list.
  4. Yes, be sure to update the lore of the compass as well.. and just use (nearby entities) that should work.. just note the longer the lore, the harder it is to see for smaller screens. ; (
  5. Totally agreed. Some servers have animated lores to display like a "commercial" of the game which tends to be over sized and most people can't see. My screen is fairly large and it cuts off (due to mojang's stupid lore system) like it all goes to the left which makes it so you can't see it..
  6. D:
    1. use getNearbyEntities() in a for-loop where you increase the radius (maybe by 10 or 20 to make it faster) until the radius contains a Player-Entity
    2. in case there are 2 players, loop through all of them and check who has the shortest distance [getDistanceSquared()]