diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 39c7dc1..58b49ee 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -161,6 +161,9 @@ public class NPC { } public void setLocation(Location location) { + if (isSimilarLocation(location)) { + return; + } this.location = location; byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); headRotationYaw.set(headRotation, yaw); @@ -175,6 +178,25 @@ public class NPC { display.setLocation(location); } + private boolean isSimilarLocation(Location location) { + if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) { + return false; + } + if (Location.normalizePitch(this.location.getPitch()) != Location.normalizePitch(location.getPitch())) { + return false; + } + if (Math.abs(this.location.getX() - location.getX()) > 0.1) { + return false; + } + if (Math.abs(this.location.getY() - location.getY()) > 0.1) { + return false; + } + if (Math.abs(this.location.getZ() - location.getZ()) > 0.1) { + return false; + } + return true; + } + public Location getLocation() { return location; }