forked from SteamWar/SteamWar
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.
This commit is contained in:
@@ -21,13 +21,12 @@ package de.steamwar.techhider;
|
|||||||
|
|
||||||
import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer;
|
import de.steamwar.techhider.AccessPrivilegeProvider.ForPlayer;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
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.ShortArraySet;
|
||||||
import it.unimi.dsi.fastutil.shorts.ShortSets;
|
import it.unimi.dsi.fastutil.shorts.ShortSets;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.SectionPos;
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.network.PacketListener;
|
import net.minecraft.network.PacketListener;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.common.*;
|
import net.minecraft.network.protocol.common.*;
|
||||||
import net.minecraft.network.protocol.configuration.ClientboundFinishConfigurationPacket;
|
import net.minecraft.network.protocol.configuration.ClientboundFinishConfigurationPacket;
|
||||||
@@ -295,9 +294,9 @@ public class TechHider {
|
|||||||
processors.put(ClientboundExplodePacket.class, (access, rawPacket) -> {
|
processors.put(ClientboundExplodePacket.class, (access, rawPacket) -> {
|
||||||
ClientboundExplodePacket packet = (ClientboundExplodePacket) rawPacket;
|
ClientboundExplodePacket packet = (ClientboundExplodePacket) rawPacket;
|
||||||
Vec3 pos = packet.center();
|
Vec3 pos = packet.center();
|
||||||
int blockX = (int) pos.x;
|
int blockX = Mth.floor(pos.x);
|
||||||
int blockY = (int) pos.y;
|
int blockY = Mth.floor(pos.y);
|
||||||
int blockZ = (int) pos.z;
|
int blockZ = Mth.floor(pos.z);
|
||||||
|
|
||||||
|
|
||||||
return proccessPositionBasedPacket(access, blockX, blockY, blockZ, packet);
|
return proccessPositionBasedPacket(access, blockX, blockY, blockZ, packet);
|
||||||
@@ -365,7 +364,7 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Packet<? extends PacketListener> processAddEntityPacket(ForPlayer access, ClientboundAddEntityPacket packet) {
|
private Packet<? extends PacketListener> 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;
|
return packet;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -511,9 +510,9 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Packet<?> processLevelParticlesPacket(ForPlayer access, ClientboundLevelParticlesPacket packet) {
|
private Packet<?> processLevelParticlesPacket(ForPlayer access, ClientboundLevelParticlesPacket packet) {
|
||||||
int blockX = (int) packet.getX();
|
int blockX = Mth.floor(packet.getX());
|
||||||
int blockY = (int) packet.getY();
|
int blockY = Mth.floor(packet.getY());
|
||||||
int blockZ = (int) packet.getZ();
|
int blockZ = Mth.floor(packet.getZ());
|
||||||
|
|
||||||
if (access.canAccessPosition(blockX, blockY, blockZ)) {
|
if (access.canAccessPosition(blockX, blockY, blockZ)) {
|
||||||
return packet;
|
return packet;
|
||||||
|
|||||||
Reference in New Issue
Block a user