Skip to content

Commit

Permalink
better BadPackets E & R support for 1.21.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Dec 4, 2024
1 parent 130f9e1 commit d67b470
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit d67b470

Please sign in to comment.