From be861b6bbf0cd8fb5f881670149c73b3dffef6a2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 13:57:30 +0100 Subject: [PATCH] Fix packet stuff --- src/de/steamwar/lobby/display/NPC.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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; }