From d67b470ff6f0605c69c700ae6faba8dbf59d03c6 Mon Sep 17 00:00:00 2001 From: AoElite <20812471+AoElite@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:00:12 -0500 Subject: [PATCH] better BadPackets E & R support for 1.21.2+ --- .../ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java | 5 +++-- .../ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java | 5 ++--- src/main/java/ac/grim/grimac/player/GrimPlayer.java | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java index 6459b22b4d..03071493c4 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java @@ -6,6 +6,7 @@ import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "BadPacketsE") @@ -23,8 +24,8 @@ public void onPacketReceive(PacketReceiveEvent event) { noReminderTicks = 0; } else if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { noReminderTicks++; - } else if (event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE || - event.getPacketType() == PacketType.Play.Client.VEHICLE_MOVE) { + } else if (event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE + || (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_2) && player.inVehicle())) { noReminderTicks = 0; // Exempt vehicles } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java index 79b86e4909..d9ac8e12ff 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java @@ -41,9 +41,8 @@ public void onPacketReceive(final PacketReceiveEvent event) { if ((event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION || event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION) && !player.compensatedEntities.getSelf().inVehicle()) { positions++; - } else if ((event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE || - event.getPacketType() == PacketType.Play.Client.VEHICLE_MOVE) - && player.compensatedEntities.getSelf().inVehicle()) { + } else if ((event.getPacketType() == PacketType.Play.Client.STEER_VEHICLE || event.getPacketType() == PacketType.Play.Client.VEHICLE_MOVE) + && player.inVehicle()) { positions++; } } diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index 05c8ace8be..a36a5f371c 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -571,6 +571,10 @@ public boolean isTickingReliablyFor(int ticks) { || compensatedEntities.getSelf().inVehicle(); } + public boolean inVehicle() { + return compensatedEntities.getSelf().inVehicle(); + } + public boolean canThePlayerBeCloseToZeroMovement(int ticks) { return (!uncertaintyHandler.lastPointThree.hasOccurredSince(ticks)); }