Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Kadioshi, May 12, 2015.
How would I make a compass that checks where the nearest Player is? Not entity?
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
Either you use Entity#getNearbyEntities or World#getEntities and loop through the list.
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. ; (
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..
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
in case there are 2 players, loop through all of them and check who has the shortest distance [getDistanceSquared()]