Skip to content

Commit

Permalink
Update some of upstream and add more verbose logging to PacketOrder c…
Browse files Browse the repository at this point in the history
…hecks
  • Loading branch information
Axionize committed Dec 28, 2024
1 parent b939ba5 commit 306c0f9
Show file tree
Hide file tree
Showing 22 changed files with 423 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;

import java.util.ArrayDeque;

@CheckData(name = "PacketOrderE", experimental = true)
public class PacketOrderE extends Check implements PostPredictionCheck {
public PacketOrderE(final GrimPlayer player) {
super(player);
}

private int invalid;
private final ArrayDeque<String> flags = new ArrayDeque<>();
private boolean setback;

@Override
Expand All @@ -30,9 +32,17 @@ public void onPacketReceive(PacketReceiveEvent event) {
|| player.packetOrderProcessor.isStartingToGlide()
|| player.packetOrderProcessor.isJumpingWithMount()
) {
if (player.canSkipTicks() || flagAndAlert()) {
invalid++;

String verbose = "attacking=" + player.packetOrderProcessor.isAttacking()
+ ", rightClicking=" + player.packetOrderProcessor.isRightClicking()
+ ", openingInventory=" + player.packetOrderProcessor.isOpeningInventory()
+ ", releasing=" + player.packetOrderProcessor.isReleasing()
+ ", sneaking=" + player.packetOrderProcessor.isSneaking()
+ ", sprinting=" + player.packetOrderProcessor.isSprinting()
+ ", bed=" + player.packetOrderProcessor.isLeavingBed()
+ ", sprinting=" + player.packetOrderProcessor.isSprinting()
+ ", gliding=" + player.packetOrderProcessor.isStartingToGlide()
+ ", mountJumping=" + player.packetOrderProcessor.isJumpingWithMount();
if (player.canSkipTicks() && flags.add(verbose) || flagAndAlert(verbose)) {
if (player.packetOrderProcessor.isUsing()) {
setback = true;
}
Expand All @@ -51,15 +61,16 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
return;
}

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
for (; invalid >= 1; invalid--) {
if (flagAndAlert() && setback) {
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
if (flagAndAlert(verbose) && setback) {
setback = false;
setbackIfAboveSetbackVL();
}
}
}

invalid = 0;
setback = false;
flags.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;

import java.util.ArrayDeque;

@CheckData(name = "PacketOrderF", experimental = true)
public class PacketOrderF extends Check implements PostPredictionCheck {
public PacketOrderF(GrimPlayer player) {
super(player);
}

private int invalid;
private final ArrayDeque<String> flags = new ArrayDeque<>();

@Override
public void onPacketReceive(PacketReceiveEvent event) {
Expand All @@ -29,8 +31,16 @@ public void onPacketReceive(PacketReceiveEvent event) {
|| (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS
&& new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT)
) if (player.packetOrderProcessor.isSprinting() || player.packetOrderProcessor.isSneaking()) {
String verbose = "action=" + (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY ? "interact"
: event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT ? "place"
: event.getPacketType() == PacketType.Play.Client.USE_ITEM ? "use"
: event.getPacketType() == PacketType.Play.Client.PICK_ITEM ? "pick"
: event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING ? "dig"
: "openInventory")
+ ", sprinting=" + player.packetOrderProcessor.isSprinting()
+ ", sneaking=" + player.packetOrderProcessor.isSneaking();
if (!player.canSkipTicks()) {
if (flagAndAlert() && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING
&& new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.RELEASE_USE_ITEM
) return; // don't cause a noslow
Expand All @@ -39,7 +49,7 @@ && new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.RELEAS
player.onPacketCancel();
}
} else {
invalid++;
flags.add(verbose);
}
}
}
Expand All @@ -48,12 +58,12 @@ && new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.RELEAS
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
}

invalid = 0;
flags.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;

import java.util.ArrayDeque;

@CheckData(name = "PacketOrderG", experimental = true)
public class PacketOrderG extends Check implements PostPredictionCheck {
public PacketOrderG(GrimPlayer player) {
super(player);
}

private int invalid;
private final ArrayDeque<String> flags = new ArrayDeque<>();

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING
|| (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS
&& new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT)
) {
if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING || (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS
&& new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT)) {
DiggingAction action = null;
if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) {
final DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction();
action = new WrapperPlayClientPlayerDigging(event).getAction();
if (action == DiggingAction.RELEASE_USE_ITEM
|| action == DiggingAction.START_DIGGING
|| action == DiggingAction.CANCELLED_DIGGING
Expand All @@ -40,13 +41,19 @@ && new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClie
|| player.packetOrderProcessor.isPicking()
|| player.packetOrderProcessor.isDigging()
) {
String verbose = "action=" + (action == null ? "openInventory" : action == DiggingAction.SWAP_ITEM_WITH_OFFHAND ? "swap" : "drop")
+ ", attacking=" + player.packetOrderProcessor.isAttacking()
+ ", releasing=" + player.packetOrderProcessor.isReleasing()
+ ", rightClicking=" + player.packetOrderProcessor.isRightClicking()
+ ", picking=" + player.packetOrderProcessor.isPicking()
+ ", digging=" + player.packetOrderProcessor.isDigging();
if (!player.canSkipTicks()) {
if (flagAndAlert() && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
invalid++;
flags.add(verbose);
}
}
}
Expand All @@ -56,12 +63,12 @@ && new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClie
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
}

invalid = 0;
flags.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,42 @@ public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) {
if (player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isPicking() || player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isDigging()) {
String verbose = "type=attack, rightClicking=" + player.packetOrderProcessor.isRightClicking()
+ ", picking=" + player.packetOrderProcessor.isPicking()
+ ", releasing=" + player.packetOrderProcessor.isReleasing()
+ ", digging=" + player.packetOrderProcessor.isDigging();
if (!player.canSkipTicks()) {
if (flagAndAlert("attack") && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add("attack");
flags.add(verbose);
}
}
} else if (player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isDigging()) {
String verbose = "type=interact, releasing=" + player.packetOrderProcessor.isReleasing() + ", digging=" + player.packetOrderProcessor.isDigging();
if (!player.canSkipTicks()) {
if (flagAndAlert("interact") && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add("interact");
flags.add(verbose);
}
}
}

if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) {
if (player.packetOrderProcessor.isReleasing() || digging) {
String verbose = "type=place/use, releasing=" + player.packetOrderProcessor.isReleasing() + ", digging=" + digging;
if (!player.canSkipTicks()) {
if (flagAndAlert("place/use") && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add("place");
flags.add(verbose);
}
}
}
Expand All @@ -73,12 +79,16 @@ public void onPacketReceive(PacketReceiveEvent event) {
switch (packet.getAction()) {
case RELEASE_USE_ITEM:
if (player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isPicking() || player.packetOrderProcessor.isDigging()) {
String verbose = "type=release, attacking=" + player.packetOrderProcessor.isAttacking()
+ ", rightClicking=" + player.packetOrderProcessor.isRightClicking()
+ ", picking=" + player.packetOrderProcessor.isPicking()
+ ", digging=" + player.packetOrderProcessor.isDigging();
if (!player.canSkipTicks()) {
if (flagAndAlert("release")) {
if (flagAndAlert(verbose)) {
setback = true;
}
} else {
flags.add("release");
flags.add(verbose);
setback = true;
}
}
Expand Down Expand Up @@ -112,7 +122,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
return;
}

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
if (flagAndAlert(verbose) && setback) {
setbackIfAboveSetbackVL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@ public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) {
if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) {
if (player.packetOrderProcessor.isClickingInInventory() || player.packetOrderProcessor.isClosingInventory()) {
String verbose = "open, clicking=" + player.packetOrderProcessor.isClickingInInventory() + ", closing=" + player.packetOrderProcessor.isClosingInventory();
if (!player.canSkipTicks()) {
flagAndAlert("open");
flagAndAlert(verbose);
} else {
flags.add("open");
flags.add(verbose);
}
}
}
}

if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) {
if (player.packetOrderProcessor.isOpeningInventory()) {
String verbose = event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close";
if (!player.canSkipTicks()) {
if (flagAndAlert(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close") && shouldModifyPackets()) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close");
flags.add(verbose);
}
}
}
Expand All @@ -51,7 +53,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ && new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ && new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER
public void onPredictionComplete(PredictionComplete predictionComplete) {
if (!player.canSkipTicks()) return;

if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Loading

0 comments on commit 306c0f9

Please sign in to comment.