From d8bace5205d1180e9ee171a4e6add05852eb442f Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Tue, 7 Jun 2022 12:49:08 +0200 Subject: [PATCH] Optimize zero offset --- .../java/org/warp/coordinatesobfuscator/CoordinateOffset.java | 4 ++++ .../org/warp/coordinatesobfuscator/TranslatorServerbound.java | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/org/warp/coordinatesobfuscator/CoordinateOffset.java b/src/main/java/org/warp/coordinatesobfuscator/CoordinateOffset.java index 064c63a..820509e 100644 --- a/src/main/java/org/warp/coordinatesobfuscator/CoordinateOffset.java +++ b/src/main/java/org/warp/coordinatesobfuscator/CoordinateOffset.java @@ -31,6 +31,10 @@ public int getZChunk() { return ((int) z) / 16; } + public boolean isZero() { + return x == 0 && z == 0; + } + public void validate() { if ((int) (Math.round(x / 16f) * 16) != x) { throw new IllegalArgumentException("x is not aligned with the chunks!"); diff --git a/src/main/java/org/warp/coordinatesobfuscator/TranslatorServerbound.java b/src/main/java/org/warp/coordinatesobfuscator/TranslatorServerbound.java index c79f27a..ed5f590 100644 --- a/src/main/java/org/warp/coordinatesobfuscator/TranslatorServerbound.java +++ b/src/main/java/org/warp/coordinatesobfuscator/TranslatorServerbound.java @@ -20,6 +20,9 @@ public static void incoming(Logger logger, final PacketContainer packet, final P } CoordinateOffset offset = PlayerManager.getOffsetOrJoinPlayer(player, player.getWorld()); Objects.requireNonNull(offset); + if (offset.isZero()) { + return; + } switch (packet.getType().name()) { case "POSITION": case "VEHICLE_MOVE":