This commit is contained in:
fullwall 2015-09-11 20:13:30 +08:00
parent dd37eb25d3
commit 44e1ea4af6

View File

@ -47,13 +47,16 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
Collections.sort(nearby, new Comparator<Entity>() { Collections.sort(nearby, new Comparator<Entity>() {
@Override @Override
public int compare(Entity o1, Entity o2) { public int compare(Entity o1, Entity o2) {
if (npcLocation.getWorld() != o1.getLocation().getWorld() || npcLocation.getWorld() != o2.getLocation().getWorld()) {
return -1;
}
double d1 = o1.getLocation().distanceSquared(npcLocation); double d1 = o1.getLocation().distanceSquared(npcLocation);
double d2 = o2.getLocation().distanceSquared(npcLocation); double d2 = o2.getLocation().distanceSquared(npcLocation);
return Double.compare(d1, d2); return Double.compare(d1, d2);
} }
}); });
for (Entity entity : nearby) { for (Entity entity : nearby) {
if (entity.getType() != EntityType.PLAYER) if (entity.getType() != EntityType.PLAYER || entity.getLocation().getWorld() != npcLocation.getWorld())
continue; continue;
if (CitizensAPI.getNPCRegistry().getNPC(entity) != null) if (CitizensAPI.getNPCRegistry().getNPC(entity) != null)
continue; continue;