From ac7dc2d2d57d203d9bf41c99ea02c86c9c5076cc Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 27 Oct 2026 10:10:18 +0100 Subject: [PATCH] Use Mth.floor instead of int casts for TechHider coordinates (int) truncates toward zero, so negative coordinates were checked against the wrong block. Matches the server's block position math. --- .../src/de/steamwar/techhider/TechHider.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java index dc9f5b5c..eee198e6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java @@ -21,13 +21,12 @@ package de.steamwar.techhider; import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer; import com.comphenix.tinyprotocol.TinyProtocol; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.shorts.ShortArraySet; import it.unimi.dsi.fastutil.shorts.ShortSets; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.network.PacketListener; +import net.minecraft.util.Mth; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.common.*; import net.minecraft.network.protocol.configuration.ClientboundFinishConfigurationPacket; @@ -295,9 +294,9 @@ public class TechHider { processors.put(ClientboundExplodePacket.class, (access, rawPacket) -> { ClientboundExplodePacket packet = (ClientboundExplodePacket) rawPacket; Vec3 pos = packet.center(); - int blockX = (int) pos.x; - int blockY = (int) pos.y; - int blockZ = (int) pos.z; + int blockX = Mth.floor(pos.x); + int blockY = Mth.floor(pos.y); + int blockZ = Mth.floor(pos.z); return proccessPositionBasedPacket(access, blockX, blockY, blockZ, packet); @@ -365,7 +364,7 @@ public class TechHider { } private Packet processAddEntityPacket(ForPlayer access, ClientboundAddEntityPacket packet) { - if (access.canAccessEntity(packet.getId()) && access.canAccessPosition((int) packet.getX(), (int) packet.getY(), (int) packet.getZ())) { + if (access.canAccessEntity(packet.getId()) && access.canAccessPosition(Mth.floor(packet.getX()), Mth.floor(packet.getY()), Mth.floor(packet.getZ()))) { return packet; } else { return null; @@ -511,9 +510,9 @@ public class TechHider { } private Packet processLevelParticlesPacket(ForPlayer access, ClientboundLevelParticlesPacket packet) { - int blockX = (int) packet.getX(); - int blockY = (int) packet.getY(); - int blockZ = (int) packet.getZ(); + int blockX = Mth.floor(packet.getX()); + int blockY = Mth.floor(packet.getY()); + int blockZ = Mth.floor(packet.getZ()); if (access.canAccessPosition(blockX, blockY, blockZ)) { return packet;