Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public Horse getHorseDistance(Player p) {
  2.  
  3. double distance = Double.MAX_VALUE;
  4. Horse h = null;
  5.  
  6. for (Entity entity : p.getNearbyEntities(100, 100, 100)) {
  7. if (entity instanceof Horse) {
  8. double dis = p.getLocation().distance(entity.getLocation());
  9. if (dis < distance) {
  10. distance = dis;
  11. h = (Horse) entity;
  12. }
  13. }
  14. }
  15. return h;
  16. }
  17.  
  18.  
  19.  
  20.  
  21. //Narchicht
  22.  
  23. CraftHorse{variant=HORSE,owner=CraftPlayer{name=Anzy02}}
  24.  
  25. //
  26. int blocks = (int) p.getLocation().distance(getHorseDistance(p).getLocation());
  27. p.sendMessage("§cDein Pferd befindet sich §a" + getHorseDistance(p) + ((blocks == 1) ? " Block" : " Blöcke") + " §centfernt von dir!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement