From 75b0f5c34402096a773c23169198d6ce79af68ec Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Thu, 22 Aug 2024 11:06:28 -0600 Subject: [PATCH 01/52] PacketOrder check catagory --- .../checks/impl/misc/TransactionOrder.java | 16 ---------------- .../PacketOrderA.java} | 8 ++++---- .../PacketOrderB.java} | 8 ++++---- .../PacketOrderC.java} | 8 ++++---- .../checks/impl/packetorder/PacketOrderD.java | 13 +++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 14 ++++++++------ .../java/ac/grim/grimac/player/GrimPlayer.java | 4 ++-- src/main/resources/punishments/de.yml | 10 +--------- src/main/resources/punishments/en.yml | 10 +--------- src/main/resources/punishments/es.yml | 10 +--------- src/main/resources/punishments/fr.yml | 10 +--------- src/main/resources/punishments/it.yml | 10 +--------- src/main/resources/punishments/nl.yml | 10 +--------- src/main/resources/punishments/pt.yml | 10 +--------- src/main/resources/punishments/ru.yml | 10 +--------- src/main/resources/punishments/zh.yml | 10 +--------- 16 files changed, 44 insertions(+), 117 deletions(-) delete mode 100644 src/main/java/ac/grim/grimac/checks/impl/misc/TransactionOrder.java rename src/main/java/ac/grim/grimac/checks/impl/{post/PostCheck.java => packetorder/PacketOrderA.java} (96%) rename src/main/java/ac/grim/grimac/checks/impl/{badpackets/BadPacketsH.java => packetorder/PacketOrderB.java} (92%) rename src/main/java/ac/grim/grimac/checks/impl/{badpackets/BadPacketsM.java => packetorder/PacketOrderC.java} (91%) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/misc/TransactionOrder.java b/src/main/java/ac/grim/grimac/checks/impl/misc/TransactionOrder.java deleted file mode 100644 index f41aee232d..0000000000 --- a/src/main/java/ac/grim/grimac/checks/impl/misc/TransactionOrder.java +++ /dev/null @@ -1,16 +0,0 @@ -package ac.grim.grimac.checks.impl.misc; - -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; -import ac.grim.grimac.player.GrimPlayer; - - -@CheckData(name = "TransactionOrder", experimental = false) -public class TransactionOrder extends Check implements PacketCheck { - - public TransactionOrder(GrimPlayer player) { - super(player); - } - -} diff --git a/src/main/java/ac/grim/grimac/checks/impl/post/PostCheck.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java similarity index 96% rename from src/main/java/ac/grim/grimac/checks/impl/post/PostCheck.java rename to src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index 9806847581..14dbf1c1ba 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/post/PostCheck.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -1,4 +1,4 @@ -package ac.grim.grimac.checks.impl.post; +package ac.grim.grimac.checks.impl.packetorder; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; @@ -24,8 +24,8 @@ import static com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client.*; -@CheckData(name = "Post") -public class PostCheck extends Check implements PacketCheck, PostPredictionCheck { +@CheckData(name = "PacketOrderA") +public class PacketOrderA extends Check implements PacketCheck, PostPredictionCheck { private final ArrayDeque post = new ArrayDeque<>(); // Due to 1.9+ missing the idle packet, we must queue flags // 1.8 clients will have the same logic for simplicity, although it's not needed @@ -33,7 +33,7 @@ public class PostCheck extends Check implements PacketCheck, PostPredictionCheck private boolean sentFlying = false; private int isExemptFromSwingingCheck = Integer.MIN_VALUE; - public PostCheck(GrimPlayer playerData) { + public PacketOrderA(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java similarity index 92% rename from src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsH.java rename to src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java index bdae1e5f35..78b3ee9e07 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java @@ -1,4 +1,4 @@ -package ac.grim.grimac.checks.impl.badpackets; +package ac.grim.grimac.checks.impl.packetorder; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; @@ -11,15 +11,15 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; -@CheckData(name = "BadPacketsH") -public class BadPacketsH extends Check implements PacketCheck { +@CheckData(name = "PacketOrderB") +public class PacketOrderB extends Check implements PacketCheck { // 1.9 packet order: INTERACT -> ANIMATION // 1.8 packet order: ANIMATION -> INTERACT // I personally think 1.8 made much more sense. You swing and THEN you hit! private boolean sentAnimation = player.getClientVersion().isNewerThan(ClientVersion.V_1_8); - public BadPacketsH(final GrimPlayer player) { + public PacketOrderB(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java similarity index 91% rename from src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java rename to src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 5398ebf759..5cfde8bcf9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -1,4 +1,4 @@ -package ac.grim.grimac.checks.impl.badpackets; +package ac.grim.grimac.checks.impl.packetorder; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; @@ -11,9 +11,9 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; -@CheckData(name = "BadPacketsM", experimental = true) -public class BadPacketsM extends Check implements PacketCheck { - public BadPacketsM(final GrimPlayer player) { +@CheckData(name = "PacketOrderC", experimental = true) +public class PacketOrderC extends Check implements PacketCheck { + public PacketOrderC(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java new file mode 100644 index 0000000000..e103e89c98 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java @@ -0,0 +1,13 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.player.GrimPlayer; + +@CheckData(name = "PacketOrderD") +public class PacketOrderD extends Check implements PacketCheck { + public PacketOrderD(GrimPlayer player) { + super(player); + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index c11939ccae..77ea7b4f29 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -15,9 +15,11 @@ import ac.grim.grimac.checks.impl.misc.ClientBrand; import ac.grim.grimac.checks.impl.misc.FastBreak; import ac.grim.grimac.checks.impl.misc.GhostBlockMitigation; -import ac.grim.grimac.checks.impl.misc.TransactionOrder; import ac.grim.grimac.checks.impl.movement.*; -import ac.grim.grimac.checks.impl.post.PostCheck; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderA; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderB; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderC; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderD; import ac.grim.grimac.checks.impl.prediction.DebugHandler; import ac.grim.grimac.checks.impl.prediction.NoFallB; import ac.grim.grimac.checks.impl.prediction.OffsetHandler; @@ -85,12 +87,10 @@ public CheckManager(GrimPlayer player) { .put(BadPacketsE.class, new BadPacketsE(player)) .put(BadPacketsF.class, new BadPacketsF(player)) .put(BadPacketsG.class, new BadPacketsG(player)) - .put(BadPacketsH.class, new BadPacketsH(player)) .put(BadPacketsI.class, new BadPacketsI(player)) .put(BadPacketsJ.class, new BadPacketsJ(player)) .put(BadPacketsK.class, new BadPacketsK(player)) .put(BadPacketsL.class, new BadPacketsL(player)) - .put(BadPacketsM.class, new BadPacketsM(player)) .put(BadPacketsN.class, new BadPacketsN(player)) .put(BadPacketsP.class, new BadPacketsP(player)) .put(BadPacketsQ.class, new BadPacketsQ(player)) @@ -104,7 +104,9 @@ public CheckManager(GrimPlayer player) { .put(BadPacketsY.class, new BadPacketsY(player)) .put(BadPacketsZ.class, new BadPacketsZ(player)) .put(FastBreak.class, new FastBreak(player)) - .put(TransactionOrder.class, new TransactionOrder(player)) + .put(PacketOrderB.class, new PacketOrderB(player)) + .put(PacketOrderC.class, new PacketOrderC(player)) + .put(PacketOrderD.class, new PacketOrderD(player)) .put(NoSlowB.class, new NoSlowB(player)) .put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets .build(); @@ -128,7 +130,7 @@ public CheckManager(GrimPlayer player) { .put(KnockbackHandler.class, new KnockbackHandler(player)) .put(GhostBlockDetector.class, new GhostBlockDetector(player)) .put(Phase.class, new Phase(player)) - .put(PostCheck.class, new PostCheck(player)) + .put(PacketOrderA.class, new PacketOrderA(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index a46e506f11..feb154b6ea 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -7,7 +7,7 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.impl.aim.processor.AimProcessor; import ac.grim.grimac.checks.impl.misc.ClientBrand; -import ac.grim.grimac.checks.impl.misc.TransactionOrder; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderD; import ac.grim.grimac.events.packets.CheckManagerListener; import ac.grim.grimac.manager.*; import ac.grim.grimac.predictionengine.MovementCheckRunner; @@ -338,7 +338,7 @@ public boolean addTransactionResponse(short id) { if (packetTracker != null) packetTracker.setIntervalPackets(packetTracker.getIntervalPackets() - 1); if (skipped > 0 && System.currentTimeMillis() - joinTime > 5000) - checkManager.getPacketCheck(TransactionOrder.class).flagAndAlert("skipped: " + skipped); + checkManager.getPacketCheck(PacketOrderD.class).flagAndAlert("skipped: " + skipped); do { data = transactionsSent.poll(); diff --git a/src/main/resources/punishments/de.yml b/src/main/resources/punishments/de.yml index d8b7460a5a..b3b365c207 100644 --- a/src/main/resources/punishments/de.yml +++ b/src/main/resources/punishments/de.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/en.yml b/src/main/resources/punishments/en.yml index eaf4af6e57..e8aeeed87d 100644 --- a/src/main/resources/punishments/en.yml +++ b/src/main/resources/punishments/en.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/es.yml b/src/main/resources/punishments/es.yml index 8965d5fd4d..71cc928e2b 100644 --- a/src/main/resources/punishments/es.yml +++ b/src/main/resources/punishments/es.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/fr.yml b/src/main/resources/punishments/fr.yml index 09f85f4dc4..fc20ee9b1e 100644 --- a/src/main/resources/punishments/fr.yml +++ b/src/main/resources/punishments/fr.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/it.yml b/src/main/resources/punishments/it.yml index 71bda391eb..b9d742a92b 100644 --- a/src/main/resources/punishments/it.yml +++ b/src/main/resources/punishments/it.yml @@ -27,18 +27,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -60,7 +53,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/nl.yml b/src/main/resources/punishments/nl.yml index a67948eee1..ddf512df21 100644 --- a/src/main/resources/punishments/nl.yml +++ b/src/main/resources/punishments/nl.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/pt.yml b/src/main/resources/punishments/pt.yml index 3dc8bbccee..64b6d577ea 100644 --- a/src/main/resources/punishments/pt.yml +++ b/src/main/resources/punishments/pt.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/ru.yml b/src/main/resources/punishments/ru.yml index 17a5433f1e..9220042c46 100644 --- a/src/main/resources/punishments/ru.yml +++ b/src/main/resources/punishments/ru.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" diff --git a/src/main/resources/punishments/zh.yml b/src/main/resources/punishments/zh.yml index 6093911f8e..6d3af07769 100644 --- a/src/main/resources/punishments/zh.yml +++ b/src/main/resources/punishments/zh.yml @@ -40,18 +40,11 @@ Punishments: - "5:5 [alert]" - "20:20 [webhook]" - "20:20 [proxy]" - Post: - remove-violations-after: 300 - checks: - - "Post" - commands: - - "20:20 [alert]" - - "40:40 [webhook]" - - "40:40 [proxy]" BadPackets: remove-violations-after: 300 checks: - "BadPackets" + - "PacketOrder" - "Crash" commands: - "20:20 [alert]" @@ -73,7 +66,6 @@ Punishments: - "Place" - "Baritone" - "FastBreak" - - "TransactionOrder" commands: - "10:5 [alert]" - "20:10 [webhook]" From 5faad6b3bad647df3f55585f32d5d0431c33e4fb Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Thu, 22 Aug 2024 11:58:23 -0600 Subject: [PATCH 02/52] add PacketOrderE --- .../checks/impl/packetorder/PacketOrderE.java | 71 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 6 +- 2 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java new file mode 100644 index 0000000000..aa07b87bd1 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -0,0 +1,71 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.protocol.player.DiggingAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderE", experimental = true) +public class PacketOrderE extends Check implements PostPredictionCheck { + public PacketOrderE(final GrimPlayer player) { + super(player); + } + + private int invalidSlots = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + flagAndAlert(); + } else { + invalidSlots++; + } + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT + || event.getPacketType() == PacketType.Play.Client.USE_ITEM + || event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY + || event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION + ) { + sent = true; + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); + if (action != DiggingAction.CANCELLED_DIGGING && action != DiggingAction.START_DIGGING && action != DiggingAction.FINISHED_DIGGING) { + sent = true; + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalidSlots >= 1; invalidSlots--) { + flagAndAlert(); + } + } + + invalidSlots = 0; + sent = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 77ea7b4f29..7298f87d4a 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -16,10 +16,7 @@ import ac.grim.grimac.checks.impl.misc.FastBreak; import ac.grim.grimac.checks.impl.misc.GhostBlockMitigation; import ac.grim.grimac.checks.impl.movement.*; -import ac.grim.grimac.checks.impl.packetorder.PacketOrderA; -import ac.grim.grimac.checks.impl.packetorder.PacketOrderB; -import ac.grim.grimac.checks.impl.packetorder.PacketOrderC; -import ac.grim.grimac.checks.impl.packetorder.PacketOrderD; +import ac.grim.grimac.checks.impl.packetorder.*; import ac.grim.grimac.checks.impl.prediction.DebugHandler; import ac.grim.grimac.checks.impl.prediction.NoFallB; import ac.grim.grimac.checks.impl.prediction.OffsetHandler; @@ -131,6 +128,7 @@ public CheckManager(GrimPlayer player) { .put(GhostBlockDetector.class, new GhostBlockDetector(player)) .put(Phase.class, new Phase(player)) .put(PacketOrderA.class, new PacketOrderA(player)) + .put(PacketOrderE.class, new PacketOrderE(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 2e7454de844c936f82be884172084ff8eec7a956 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Thu, 22 Aug 2024 12:38:36 -0600 Subject: [PATCH 03/52] add PacketOrderF --- .../checks/impl/packetorder/PacketOrderF.java | 70 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 71 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java new file mode 100644 index 0000000000..2a268c76ad --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -0,0 +1,70 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderF", experimental = true) +public class PacketOrderF extends Check implements PostPredictionCheck { + public PacketOrderF(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + } + + if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { + WrapperPlayClientEntityAction.Action action = new WrapperPlayClientEntityAction(event).getAction(); + + if (action == WrapperPlayClientEntityAction.Action.STOP_SPRINTING + || action == WrapperPlayClientEntityAction.Action.START_SPRINTING + || action == WrapperPlayClientEntityAction.Action.STOP_SNEAKING + || action == WrapperPlayClientEntityAction.Action.START_SNEAKING + ) { + sent = true; + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + sent = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 7298f87d4a..5893462545 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -129,6 +129,7 @@ public CheckManager(GrimPlayer player) { .put(Phase.class, new Phase(player)) .put(PacketOrderA.class, new PacketOrderA(player)) .put(PacketOrderE.class, new PacketOrderE(player)) + .put(PacketOrderF.class, new PacketOrderF(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 0f10d48519a82b28d441ef6db4a6b66d60ba68a9 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 24 Aug 2024 12:51:48 -0600 Subject: [PATCH 04/52] Add PacketOrderG --- .../checks/impl/packetorder/PacketOrderG.java | 81 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 82 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java new file mode 100644 index 0000000000..1ae93145e9 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -0,0 +1,81 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.protocol.player.DiggingAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderG", experimental = true) +public class PacketOrderG extends Check implements PacketCheck, PostPredictionCheck { + public PacketOrderG(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); + + if (action == DiggingAction.START_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.CANCELLED_DIGGING) { + sent = true; + return; + } + + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (!flagAndAlert()) { + return; + } + + if (shouldModifyPackets() && action != DiggingAction.RELEASE_USE_ITEM) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + + invalid++; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + sent = true; + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (invalid > 0) { + setbackIfAboveSetbackVL(); + } + + invalid = 0; + } else { + if (!player.skippedTickInActualMovement) { + for (; invalid > 0; invalid--) { + if (flagAndAlert()) { + setbackIfAboveSetbackVL(); + } + } + } + + invalid = 0; + sent = false; + } + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 5893462545..db210632b3 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -130,6 +130,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderA.class, new PacketOrderA(player)) .put(PacketOrderE.class, new PacketOrderE(player)) .put(PacketOrderF.class, new PacketOrderF(player)) + .put(PacketOrderG.class, new PacketOrderG(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 4b989a15b600a44e5c5f0f18e80fa644814f9a15 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 11:53:47 -0600 Subject: [PATCH 05/52] Add PacketOrderH --- .../checks/impl/packetorder/PacketOrderH.java | 62 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 63 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java new file mode 100644 index 0000000000..9a91536a5f --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -0,0 +1,62 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderH", experimental = true) +public class PacketOrderH extends Check implements PostPredictionCheck { + public PacketOrderH(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { + switch (new WrapperPlayClientEntityAction(event).getAction()) { + case START_SPRINTING: + case STOP_SPRINTING: + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + flagAndAlert(); + } else { + invalid++; + } + } + break; + case START_SNEAKING: + case STOP_SNEAKING: + sent = true; + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + sent = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index db210632b3..4770d176cb 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -131,6 +131,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderE.class, new PacketOrderE(player)) .put(PacketOrderF.class, new PacketOrderF(player)) .put(PacketOrderG.class, new PacketOrderG(player)) + .put(PacketOrderH.class, new PacketOrderH(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From c06beba53bb629c25014c912ccf2a9cc4615e742 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 12:14:54 -0600 Subject: [PATCH 06/52] Add PacketOrderI --- .../checks/impl/packetorder/PacketOrderI.java | 64 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 65 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java new file mode 100644 index 0000000000..3328544e96 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -0,0 +1,64 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderI", experimental = true) +public class PacketOrderI extends Check implements PostPredictionCheck { + public PacketOrderI(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + switch (new WrapperPlayClientInteractEntity(event).getAction()) { + case ATTACK: + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + break; + case INTERACT_AT: + case INTERACT: + sent = true; + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + sent = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 4770d176cb..ab5d63f5fe 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -132,6 +132,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderF.class, new PacketOrderF(player)) .put(PacketOrderG.class, new PacketOrderG(player)) .put(PacketOrderH.class, new PacketOrderH(player)) + .put(PacketOrderI.class, new PacketOrderI(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 478548254391b8e740abba8577bc245da918bfd9 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 13:49:25 -0600 Subject: [PATCH 07/52] Add PacketOrderJ --- .../checks/impl/packetorder/PacketOrderJ.java | 66 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 67 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java new file mode 100644 index 0000000000..dc25dac42c --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -0,0 +1,66 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderJ", experimental = true) +public class PacketOrderJ extends Check implements PostPredictionCheck { + public PacketOrderJ(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean interact = false; + private boolean attack = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { + attack = true; + } else { + interact = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + if (attack && !interact) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + interact = attack = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + interact = attack = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index ab5d63f5fe..ef65988304 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -133,6 +133,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderG.class, new PacketOrderG(player)) .put(PacketOrderH.class, new PacketOrderH(player)) .put(PacketOrderI.class, new PacketOrderI(player)) + .put(PacketOrderJ.class, new PacketOrderJ(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 99e06d6b3bf83efa8876b9b5ee530721bad818af Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 13:50:19 -0600 Subject: [PATCH 08/52] Update PacketOrderI.java --- .../checks/impl/packetorder/PacketOrderI.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index 3328544e96..f5ddbf66a8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -23,22 +23,19 @@ public PacketOrderI(final GrimPlayer player) { @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { - switch (new WrapperPlayClientInteractEntity(event).getAction()) { - case ATTACK: - if (sent) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (flagAndAlert() && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); - } - } else { - invalid++; + if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); } + } else { + invalid++; } - break; - case INTERACT_AT: - case INTERACT: - sent = true; + } + } else { + sent = true; } } From 0ad3c58496b179ed1f0e970505823aa47113df7d Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 15:05:48 -0600 Subject: [PATCH 09/52] Check digging packets in PacketOrderF --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index 2a268c76ad..d7c2da78fc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -48,6 +48,10 @@ public void onPacketReceive(PacketReceiveEvent event) { } } + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + sent = true; + } + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { sent = false; } From c701b22098365fc88714736cd63243d7db0ffb7c Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 28 Aug 2024 16:24:50 -0600 Subject: [PATCH 10/52] these are already packet checks --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java | 3 +-- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 1 - .../ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java | 1 - .../ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index 14dbf1c1ba..94d8bfcc84 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -2,7 +2,6 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; @@ -25,7 +24,7 @@ import static com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client.*; @CheckData(name = "PacketOrderA") -public class PacketOrderA extends Check implements PacketCheck, PostPredictionCheck { +public class PacketOrderA extends Check implements PostPredictionCheck { private final ArrayDeque post = new ArrayDeque<>(); // Due to 1.9+ missing the idle packet, we must queue flags // 1.8 clients will have the same logic for simplicity, although it's not needed diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index aa07b87bd1..c248dc523e 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -2,7 +2,6 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index d7c2da78fc..32aa9b7f93 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -2,7 +2,6 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index 1ae93145e9..efe0932fa3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -2,7 +2,6 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; @@ -14,7 +13,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderG", experimental = true) -public class PacketOrderG extends Check implements PacketCheck, PostPredictionCheck { +public class PacketOrderG extends Check implements PostPredictionCheck { public PacketOrderG(final GrimPlayer player) { super(player); } From 0bd57102d575bdf8e6cad0c1e87776256f25e593 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 31 Aug 2024 18:51:51 -0600 Subject: [PATCH 11/52] Check entity in PacketOrderC --- .../checks/impl/packetorder/PacketOrderC.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 5cfde8bcf9..937e827970 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -10,6 +10,7 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderC", experimental = true) public class PacketOrderC extends Check implements PacketCheck { @@ -20,10 +21,15 @@ public PacketOrderC(final GrimPlayer player) { // 1.7 players do not send INTERACT_AT, so we cannot check them private final boolean exempt = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10); private boolean sentInteractAt = false; + private int requiredEntity; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY && !exempt) { + if (exempt) { + return; + } + + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event); @@ -43,6 +49,11 @@ public void onPacketReceive(PacketReceiveEvent event) { event.setCancelled(true); player.onPacketCancel(); } + } else if (wrapper.getEntityId() != requiredEntity) { + if (flagAndAlert("Wrong Entity, required=" + requiredEntity + ", entity=" + wrapper.getEntityId()) && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } } sentInteractAt = false; break; @@ -53,9 +64,19 @@ public void onPacketReceive(PacketReceiveEvent event) { player.onPacketCancel(); } } + requiredEntity = wrapper.getEntityId(); sentInteractAt = true; break; } } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { + if (sentInteractAt) { + if (flagAndAlert("Missed Interact (Tick)") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + } } } From 80d33f0f11cd4ab509f439b52c10180e1e8d19dc Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 11:18:49 -0600 Subject: [PATCH 12/52] this packet order is only valid in 1.7 client --- .../grim/grimac/checks/impl/packetorder/PacketOrderG.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index efe0932fa3..b7652fb13c 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -27,8 +27,10 @@ public void onPacketReceive(PacketReceiveEvent event) { DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); if (action == DiggingAction.START_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.CANCELLED_DIGGING) { - sent = true; - return; + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { + sent = true; + return; + } } if (sent) { From a29f7a2807f0dd7fe84a3c8119751e61299a966d Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 11:42:29 -0600 Subject: [PATCH 13/52] nvm it is valid on 1.8 --- .../grim/grimac/checks/impl/packetorder/PacketOrderG.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index b7652fb13c..efe0932fa3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -27,10 +27,8 @@ public void onPacketReceive(PacketReceiveEvent event) { DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); if (action == DiggingAction.START_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.CANCELLED_DIGGING) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { - sent = true; - return; - } + sent = true; + return; } if (sent) { From 487ce68ef65db20a3bd02259fa445299b1a71bb9 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 12:17:46 -0600 Subject: [PATCH 14/52] Add PacketOrderL --- .../checks/impl/packetorder/PacketOrderL.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java new file mode 100644 index 0000000000..cacde379aa --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -0,0 +1,76 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed; +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.WrapperPlayClientPlayerDigging; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderL", experimental = true) +public class PacketOrderL extends Check implements PostPredictionCheck { + public PacketOrderL(final GrimPlayer player) { + super(player); + } + + private int invalid = 0; + private boolean sent = false; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + WrapperPlayClientPlayerDigging packet = new WrapperPlayClientPlayerDigging(event); + + switch (packet.getAction()) { + case START_DIGGING: + if (BlockBreakSpeed.getBlockDamage(player, packet.getBlockPosition()) >= 1) { + return; // can false on insta-break blocks + } + case CANCELLED_DIGGING: + case FINISHED_DIGGING: + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { + return; // valid on 1.7 + } + case RELEASE_USE_ITEM: + sent = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + if (sent) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + sent = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + sent = false; + } +} From ce28bb689ad04e05288c6cc32249153493f9fc82 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 14:36:27 -0600 Subject: [PATCH 15/52] fix some PacketOrderF falses --- .../grim/grimac/checks/impl/packetorder/PacketOrderF.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index 32aa9b7f93..31770a980b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -8,7 +8,9 @@ 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.protocol.player.DiggingAction; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderF", experimental = true) @@ -48,7 +50,10 @@ public void onPacketReceive(PacketReceiveEvent event) { } if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { - sent = true; + DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); + if (action == DiggingAction.START_DIGGING || action == DiggingAction.CANCELLED_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.RELEASE_USE_ITEM) { + sent = true; + } } if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { From 81aa8b8d31c63b85f3b923f3f58a17cc688a58db Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 15:49:21 -0600 Subject: [PATCH 16/52] check ENTITY_ACTION packets in PacketOrderL --- .../grimac/checks/impl/packetorder/PacketOrderL.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index cacde379aa..17d820c0a8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -9,6 +9,8 @@ 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.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @@ -41,6 +43,16 @@ public void onPacketReceive(PacketReceiveEvent event) { } } + if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { + WrapperPlayClientEntityAction.Action action = new WrapperPlayClientEntityAction(event).getAction(); + if (action == WrapperPlayClientEntityAction.Action.START_SNEAKING + || action == WrapperPlayClientEntityAction.Action.STOP_SNEAKING + || action == WrapperPlayClientEntityAction.Action.START_SPRINTING + || action == WrapperPlayClientEntityAction.Action.STOP_SPRINTING) { + sent = true; + } + } + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { if (sent) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { From 93d0c3839352254e9ca9f6a52181652034ee84fa Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 7 Sep 2024 18:20:01 -0600 Subject: [PATCH 17/52] make PacketOrderE setback https://github.com/CCBlueX/LiquidBounce/blob/nextgen/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/blocking/NoSlowBlockingSwitch.kt --- .../checks/impl/packetorder/PacketOrderE.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index c248dc523e..c33182990b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -25,9 +25,7 @@ public PacketOrderE(final GrimPlayer player) { public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { if (sent) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - flagAndAlert(); - } else { + if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) || flagAndAlert()) { invalidSlots++; } } @@ -55,8 +53,14 @@ public void onPacketReceive(PacketReceiveEvent event) { @Override public void onPredictionComplete(PredictionComplete predictionComplete) { - // we don't need to check pre-1.9 players here (no tick skipping) - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (invalidSlots > 0) { + setbackIfAboveSetbackVL(); + } + + invalidSlots = 0; + return; + } if (!player.skippedTickInActualMovement) { for (; invalidSlots >= 1; invalidSlots--) { From 4e69adc548103621d322fdc7e89986a472bd9651 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 13 Sep 2024 19:14:39 -0600 Subject: [PATCH 18/52] exemptBreaking option in PacketOrdlerL --- .../grimac/checks/impl/packetorder/PacketOrderL.java | 12 ++++++++++-- src/main/resources/config/de.yml | 4 ++++ src/main/resources/config/en.yml | 4 ++++ src/main/resources/config/es.yml | 4 ++++ src/main/resources/config/fr.yml | 4 ++++ src/main/resources/config/it.yml | 4 ++++ src/main/resources/config/nl.yml | 4 ++++ src/main/resources/config/pt.yml | 4 ++++ src/main/resources/config/ru.yml | 4 ++++ src/main/resources/config/zh.yml | 4 ++++ 10 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index 17d820c0a8..90bf746b75 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -10,7 +10,6 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @@ -20,6 +19,9 @@ public PacketOrderL(final GrimPlayer player) { super(player); } + // fixes issues with pvp clients + private static boolean exemptBreaking; + private int invalid = 0; private boolean sent = false; @@ -35,7 +37,7 @@ public void onPacketReceive(PacketReceiveEvent event) { } case CANCELLED_DIGGING: case FINISHED_DIGGING: - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { + if (exemptBreaking || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { return; // valid on 1.7 } case RELEASE_USE_ITEM: @@ -85,4 +87,10 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { invalid = 0; sent = false; } + + @Override + public void reload() { + super.reload(); + exemptBreaking = getConfig().getBooleanElse(getConfigName() + ".exemptBreaking", false); + } } diff --git a/src/main/resources/config/de.yml b/src/main/resources/config/de.yml index 29d10af784..6a5001709d 100644 --- a/src/main/resources/config/de.yml +++ b/src/main/resources/config/de.yml @@ -138,6 +138,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # Um wie viel sollen wir die Hitboxen erweitern? 0,0005 sollte 3,0005+ Reichweite erkennen # diff --git a/src/main/resources/config/en.yml b/src/main/resources/config/en.yml index aff61a8f20..85e8cd4967 100644 --- a/src/main/resources/config/en.yml +++ b/src/main/resources/config/en.yml @@ -138,6 +138,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # How much should we expand hitboxes by? 0.0005 should detect 3.0005+ reach # diff --git a/src/main/resources/config/es.yml b/src/main/resources/config/es.yml index b83737e466..4a383dbcd4 100644 --- a/src/main/resources/config/es.yml +++ b/src/main/resources/config/es.yml @@ -143,6 +143,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # Cuanto deberíamos expandir las hit-boxes? 0.0005 debería detectar un reach de 3.0005+ # diff --git a/src/main/resources/config/fr.yml b/src/main/resources/config/fr.yml index 0e1c36c451..45c2761f83 100644 --- a/src/main/resources/config/fr.yml +++ b/src/main/resources/config/fr.yml @@ -139,6 +139,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # De combien devrions-nous agrandir les hitboxes ? Une augmentation de 0,0005 devrait détecter une portée de 3,0005 ou plus. # diff --git a/src/main/resources/config/it.yml b/src/main/resources/config/it.yml index 82926afb77..286d24b923 100644 --- a/src/main/resources/config/it.yml +++ b/src/main/resources/config/it.yml @@ -128,6 +128,10 @@ EntityControl: # Livello di violazione per il controllo entità setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # Limite per rilevare un attacco oltre la distanza massima threshold: 0.0005 diff --git a/src/main/resources/config/nl.yml b/src/main/resources/config/nl.yml index f198782f54..9bcaff687d 100644 --- a/src/main/resources/config/nl.yml +++ b/src/main/resources/config/nl.yml @@ -138,6 +138,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # Met hoeveel moeten we hitboxes uitbreiden? 0.0005 moet 3.0005+ bereik detecteren # diff --git a/src/main/resources/config/pt.yml b/src/main/resources/config/pt.yml index 386bf6d103..23922c12e4 100644 --- a/src/main/resources/config/pt.yml +++ b/src/main/resources/config/pt.yml @@ -141,6 +141,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # Por quanto deve-se expandir as caixas de colisão? 0.0005 deve detectar 3.0005+ de alcance. # diff --git a/src/main/resources/config/ru.yml b/src/main/resources/config/ru.yml index 0cd1bae724..d4e8ab5474 100644 --- a/src/main/resources/config/ru.yml +++ b/src/main/resources/config/ru.yml @@ -139,6 +139,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking: false + Reach: # На сколько мы должны расширить хитбоксы? 0.0005 должно определять 3.0005+ дополнительное достижение # diff --git a/src/main/resources/config/zh.yml b/src/main/resources/config/zh.yml index 01cacd08eb..ffcdd68c85 100644 --- a/src/main/resources/config/zh.yml +++ b/src/main/resources/config/zh.yml @@ -139,6 +139,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderL: + # enable if players are getting flagged for using 1.7 animations mods + exemptBreaking : false + Reach: # 我们应该将碰撞箱扩大多少? 0.0005 应该检测到 3.0005+ reach # From 44f68a3266d237bd38001776af47087cd5dc6cdf Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sun, 15 Sep 2024 19:56:03 -0600 Subject: [PATCH 19/52] Add PacketOrderK --- .../checks/impl/packetorder/PacketOrderK.java | 43 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 44 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java new file mode 100644 index 0000000000..146eb9c86d --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -0,0 +1,43 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +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.wrapper.play.client.WrapperPlayClientClientStatus; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderK", experimental = true) +public class PacketOrderK extends Check implements PacketCheck { + public PacketOrderK(final GrimPlayer player) { + super(player); + } + + private boolean opened, clickedOrClosed; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { + if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { + opened = true; + if (clickedOrClosed) { + flagAndAlert(); + } + } + } + + if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { + clickedOrClosed = true; + if (opened && flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) { + opened = clickedOrClosed = false; + } + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index ef65988304..ae1ac37c8f 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -104,6 +104,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderB.class, new PacketOrderB(player)) .put(PacketOrderC.class, new PacketOrderC(player)) .put(PacketOrderD.class, new PacketOrderD(player)) + .put(PacketOrderK.class, new PacketOrderK(player)) .put(NoSlowB.class, new NoSlowB(player)) .put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets .build(); From 737e6c4cfb604b09d23a67cfe1fc8e8f5379b72a Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Thu, 19 Sep 2024 18:53:03 -0600 Subject: [PATCH 20/52] exemptBreaking -> exempt-breaking --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java | 2 +- src/main/resources/config/de.yml | 2 +- src/main/resources/config/en.yml | 2 +- src/main/resources/config/es.yml | 2 +- src/main/resources/config/fr.yml | 2 +- src/main/resources/config/it.yml | 2 +- src/main/resources/config/nl.yml | 2 +- src/main/resources/config/pt.yml | 2 +- src/main/resources/config/ru.yml | 2 +- src/main/resources/config/zh.yml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index 90bf746b75..dd24245ae5 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -91,6 +91,6 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { @Override public void reload() { super.reload(); - exemptBreaking = getConfig().getBooleanElse(getConfigName() + ".exemptBreaking", false); + exemptBreaking = getConfig().getBooleanElse(getConfigName() + ".exempt-breaking", false); } } diff --git a/src/main/resources/config/de.yml b/src/main/resources/config/de.yml index 6a5001709d..f832da5f69 100644 --- a/src/main/resources/config/de.yml +++ b/src/main/resources/config/de.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # Um wie viel sollen wir die Hitboxen erweitern? 0,0005 sollte 3,0005+ Reichweite erkennen diff --git a/src/main/resources/config/en.yml b/src/main/resources/config/en.yml index 85e8cd4967..380dd5900e 100644 --- a/src/main/resources/config/en.yml +++ b/src/main/resources/config/en.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # How much should we expand hitboxes by? 0.0005 should detect 3.0005+ reach diff --git a/src/main/resources/config/es.yml b/src/main/resources/config/es.yml index 4a383dbcd4..fd1a264cde 100644 --- a/src/main/resources/config/es.yml +++ b/src/main/resources/config/es.yml @@ -145,7 +145,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # Cuanto deberíamos expandir las hit-boxes? 0.0005 debería detectar un reach de 3.0005+ diff --git a/src/main/resources/config/fr.yml b/src/main/resources/config/fr.yml index 45c2761f83..c9fb825e5c 100644 --- a/src/main/resources/config/fr.yml +++ b/src/main/resources/config/fr.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # De combien devrions-nous agrandir les hitboxes ? Une augmentation de 0,0005 devrait détecter une portée de 3,0005 ou plus. diff --git a/src/main/resources/config/it.yml b/src/main/resources/config/it.yml index 286d24b923..54537f8224 100644 --- a/src/main/resources/config/it.yml +++ b/src/main/resources/config/it.yml @@ -130,7 +130,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # Limite per rilevare un attacco oltre la distanza massima diff --git a/src/main/resources/config/nl.yml b/src/main/resources/config/nl.yml index 9bcaff687d..be17757642 100644 --- a/src/main/resources/config/nl.yml +++ b/src/main/resources/config/nl.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # Met hoeveel moeten we hitboxes uitbreiden? 0.0005 moet 3.0005+ bereik detecteren diff --git a/src/main/resources/config/pt.yml b/src/main/resources/config/pt.yml index 23922c12e4..b265e907ad 100644 --- a/src/main/resources/config/pt.yml +++ b/src/main/resources/config/pt.yml @@ -143,7 +143,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # Por quanto deve-se expandir as caixas de colisão? 0.0005 deve detectar 3.0005+ de alcance. diff --git a/src/main/resources/config/ru.yml b/src/main/resources/config/ru.yml index d4e8ab5474..a3fd2cdf31 100644 --- a/src/main/resources/config/ru.yml +++ b/src/main/resources/config/ru.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking: false + exempt-breaking: false Reach: # На сколько мы должны расширить хитбоксы? 0.0005 должно определять 3.0005+ дополнительное достижение diff --git a/src/main/resources/config/zh.yml b/src/main/resources/config/zh.yml index ffcdd68c85..c80350524a 100644 --- a/src/main/resources/config/zh.yml +++ b/src/main/resources/config/zh.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderL: # enable if players are getting flagged for using 1.7 animations mods - exemptBreaking : false + exempt-breaking : false Reach: # 我们应该将碰撞箱扩大多少? 0.0005 应该检测到 3.0005+ reach From 79f1d65713d4da9c916969e9e6a78129c457b51b Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 5 Oct 2024 13:03:51 -0600 Subject: [PATCH 21/52] fix falses --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index c33182990b..ec6a47b752 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -62,7 +62,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { return; } - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalidSlots >= 1; invalidSlots--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index 31770a980b..611d4408d5 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -66,7 +66,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index efe0932fa3..2aa563eabb 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -65,7 +65,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { invalid = 0; } else { - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid > 0; invalid--) { if (flagAndAlert()) { setbackIfAboveSetbackVL(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java index 9a91536a5f..96b0645758 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -50,7 +50,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index f5ddbf66a8..929c9bd0dc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -49,7 +49,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java index dc25dac42c..735eb0f4e8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -54,7 +54,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index dd24245ae5..4754db27ba 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -78,7 +78,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { flagAndAlert(); } From b27cea2385e9430183cb1d17e435dbe3d41f9dca Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Mon, 14 Oct 2024 15:35:36 -0600 Subject: [PATCH 22/52] register PacketOrderL --- src/main/java/ac/grim/grimac/manager/CheckManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index ae1ac37c8f..d15798747e 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -135,6 +135,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderH.class, new PacketOrderH(player)) .put(PacketOrderI.class, new PacketOrderI(player)) .put(PacketOrderJ.class, new PacketOrderJ(player)) + .put(PacketOrderL.class, new PacketOrderL(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 81c550e8349cff744d38dafd8e56313cf7bf90ce Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Mon, 14 Oct 2024 16:19:15 -0600 Subject: [PATCH 23/52] oops --- .../grim/grimac/checks/impl/packetorder/PacketOrderL.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index 4754db27ba..fb4f7c9293 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.packetorder; +import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.PostPredictionCheck; @@ -89,8 +90,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { } @Override - public void reload() { - super.reload(); - exemptBreaking = getConfig().getBooleanElse(getConfigName() + ".exempt-breaking", false); + public void onReload(ConfigManager config) { + exemptBreaking = config.getBooleanElse(getConfigName() + ".exempt-breaking", false); } } From d35d326595193e9f48b513cb6b49640bdc44b2b5 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Tue, 15 Oct 2024 18:17:44 -0600 Subject: [PATCH 24/52] fixes --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java | 1 + .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 937e827970..4e7920913b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -76,6 +76,7 @@ public void onPacketReceive(PacketReceiveEvent event) { event.setCancelled(true); player.onPacketCancel(); } + sentInteractAt = false; } } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index ec6a47b752..fc03f75bf9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -64,7 +64,9 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalidSlots >= 1; invalidSlots--) { - flagAndAlert(); + if (flagAndAlert()) { + setbackIfAboveSetbackVL(); + } } } From 809d26307f73db7513de5adc58d3a30780e21383 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Tue, 15 Oct 2024 18:45:25 -0600 Subject: [PATCH 25/52] more PacketOrderC stuff --- .../checks/impl/packetorder/PacketOrderC.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 4e7920913b..8cd8185a39 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -9,6 +9,7 @@ import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; +import com.github.retrooper.packetevents.protocol.player.InteractionHand; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @@ -22,6 +23,8 @@ public PacketOrderC(final GrimPlayer player) { private final boolean exempt = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10); private boolean sentInteractAt = false; private int requiredEntity; + private InteractionHand requiredHand; + private boolean requiredSneaking; @Override public void onPacketReceive(PacketReceiveEvent event) { @@ -30,10 +33,9 @@ public void onPacketReceive(PacketReceiveEvent event) { } if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + final WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event); - final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event); - - final PacketEntity entity = player.compensatedEntities.entityMap.get(wrapper.getEntityId()); + final PacketEntity entity = player.compensatedEntities.entityMap.get(packet.getEntityId()); // For armor stands, vanilla clients send: // - when renaming the armor stand or in spectator mode: INTERACT_AT + INTERACT @@ -41,30 +43,39 @@ public void onPacketReceive(PacketReceiveEvent event) { // Just exempt armor stands to be safe if (entity != null && entity.getType() == EntityTypes.ARMOR_STAND) return; - switch (wrapper.getAction()) { + final boolean sneaking = packet.isSneaking().orElse(false); + + switch (packet.getAction()) { // INTERACT_AT then INTERACT case INTERACT: if (!sentInteractAt) { - if (flagAndAlert("Missed Interact-At") && shouldModifyPackets()) { + if (flagAndAlert("Skipped Interact-At") && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } - } else if (wrapper.getEntityId() != requiredEntity) { - if (flagAndAlert("Wrong Entity, required=" + requiredEntity + ", entity=" + wrapper.getEntityId()) && shouldModifyPackets()) { + } else if (packet.getEntityId() != requiredEntity || packet.getHand() != requiredHand || sneaking != requiredSneaking) { + String verbose = "requiredEntity=" + requiredEntity + ", entity=" + packet.getEntityId() + + ", requiredHand=" + requiredHand + ", hand=" + packet.getHand() + + ", requiredSneaking=" + requiredSneaking + ", sneaking=" + sneaking; + if (flagAndAlert(verbose) && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } } + sentInteractAt = false; break; case INTERACT_AT: if (sentInteractAt) { - if (flagAndAlert("Missed Interact") && shouldModifyPackets()) { + if (flagAndAlert("Skipped Interact") && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } } - requiredEntity = wrapper.getEntityId(); + + requiredHand = packet.getHand(); + requiredEntity = packet.getEntityId(); + requiredSneaking = sneaking; sentInteractAt = true; break; } @@ -72,11 +83,11 @@ public void onPacketReceive(PacketReceiveEvent event) { if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { if (sentInteractAt) { - if (flagAndAlert("Missed Interact (Tick)") && shouldModifyPackets()) { + sentInteractAt = false; + if (flagAndAlert("Skipped Interact (Tick)") && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } - sentInteractAt = false; } } } From a653e17f3ce256734f74a814cdae4d4a96c55f8c Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 16 Oct 2024 16:31:52 -0600 Subject: [PATCH 26/52] don't cancel the tick --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 8cd8185a39..57c7572026 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -84,10 +84,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { if (sentInteractAt) { sentInteractAt = false; - if (flagAndAlert("Skipped Interact (Tick)") && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); - } + flagAndAlert("Skipped Interact (Tick)"); } } } From ab32f24dc16b7e41907525c4532e63ab1119ada7 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 16 Oct 2024 17:05:52 -0600 Subject: [PATCH 27/52] fix falses --- .../grim/grimac/checks/impl/packetorder/PacketOrderL.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index fb4f7c9293..eddd681028 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -10,6 +10,7 @@ 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.protocol.player.GameMode; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @@ -33,8 +34,9 @@ public void onPacketReceive(PacketReceiveEvent event) { switch (packet.getAction()) { case START_DIGGING: - if (BlockBreakSpeed.getBlockDamage(player, packet.getBlockPosition()) >= 1) { - return; // can false on insta-break blocks + double damage = BlockBreakSpeed.getBlockDamage(player, packet.getBlockPosition()); + if (damage >= 1 || damage <= 0 && player.gamemode == GameMode.CREATIVE) { + return; // can false on insta-break blocks, and unbreakable blocks in creative mode } case CANCELLED_DIGGING: case FINISHED_DIGGING: From cfcf52f33700726d47df5c0a59ff6d48a9128088 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Thu, 7 Nov 2024 19:56:44 -0700 Subject: [PATCH 28/52] rewrite --- .../checks/impl/packetorder/PacketOrderE.java | 17 +-- .../checks/impl/packetorder/PacketOrderF.java | 59 ++++----- .../checks/impl/packetorder/PacketOrderG.java | 71 +++++------ .../checks/impl/packetorder/PacketOrderH.java | 19 +-- .../checks/impl/packetorder/PacketOrderI.java | 103 ++++++++++++--- .../checks/impl/packetorder/PacketOrderJ.java | 21 +--- .../checks/impl/packetorder/PacketOrderK.java | 7 +- .../checks/impl/packetorder/PacketOrderL.java | 68 ++-------- .../packetorder/PacketOrderProcessor.java | 118 ++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + .../ac/grim/grimac/player/GrimPlayer.java | 2 + src/main/resources/config/de.yml | 4 +- src/main/resources/config/en.yml | 4 +- src/main/resources/config/es.yml | 4 +- src/main/resources/config/fr.yml | 4 +- src/main/resources/config/it.yml | 4 +- src/main/resources/config/nl.yml | 4 +- src/main/resources/config/pt.yml | 4 +- src/main/resources/config/ru.yml | 4 +- src/main/resources/config/tr.yml | 4 + src/main/resources/config/zh.yml | 4 +- 21 files changed, 305 insertions(+), 221 deletions(-) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index fc03f75bf9..8f71ed84ed 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -8,8 +8,6 @@ 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.protocol.player.DiggingAction; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderE", experimental = true) @@ -24,28 +22,17 @@ public PacketOrderE(final GrimPlayer player) { @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { - if (sent) { + if (sent || player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isOpeningInventory() || player.packetOrderProcessor.isSwapping() || player.packetOrderProcessor.isDropping() || player.packetOrderProcessor.isReleasing()) { if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) || flagAndAlert()) { invalidSlots++; } } } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT - || event.getPacketType() == PacketType.Play.Client.USE_ITEM - || event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY - || event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION - ) { + if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { sent = true; } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { - DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); - if (action != DiggingAction.CANCELLED_DIGGING && action != DiggingAction.START_DIGGING && action != DiggingAction.FINISHED_DIGGING) { - sent = true; - } - } - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { sent = false; } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index 611d4408d5..92e5012843 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -9,56 +9,40 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.protocol.player.DiggingAction; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderF", experimental = true) public class PacketOrderF extends Check implements PostPredictionCheck { - public PacketOrderF(final GrimPlayer player) { + public PacketOrderF(GrimPlayer player) { super(player); } - private int invalid = 0; - private boolean sent = false; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { - if (sent) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (flagAndAlert() && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); - } - } else { - invalid++; + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY + || event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT + || event.getPacketType() == PacketType.Play.Client.USE_ITEM + || event.getPacketType() == PacketType.Play.Client.PICK_ITEM + || event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING + || (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS + && new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) + ) if (player.packetOrderProcessor.isSprinting() || player.packetOrderProcessor.isSneaking()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING + && new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.RELEASE_USE_ITEM + ) return; // don't cause a noslow + + event.setCancelled(true); + player.onPacketCancel(); } + } else { + invalid++; } } - - if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { - WrapperPlayClientEntityAction.Action action = new WrapperPlayClientEntityAction(event).getAction(); - - if (action == WrapperPlayClientEntityAction.Action.STOP_SPRINTING - || action == WrapperPlayClientEntityAction.Action.START_SPRINTING - || action == WrapperPlayClientEntityAction.Action.STOP_SNEAKING - || action == WrapperPlayClientEntityAction.Action.START_SNEAKING - ) { - sent = true; - } - } - - if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { - DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); - if (action == DiggingAction.START_DIGGING || action == DiggingAction.CANCELLED_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.RELEASE_USE_ITEM) { - sent = true; - } - } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; - } } @Override @@ -73,6 +57,5 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { } invalid = 0; - sent = false; } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index 2aa563eabb..418a268dac 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -9,72 +9,61 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.protocol.player.DiggingAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderG", experimental = true) public class PacketOrderG extends Check implements PostPredictionCheck { - public PacketOrderG(final GrimPlayer player) { + public PacketOrderG(GrimPlayer player) { super(player); } - private int invalid = 0; - private boolean sent = false; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { - DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); - - if (action == DiggingAction.START_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.CANCELLED_DIGGING) { - sent = true; - return; + 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) { + final DiggingAction action = new WrapperPlayClientPlayerDigging(event).getAction(); + if (action == DiggingAction.RELEASE_USE_ITEM + || action == DiggingAction.START_DIGGING + || action == DiggingAction.CANCELLED_DIGGING + || action == DiggingAction.FINISHED_DIGGING + ) return; } - if (sent) { + if (player.packetOrderProcessor.isAttacking() + || player.packetOrderProcessor.isReleasing() + || player.packetOrderProcessor.isRightClicking() + || player.packetOrderProcessor.isPicking() + || player.packetOrderProcessor.isDigging() + ) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (!flagAndAlert()) { - return; - } - - if (shouldModifyPackets() && action != DiggingAction.RELEASE_USE_ITEM) { + if (flagAndAlert() && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } + } else { + invalid++; } - - invalid++; } } - - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { - sent = true; - } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; - } } @Override public void onPredictionComplete(PredictionComplete predictionComplete) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (invalid > 0) { - setbackIfAboveSetbackVL(); - } + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - invalid = 0; - } else { - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { - for (; invalid > 0; invalid--) { - if (flagAndAlert()) { - setbackIfAboveSetbackVL(); - } - } + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); } - - invalid = 0; - sent = false; } + + invalid = 0; } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java index 96b0645758..20f4aa7ec4 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -9,7 +9,6 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderH", experimental = true) public class PacketOrderH extends Check implements PostPredictionCheck { @@ -17,32 +16,23 @@ public PacketOrderH(final GrimPlayer player) { super(player); } - private int invalid = 0; - private boolean sent = false; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { switch (new WrapperPlayClientEntityAction(event).getAction()) { - case START_SPRINTING: - case STOP_SPRINTING: - if (sent) { + case START_SPRINTING, STOP_SPRINTING -> { + if (player.packetOrderProcessor.isSneaking()) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { flagAndAlert(); } else { invalid++; } } - break; - case START_SNEAKING: - case STOP_SNEAKING: - sent = true; + } } } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; - } } @Override @@ -57,6 +47,5 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { } invalid = 0; - sent = false; } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index 929c9bd0dc..26f810edf6 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -1,61 +1,132 @@ package ac.grim.grimac.checks.impl.packetorder; +import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed; 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.protocol.player.GameMode; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; +import java.util.ArrayDeque; + @CheckData(name = "PacketOrderI", experimental = true) public class PacketOrderI extends Check implements PostPredictionCheck { public PacketOrderI(final GrimPlayer player) { super(player); } - private int invalid = 0; - private boolean sent = false; + private boolean exemptDigging; + + private boolean setback; + private boolean digging; // for placing + private final ArrayDeque flags = new ArrayDeque<>(); @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { - if (sent) { + if (player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isPicking() || player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isDigging()) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (flagAndAlert() && shouldModifyPackets()) { + if (flagAndAlert("attack") && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } } else { - invalid++; + flags.add("attack"); + } + } + } else if (player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isDigging()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert("interact") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + flags.add("interact"); + } + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + if (player.packetOrderProcessor.isReleasing() || digging) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert("place/use") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); } + } else { + flags.add("place"); } - } else { - sent = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + WrapperPlayClientPlayerDigging packet = new WrapperPlayClientPlayerDigging(event); + + switch (packet.getAction()) { + case RELEASE_USE_ITEM: + if (player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isPicking() || player.packetOrderProcessor.isDigging()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert("release")) { + setback = true; + if (shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + } else { + flags.add("release"); + setback = true; + } + } + break; + case START_DIGGING: + double damage = BlockBreakSpeed.getBlockDamage(player, packet.getBlockPosition()); + if (damage >= 1 || damage <= 0 && player.gamemode == GameMode.CREATIVE) { + return; + } + case CANCELLED_DIGGING, FINISHED_DIGGING: + if (exemptDigging || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { + return; + } } } if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; + digging = false; } } @Override public void onPredictionComplete(PredictionComplete predictionComplete) { - // we don't need to check pre-1.9 players here (no tick skipping) - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { - for (; invalid >= 1; invalid--) { - flagAndAlert(); + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (setback) { + setbackIfAboveSetbackVL(); + setback = false; + } + } else if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + for (String verbose : flags) { + if (flagAndAlert(verbose) && setback) { + setbackIfAboveSetbackVL(); + setback = false; + } } } - invalid = 0; - sent = false; + flags.clear(); + setback = digging = false; + } + + @Override + public void onReload(ConfigManager config) { + exemptDigging = config.getBooleanElse(getConfigName() + ".exempt-digging", false); } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java index 735eb0f4e8..b4ab513aab 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -8,8 +8,6 @@ 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.WrapperPlayClientInteractEntity; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderJ", experimental = true) public class PacketOrderJ extends Check implements PostPredictionCheck { @@ -17,22 +15,12 @@ public PacketOrderJ(final GrimPlayer player) { super(player); } - private int invalid = 0; - private boolean interact = false; - private boolean attack = false; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { - if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { - attack = true; - } else { - interact = true; - } - } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { - if (attack && !interact) { + if (player.packetOrderProcessor.isAttacking() && !player.packetOrderProcessor.isInteracting()) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { if (flagAndAlert() && shouldModifyPackets()) { event.setCancelled(true); @@ -43,10 +31,6 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - interact = attack = false; - } } @Override @@ -61,6 +45,5 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { } invalid = 0; - interact = attack = false; } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index 146eb9c86d..cd84591461 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -15,13 +15,12 @@ public PacketOrderK(final GrimPlayer player) { super(player); } - private boolean opened, clickedOrClosed; + private boolean clickedOrClosed; @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { - opened = true; if (clickedOrClosed) { flagAndAlert(); } @@ -30,14 +29,14 @@ public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { clickedOrClosed = true; - if (opened && flagAndAlert() && shouldModifyPackets()) { + if (player.packetOrderProcessor.isOpeningInventory() && flagAndAlert() && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } } if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) { - opened = clickedOrClosed = false; + clickedOrClosed = false; } } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index eddd681028..0d936abd03 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -1,19 +1,16 @@ package ac.grim.grimac.checks.impl.packetorder; -import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; -import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed; 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.protocol.player.GameMode; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; +import com.github.retrooper.packetevents.protocol.player.DiggingAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderL", experimental = true) public class PacketOrderL extends Check implements PostPredictionCheck { @@ -21,59 +18,26 @@ public PacketOrderL(final GrimPlayer player) { super(player); } - // fixes issues with pvp clients - private static boolean exemptBreaking; - - private int invalid = 0; - private boolean sent = false; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { - WrapperPlayClientPlayerDigging packet = new WrapperPlayClientPlayerDigging(event); - - switch (packet.getAction()) { - case START_DIGGING: - double damage = BlockBreakSpeed.getBlockDamage(player, packet.getBlockPosition()); - if (damage >= 1 || damage <= 0 && player.gamemode == GameMode.CREATIVE) { - return; // can false on insta-break blocks, and unbreakable blocks in creative mode - } - case CANCELLED_DIGGING: - case FINISHED_DIGGING: - if (exemptBreaking || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { - return; // valid on 1.7 - } - case RELEASE_USE_ITEM: - sent = true; - } - } - - if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { - WrapperPlayClientEntityAction.Action action = new WrapperPlayClientEntityAction(event).getAction(); - if (action == WrapperPlayClientEntityAction.Action.START_SNEAKING - || action == WrapperPlayClientEntityAction.Action.STOP_SNEAKING - || action == WrapperPlayClientEntityAction.Action.START_SPRINTING - || action == WrapperPlayClientEntityAction.Action.STOP_SPRINTING) { - sent = true; + if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { + if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { + if (player.packetOrderProcessor.isDropping() && flagAndAlert("inventory") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } } } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT || event.getPacketType() == PacketType.Play.Client.USE_ITEM) { - if (sent) { - if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (flagAndAlert() && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); - } - } else { + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + if (new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.SWAP_ITEM_WITH_OFFHAND) { + if (player.packetOrderProcessor.isDropping()) { invalid++; } } } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; - } } @Override @@ -83,16 +47,10 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { - flagAndAlert(); + flagAndAlert("swap"); } } invalid = 0; - sent = false; - } - - @Override - public void onReload(ConfigManager config) { - exemptBreaking = config.getBooleanElse(getConfigName() + ".exempt-breaking", false); } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java new file mode 100644 index 0000000000..761d68236e --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -0,0 +1,118 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.protocol.world.BlockFace; +import com.github.retrooper.packetevents.wrapper.play.client.*; +import lombok.Getter; +import org.jetbrains.annotations.Contract; + +@Getter +public final class PacketOrderProcessor extends Check implements PostPredictionCheck { + public PacketOrderProcessor(final GrimPlayer player) { + super(player); + } + + private boolean openingInventory; // only pre 1.9 clients on pre 1.9 servers + private boolean swapping; + private boolean dropping; + private boolean interacting; + private boolean attacking; + private boolean releasing; + private boolean digging; + private boolean sprinting; + private boolean sneaking; + private boolean placing; + private boolean using; + private boolean picking; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { + if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { + openingInventory = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { + attacking = true; + } else { + interacting = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + switch (new WrapperPlayClientPlayerDigging(event).getAction()) { + case SWAP_ITEM_WITH_OFFHAND -> swapping = true; + case DROP_ITEM, DROP_ITEM_STACK -> dropping = true; + case RELEASE_USE_ITEM -> releasing = true; + case FINISHED_DIGGING, CANCELLED_DIGGING, START_DIGGING -> digging = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { + switch (new WrapperPlayClientEntityAction(event).getAction()) { + case START_SPRINTING, STOP_SPRINTING -> sprinting = true; + case STOP_SNEAKING, START_SNEAKING -> sneaking = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + using = true; + } + + if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { + if (new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER) { + using = true; + } else { + placing = true; + } + } + + if (event.getPacketType() == PacketType.Play.Client.PICK_ITEM) { + picking = true; + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + onTick(); + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) { + onTick(); + } + } + + private void onTick() { + openingInventory = false; + swapping = false; + dropping = false; + attacking = false; + interacting = false; + releasing = false; + digging = false; + placing = false; + using = false; + picking = false; + sprinting = false; + sneaking = false; + } + + // PacketOrderI (releasing & attacking & interact) + public boolean hasSentMouseInput() { + return releasing || attacking || picking || digging || isRightClicking(); + } + + @Contract(pure = true) + public boolean isRightClicking() { + return placing || using || interacting; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index d15798747e..22c7663c3d 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -128,6 +128,7 @@ public CheckManager(GrimPlayer player) { .put(KnockbackHandler.class, new KnockbackHandler(player)) .put(GhostBlockDetector.class, new GhostBlockDetector(player)) .put(Phase.class, new Phase(player)) + .put(PacketOrderProcessor.class, player.packetOrderProcessor) .put(PacketOrderA.class, new PacketOrderA(player)) .put(PacketOrderE.class, new PacketOrderE(player)) .put(PacketOrderF.class, new PacketOrderF(player)) diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index feb154b6ea..07e0581992 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -8,6 +8,7 @@ import ac.grim.grimac.checks.impl.aim.processor.AimProcessor; import ac.grim.grimac.checks.impl.misc.ClientBrand; import ac.grim.grimac.checks.impl.packetorder.PacketOrderD; +import ac.grim.grimac.checks.impl.packetorder.PacketOrderProcessor; import ac.grim.grimac.events.packets.CheckManagerListener; import ac.grim.grimac.manager.*; import ac.grim.grimac.predictionengine.MovementCheckRunner; @@ -92,6 +93,7 @@ public class GrimPlayer implements GrimUser { // End manager like classes public Vector clientVelocity = new Vector(); PacketTracker packetTracker; + public final PacketOrderProcessor packetOrderProcessor = new PacketOrderProcessor(this); private long transactionPing = 0; public long lastTransSent = 0; public long lastTransReceived = 0; diff --git a/src/main/resources/config/de.yml b/src/main/resources/config/de.yml index f832da5f69..cd0b136d6b 100644 --- a/src/main/resources/config/de.yml +++ b/src/main/resources/config/de.yml @@ -138,9 +138,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # Um wie viel sollen wir die Hitboxen erweitern? 0,0005 sollte 3,0005+ Reichweite erkennen diff --git a/src/main/resources/config/en.yml b/src/main/resources/config/en.yml index 380dd5900e..4b6cc01ee5 100644 --- a/src/main/resources/config/en.yml +++ b/src/main/resources/config/en.yml @@ -138,9 +138,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # How much should we expand hitboxes by? 0.0005 should detect 3.0005+ reach diff --git a/src/main/resources/config/es.yml b/src/main/resources/config/es.yml index fd1a264cde..486e28d0f6 100644 --- a/src/main/resources/config/es.yml +++ b/src/main/resources/config/es.yml @@ -143,9 +143,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # Cuanto deberíamos expandir las hit-boxes? 0.0005 debería detectar un reach de 3.0005+ diff --git a/src/main/resources/config/fr.yml b/src/main/resources/config/fr.yml index c9fb825e5c..92ff830d28 100644 --- a/src/main/resources/config/fr.yml +++ b/src/main/resources/config/fr.yml @@ -139,9 +139,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # De combien devrions-nous agrandir les hitboxes ? Une augmentation de 0,0005 devrait détecter une portée de 3,0005 ou plus. diff --git a/src/main/resources/config/it.yml b/src/main/resources/config/it.yml index 54537f8224..5d7ded0e92 100644 --- a/src/main/resources/config/it.yml +++ b/src/main/resources/config/it.yml @@ -128,9 +128,9 @@ EntityControl: # Livello di violazione per il controllo entità setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # Limite per rilevare un attacco oltre la distanza massima diff --git a/src/main/resources/config/nl.yml b/src/main/resources/config/nl.yml index be17757642..e89811fd55 100644 --- a/src/main/resources/config/nl.yml +++ b/src/main/resources/config/nl.yml @@ -138,9 +138,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # Met hoeveel moeten we hitboxes uitbreiden? 0.0005 moet 3.0005+ bereik detecteren diff --git a/src/main/resources/config/pt.yml b/src/main/resources/config/pt.yml index b265e907ad..1e498bd25a 100644 --- a/src/main/resources/config/pt.yml +++ b/src/main/resources/config/pt.yml @@ -141,9 +141,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # Por quanto deve-se expandir as caixas de colisão? 0.0005 deve detectar 3.0005+ de alcance. diff --git a/src/main/resources/config/ru.yml b/src/main/resources/config/ru.yml index a3fd2cdf31..3908315dc4 100644 --- a/src/main/resources/config/ru.yml +++ b/src/main/resources/config/ru.yml @@ -139,9 +139,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking: false + exempt-digging: false Reach: # На сколько мы должны расширить хитбоксы? 0.0005 должно определять 3.0005+ дополнительное достижение diff --git a/src/main/resources/config/tr.yml b/src/main/resources/config/tr.yml index 4e5e23c480..de7ee08263 100644 --- a/src/main/resources/config/tr.yml +++ b/src/main/resources/config/tr.yml @@ -138,6 +138,10 @@ TimerVehicle: EntityControl: setbackvl: 25 +PacketOrderI: + # enable if players are getting flagged for using 1.7 animations mods + exempt-digging: false + Reach: # Hitbox'ları ne kadar genişletmeliyiz? 0.0005, 3.0005+ menzili tespit etmelidir # diff --git a/src/main/resources/config/zh.yml b/src/main/resources/config/zh.yml index c80350524a..385076a85b 100644 --- a/src/main/resources/config/zh.yml +++ b/src/main/resources/config/zh.yml @@ -139,9 +139,9 @@ TimerVehicle: EntityControl: setbackvl: 25 -PacketOrderL: +PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-breaking : false + exempt-digging: false Reach: # 我们应该将碰撞箱扩大多少? 0.0005 应该检测到 3.0005+ reach From 5b8741ca469f75f413ece5b709e665bd3c53ec6b Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 8 Nov 2024 11:15:39 -0700 Subject: [PATCH 29/52] use PacketOrderProcessor in PacketOrderK --- .../grimac/checks/impl/packetorder/PacketOrderK.java | 10 +--------- .../impl/packetorder/PacketOrderProcessor.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index cd84591461..eda4559330 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -7,7 +7,6 @@ import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderK", experimental = true) public class PacketOrderK extends Check implements PacketCheck { @@ -15,28 +14,21 @@ public PacketOrderK(final GrimPlayer player) { super(player); } - private boolean clickedOrClosed; - @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { - if (clickedOrClosed) { + if (player.packetOrderProcessor.isClickingInInventory() || player.packetOrderProcessor.isClosingInventory()) { flagAndAlert(); } } } if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { - clickedOrClosed = true; if (player.packetOrderProcessor.isOpeningInventory() && flagAndAlert() && shouldModifyPackets()) { event.setCancelled(true); player.onPacketCancel(); } } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) { - clickedOrClosed = false; - } } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index 761d68236e..e78afa0844 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -30,6 +30,8 @@ public PacketOrderProcessor(final GrimPlayer player) { private boolean placing; private boolean using; private boolean picking; + private boolean clickingInInventory; + private boolean closingInventory; @Override public void onPacketReceive(PacketReceiveEvent event) { @@ -79,6 +81,14 @@ public void onPacketReceive(PacketReceiveEvent event) { picking = true; } + if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { + clickingInInventory = true; + } + + if (event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { + closingInventory = true; + } + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { onTick(); } @@ -104,6 +114,8 @@ private void onTick() { picking = false; sprinting = false; sneaking = false; + clickingInInventory = false; + closingInventory = false; } // PacketOrderI (releasing & attacking & interact) From d14916c59084b2ecfef7b864aa9991fd51d729e7 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 8 Nov 2024 13:10:43 -0700 Subject: [PATCH 30/52] add PacketOrderM --- .../checks/impl/packetorder/PacketOrderM.java | 54 +++++++++++++++++++ .../packetorder/PacketOrderProcessor.java | 30 +++++++---- .../ac/grim/grimac/manager/CheckManager.java | 1 + 3 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java new file mode 100644 index 0000000000..d446705016 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java @@ -0,0 +1,54 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.WrapperPlayClientClickWindow; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.WindowClickType; + +@CheckData(name = "PacketOrderM", experimental = true) +public class PacketOrderM extends Check implements PostPredictionCheck { + public PacketOrderM(final GrimPlayer player) { + super(player); + } + + private int invalid; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { + final WindowClickType clickType = new WrapperPlayClientClickWindow(event).getWindowClickType(); + + if ((clickType == WindowClickType.PICKUP || clickType == WindowClickType.PICKUP_ALL) && player.packetOrderProcessor.isQuickMoveClicking() + || clickType == WindowClickType.QUICK_MOVE && player.packetOrderProcessor.isPickUpClicking()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + } +} diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index e78afa0844..799a862775 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -6,6 +6,7 @@ import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.protocol.world.BlockFace; import com.github.retrooper.packetevents.wrapper.play.client.*; @@ -32,16 +33,20 @@ public PacketOrderProcessor(final GrimPlayer player) { private boolean picking; private boolean clickingInInventory; private boolean closingInventory; + private boolean quickMoveClicking; + private boolean pickUpClicking; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) { + final PacketTypeCommon packetType = event.getPacketType(); + + if (packetType == PacketType.Play.Client.CLIENT_STATUS) { if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { openingInventory = true; } } - if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + if (packetType == PacketType.Play.Client.INTERACT_ENTITY) { if (new WrapperPlayClientInteractEntity(event).getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) { attacking = true; } else { @@ -49,7 +54,7 @@ public void onPacketReceive(PacketReceiveEvent event) { } } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { + if (packetType == PacketType.Play.Client.PLAYER_DIGGING) { switch (new WrapperPlayClientPlayerDigging(event).getAction()) { case SWAP_ITEM_WITH_OFFHAND -> swapping = true; case DROP_ITEM, DROP_ITEM_STACK -> dropping = true; @@ -58,18 +63,18 @@ public void onPacketReceive(PacketReceiveEvent event) { } } - if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { + if (packetType == PacketType.Play.Client.ENTITY_ACTION) { switch (new WrapperPlayClientEntityAction(event).getAction()) { case START_SPRINTING, STOP_SPRINTING -> sprinting = true; case STOP_SNEAKING, START_SNEAKING -> sneaking = true; } } - if (event.getPacketType() == PacketType.Play.Client.USE_ITEM) { + if (packetType == PacketType.Play.Client.USE_ITEM) { using = true; } - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { + if (packetType == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { if (new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER) { using = true; } else { @@ -77,15 +82,20 @@ public void onPacketReceive(PacketReceiveEvent event) { } } - if (event.getPacketType() == PacketType.Play.Client.PICK_ITEM) { + if (packetType == PacketType.Play.Client.PICK_ITEM) { picking = true; } - if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { + if (packetType == PacketType.Play.Client.CLICK_WINDOW) { clickingInInventory = true; + + switch (new WrapperPlayClientClickWindow(event).getWindowClickType()) { + case QUICK_MOVE -> quickMoveClicking = true; + case PICKUP, PICKUP_ALL -> pickUpClicking = true; + } } - if (event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { + if (packetType == PacketType.Play.Client.CLOSE_WINDOW) { closingInventory = true; } @@ -116,6 +126,8 @@ private void onTick() { sneaking = false; clickingInInventory = false; closingInventory = false; + quickMoveClicking = false; + pickUpClicking = false; } // PacketOrderI (releasing & attacking & interact) diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 22c7663c3d..17ccf7a946 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -137,6 +137,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderI.class, new PacketOrderI(player)) .put(PacketOrderJ.class, new PacketOrderJ(player)) .put(PacketOrderL.class, new PacketOrderL(player)) + .put(PacketOrderM.class, new PacketOrderM(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 57ccbe753e755fa9eb9657c5ba30be5dffd7411d Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 8 Nov 2024 13:43:37 -0700 Subject: [PATCH 31/52] revert renaming post --- .../{packetorder/PacketOrderA.java => post/Post.java} | 8 ++++---- src/main/java/ac/grim/grimac/manager/CheckManager.java | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) rename src/main/java/ac/grim/grimac/checks/impl/{packetorder/PacketOrderA.java => post/Post.java} (96%) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java b/src/main/java/ac/grim/grimac/checks/impl/post/Post.java similarity index 96% rename from src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java rename to src/main/java/ac/grim/grimac/checks/impl/post/Post.java index 94d8bfcc84..681317c5d9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/post/Post.java @@ -1,4 +1,4 @@ -package ac.grim.grimac.checks.impl.packetorder; +package ac.grim.grimac.checks.impl.post; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; @@ -23,8 +23,8 @@ import static com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client.*; -@CheckData(name = "PacketOrderA") -public class PacketOrderA extends Check implements PostPredictionCheck { +@CheckData(name = "Post") +public class Post extends Check implements PostPredictionCheck { private final ArrayDeque post = new ArrayDeque<>(); // Due to 1.9+ missing the idle packet, we must queue flags // 1.8 clients will have the same logic for simplicity, although it's not needed @@ -32,7 +32,7 @@ public class PacketOrderA extends Check implements PostPredictionCheck { private boolean sentFlying = false; private int isExemptFromSwingingCheck = Integer.MIN_VALUE; - public PacketOrderA(GrimPlayer playerData) { + public Post(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 17ccf7a946..313602c783 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -17,6 +17,7 @@ import ac.grim.grimac.checks.impl.misc.GhostBlockMitigation; import ac.grim.grimac.checks.impl.movement.*; import ac.grim.grimac.checks.impl.packetorder.*; +import ac.grim.grimac.checks.impl.post.Post; import ac.grim.grimac.checks.impl.prediction.DebugHandler; import ac.grim.grimac.checks.impl.prediction.NoFallB; import ac.grim.grimac.checks.impl.prediction.OffsetHandler; @@ -129,7 +130,7 @@ public CheckManager(GrimPlayer player) { .put(GhostBlockDetector.class, new GhostBlockDetector(player)) .put(Phase.class, new Phase(player)) .put(PacketOrderProcessor.class, player.packetOrderProcessor) - .put(PacketOrderA.class, new PacketOrderA(player)) + .put(Post.class, new Post(player)) .put(PacketOrderE.class, new PacketOrderE(player)) .put(PacketOrderF.class, new PacketOrderF(player)) .put(PacketOrderG.class, new PacketOrderG(player)) From 2fc13af09dd3a04ea79d8f86cc0df4da0d156b68 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 8 Nov 2024 13:44:29 -0700 Subject: [PATCH 32/52] rename PacketOrderM to PacketOrderA --- .../packetorder/{PacketOrderM.java => PacketOrderA.java} | 6 +++--- src/main/java/ac/grim/grimac/manager/CheckManager.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/ac/grim/grimac/checks/impl/packetorder/{PacketOrderM.java => PacketOrderA.java} (92%) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java similarity index 92% rename from src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java rename to src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index d446705016..3618c5a12b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -11,9 +11,9 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.WindowClickType; -@CheckData(name = "PacketOrderM", experimental = true) -public class PacketOrderM extends Check implements PostPredictionCheck { - public PacketOrderM(final GrimPlayer player) { +@CheckData(name = "PacketOrderA", experimental = true) +public class PacketOrderA extends Check implements PostPredictionCheck { + public PacketOrderA(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 313602c783..e19c0cc1cd 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -131,6 +131,7 @@ public CheckManager(GrimPlayer player) { .put(Phase.class, new Phase(player)) .put(PacketOrderProcessor.class, player.packetOrderProcessor) .put(Post.class, new Post(player)) + .put(PacketOrderA.class, new PacketOrderA(player)) .put(PacketOrderE.class, new PacketOrderE(player)) .put(PacketOrderF.class, new PacketOrderF(player)) .put(PacketOrderG.class, new PacketOrderG(player)) @@ -138,7 +139,6 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderI.class, new PacketOrderI(player)) .put(PacketOrderJ.class, new PacketOrderJ(player)) .put(PacketOrderL.class, new PacketOrderL(player)) - .put(PacketOrderM.class, new PacketOrderM(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From 72a0ad53ddfddb461232c4ad7bdc1582ab16e709 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 8 Nov 2024 17:09:08 -0700 Subject: [PATCH 33/52] rename exempt-digging to exempt-placing-while-digging in PAcketOrderI and make it work --- .../grim/grimac/checks/impl/packetorder/PacketOrderI.java | 7 ++++--- src/main/resources/config/de.yml | 2 +- src/main/resources/config/en.yml | 2 +- src/main/resources/config/es.yml | 2 +- src/main/resources/config/fr.yml | 2 +- src/main/resources/config/it.yml | 2 +- src/main/resources/config/nl.yml | 2 +- src/main/resources/config/pt.yml | 2 +- src/main/resources/config/ru.yml | 2 +- src/main/resources/config/tr.yml | 2 +- src/main/resources/config/zh.yml | 2 +- 11 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index 26f810edf6..4bf82b87cc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -23,7 +23,7 @@ public PacketOrderI(final GrimPlayer player) { super(player); } - private boolean exemptDigging; + private boolean exemptPlacingWhileDigging; private boolean setback; private boolean digging; // for placing @@ -94,9 +94,10 @@ public void onPacketReceive(PacketReceiveEvent event) { return; } case CANCELLED_DIGGING, FINISHED_DIGGING: - if (exemptDigging || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { + if (exemptPlacingWhileDigging || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) { return; } + digging = true; } } @@ -127,6 +128,6 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { @Override public void onReload(ConfigManager config) { - exemptDigging = config.getBooleanElse(getConfigName() + ".exempt-digging", false); + exemptPlacingWhileDigging = config.getBooleanElse(getConfigName() + ".exempt-placing-while-digging", false); } } diff --git a/src/main/resources/config/de.yml b/src/main/resources/config/de.yml index cd0b136d6b..e77fc40362 100644 --- a/src/main/resources/config/de.yml +++ b/src/main/resources/config/de.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Um wie viel sollen wir die Hitboxen erweitern? 0,0005 sollte 3,0005+ Reichweite erkennen diff --git a/src/main/resources/config/en.yml b/src/main/resources/config/en.yml index 4b6cc01ee5..c1a9531ee2 100644 --- a/src/main/resources/config/en.yml +++ b/src/main/resources/config/en.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # How much should we expand hitboxes by? 0.0005 should detect 3.0005+ reach diff --git a/src/main/resources/config/es.yml b/src/main/resources/config/es.yml index 486e28d0f6..2ec0496063 100644 --- a/src/main/resources/config/es.yml +++ b/src/main/resources/config/es.yml @@ -145,7 +145,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Cuanto deberíamos expandir las hit-boxes? 0.0005 debería detectar un reach de 3.0005+ diff --git a/src/main/resources/config/fr.yml b/src/main/resources/config/fr.yml index 92ff830d28..ecbf8cf902 100644 --- a/src/main/resources/config/fr.yml +++ b/src/main/resources/config/fr.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # De combien devrions-nous agrandir les hitboxes ? Une augmentation de 0,0005 devrait détecter une portée de 3,0005 ou plus. diff --git a/src/main/resources/config/it.yml b/src/main/resources/config/it.yml index 5d7ded0e92..bd966cd57e 100644 --- a/src/main/resources/config/it.yml +++ b/src/main/resources/config/it.yml @@ -130,7 +130,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Limite per rilevare un attacco oltre la distanza massima diff --git a/src/main/resources/config/nl.yml b/src/main/resources/config/nl.yml index e89811fd55..93648a8fe9 100644 --- a/src/main/resources/config/nl.yml +++ b/src/main/resources/config/nl.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Met hoeveel moeten we hitboxes uitbreiden? 0.0005 moet 3.0005+ bereik detecteren diff --git a/src/main/resources/config/pt.yml b/src/main/resources/config/pt.yml index 1e498bd25a..61adb92769 100644 --- a/src/main/resources/config/pt.yml +++ b/src/main/resources/config/pt.yml @@ -143,7 +143,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Por quanto deve-se expandir as caixas de colisão? 0.0005 deve detectar 3.0005+ de alcance. diff --git a/src/main/resources/config/ru.yml b/src/main/resources/config/ru.yml index 3908315dc4..aa052a24e2 100644 --- a/src/main/resources/config/ru.yml +++ b/src/main/resources/config/ru.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # На сколько мы должны расширить хитбоксы? 0.0005 должно определять 3.0005+ дополнительное достижение diff --git a/src/main/resources/config/tr.yml b/src/main/resources/config/tr.yml index de7ee08263..5934f80cf0 100644 --- a/src/main/resources/config/tr.yml +++ b/src/main/resources/config/tr.yml @@ -140,7 +140,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # Hitbox'ları ne kadar genişletmeliyiz? 0.0005, 3.0005+ menzili tespit etmelidir diff --git a/src/main/resources/config/zh.yml b/src/main/resources/config/zh.yml index 385076a85b..f53383b957 100644 --- a/src/main/resources/config/zh.yml +++ b/src/main/resources/config/zh.yml @@ -141,7 +141,7 @@ EntityControl: PacketOrderI: # enable if players are getting flagged for using 1.7 animations mods - exempt-digging: false + exempt-placing-while-digging: false Reach: # 我们应该将碰撞箱扩大多少? 0.0005 应该检测到 3.0005+ reach From c888256b38ff7770eb315178844aefafda25c10e Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 9 Nov 2024 15:42:06 -0700 Subject: [PATCH 34/52] remove unused method --- .../grimac/checks/impl/packetorder/PacketOrderProcessor.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index 799a862775..53650a1e51 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -130,11 +130,6 @@ private void onTick() { pickUpClicking = false; } - // PacketOrderI (releasing & attacking & interact) - public boolean hasSentMouseInput() { - return releasing || attacking || picking || digging || isRightClicking(); - } - @Contract(pure = true) public boolean isRightClicking() { return placing || using || interacting; From 90c59ad4dfaab9a682299befda6921308cd5d0f7 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 9 Nov 2024 18:27:01 -0700 Subject: [PATCH 35/52] Add PacketOrderM --- .../checks/impl/packetorder/PacketOrderM.java | 72 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 73 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java new file mode 100644 index 0000000000..b7f6d8d898 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java @@ -0,0 +1,72 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.protocol.world.BlockFace; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderM", experimental = true) +public class PacketOrderM extends Check implements PostPredictionCheck { + public PacketOrderM(final GrimPlayer player) { + super(player); + } + + private int invalid; + private boolean usingWithoutInteract, interacting; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { + if (new WrapperPlayClientInteractEntity(event).getAction() != WrapperPlayClientInteractEntity.InteractAction.ATTACK) { + interacting = true; + if (usingWithoutInteract) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + invalid++; + } + } + } + } + + if (event.getPacketType() == PacketType.Play.Client.USE_ITEM + || event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT + && new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER) { + if (!interacting) { + usingWithoutInteract = true; + } + + interacting = false; + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + usingWithoutInteract = interacting = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + usingWithoutInteract = interacting = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index e19c0cc1cd..7752245539 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -139,6 +139,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderI.class, new PacketOrderI(player)) .put(PacketOrderJ.class, new PacketOrderJ(player)) .put(PacketOrderL.class, new PacketOrderL(player)) + .put(PacketOrderM.class, new PacketOrderM(player)) .put(NoFallB.class, new NoFallB(player)) .put(OffsetHandler.class, new OffsetHandler(player)) .put(SuperDebug.class, new SuperDebug(player)) From e9716045651f5b7df8d9a1c9439ed96e4b19eab1 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 9 Nov 2024 20:09:22 -0700 Subject: [PATCH 36/52] add PacketOrderN --- .../checks/impl/packetorder/PacketOrderN.java | 69 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 70 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java new file mode 100644 index 0000000000..c70cd8fc1b --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java @@ -0,0 +1,69 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.BlockPlaceCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.BlockPlace; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; +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.protocol.world.BlockFace; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderN", experimental = true) +public class PacketOrderN extends BlockPlaceCheck { + public PacketOrderN(final GrimPlayer player) { + super(player); + } + + private int invalid; + private boolean usingWithoutPlacing, placing; + + @Override + public void onBlockPlace(BlockPlace place) { + placing = true; + if (usingWithoutPlacing) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert() && shouldModifyPackets() && shouldCancel()) { + place.resync(); + } + } else { + invalid++; + } + } + } + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.USE_ITEM + || event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT + && new WrapperPlayClientPlayerBlockPlacement(event).getFace() == BlockFace.OTHER) { + if (!placing) { + usingWithoutPlacing = true; + } + + placing = false; + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { + usingWithoutPlacing = placing = false; + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement) { + for (; invalid >= 1; invalid--) { + flagAndAlert(); + } + } + + invalid = 0; + usingWithoutPlacing = placing = false; + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 7752245539..e5b9b14c36 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -166,6 +166,7 @@ public CheckManager(GrimPlayer player) { .put(FabricatedPlace.class, new FabricatedPlace(player)) .put(PositionPlace.class, new PositionPlace(player)) .put(RotationPlace.class, new RotationPlace(player)) + .put(PacketOrderN.class, new PacketOrderN(player)) .put(DuplicateRotPlace.class, new DuplicateRotPlace(player)) .put(GhostBlockMitigation.class, new GhostBlockMitigation(player)) .build(); From 22dd1341969f44d0bcb7deb6310ccd6a78d294b3 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 9 Nov 2024 20:11:22 -0700 Subject: [PATCH 37/52] add PacketOrderO and PacketOrderP --- .../checks/impl/packetorder/PacketOrderO.java | 60 ++++++++++++++++++ .../checks/impl/packetorder/PacketOrderP.java | 63 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 2 + 3 files changed, 125 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java create mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java new file mode 100644 index 0000000000..eaad366da1 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java @@ -0,0 +1,60 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.BlockPlaceCheck; +import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.BlockPlace; +import com.github.retrooper.packetevents.PacketEvents; +import com.github.retrooper.packetevents.event.PacketReceiveEvent; +import com.github.retrooper.packetevents.manager.server.ServerVersion; +import com.github.retrooper.packetevents.protocol.player.ClientVersion; +import com.github.retrooper.packetevents.protocol.player.InteractionHand; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderO", experimental = true) +public class PacketOrderO extends BlockPlaceCheck { + public PacketOrderO(final GrimPlayer player) { + super(player); + } + + private boolean sentMainhand; + + @Override + public void onBlockPlace(BlockPlace place) { + if (!isSupported()) { + return; + } + + if (place.getHand() == InteractionHand.OFF_HAND) { + if (!sentMainhand) { + if (flagAndAlert("Skipped Mainhand") && shouldModifyPackets() && shouldCancel()) { + place.resync(); + } + } + + sentMainhand = false; + } else { + if (sentMainhand) { + if (flagAndAlert("Skipped Offhand") && shouldModifyPackets() && shouldCancel()) { + place.resync(); + } + } + + sentMainhand = !place.isBlock(); + } + } + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { + if (sentMainhand) { + sentMainhand = false; + flagAndAlert("Skipped Offhand (Tick)"); + } + } + } + + private boolean isSupported() { + return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java new file mode 100644 index 0000000000..e58f1e7e7d --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java @@ -0,0 +1,63 @@ +package ac.grim.grimac.checks.impl.packetorder; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +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.protocol.player.InteractionHand; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity.InteractAction; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; + +@CheckData(name = "PacketOrderP", experimental = true) +public class PacketOrderP extends Check implements PacketCheck { + public PacketOrderP(final GrimPlayer player) { + super(player); + } + + private boolean sentMainhand; + private int requiredEntity; + private boolean requiredSneaking; + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) { + final WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event); + InteractAction action = packet.getAction(); + if (action != InteractAction.ATTACK) { + final boolean sneaking = packet.isSneaking().orElse(false); + final int entity = packet.getEntityId(); + + if (packet.getHand() == InteractionHand.OFF_HAND) { + if (action == InteractAction.INTERACT) { + if (!sentMainhand) { + if (flagAndAlert("Skipped Mainhand") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + sentMainhand = false; + } else if (sneaking != requiredSneaking || entity != requiredEntity) { + String verbose = "requiredEntity=" + requiredEntity + ", entity=" + entity + + ", requiredSneaking=" + requiredSneaking + ", sneaking=" + sneaking; + if (flagAndAlert(verbose) && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + } else { + requiredEntity = entity; + requiredSneaking = sneaking; + sentMainhand = true; + } + } + } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { + sentMainhand = false; + } + } +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index e5b9b14c36..0ef3aa7f57 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -106,6 +106,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderC.class, new PacketOrderC(player)) .put(PacketOrderD.class, new PacketOrderD(player)) .put(PacketOrderK.class, new PacketOrderK(player)) + .put(PacketOrderP.class, new PacketOrderP(player)) .put(NoSlowB.class, new NoSlowB(player)) .put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets .build(); @@ -167,6 +168,7 @@ public CheckManager(GrimPlayer player) { .put(PositionPlace.class, new PositionPlace(player)) .put(RotationPlace.class, new RotationPlace(player)) .put(PacketOrderN.class, new PacketOrderN(player)) + .put(PacketOrderO.class, new PacketOrderO(player)) .put(DuplicateRotPlace.class, new DuplicateRotPlace(player)) .put(GhostBlockMitigation.class, new GhostBlockMitigation(player)) .build(); From fe4e60c80ca7ab99d61b3130ab496db9f88f0ad3 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 16:45:53 -0700 Subject: [PATCH 38/52] rename invalidSlots to invalid --- .../grimac/checks/impl/packetorder/PacketOrderE.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 8f71ed84ed..953f4c9ccb 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -16,7 +16,7 @@ public PacketOrderE(final GrimPlayer player) { super(player); } - private int invalidSlots = 0; + private int invalid = 0; private boolean sent = false; @Override @@ -24,7 +24,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { if (sent || player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isOpeningInventory() || player.packetOrderProcessor.isSwapping() || player.packetOrderProcessor.isDropping() || player.packetOrderProcessor.isReleasing()) { if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) || flagAndAlert()) { - invalidSlots++; + invalid++; } } } @@ -41,23 +41,23 @@ public void onPacketReceive(PacketReceiveEvent event) { @Override public void onPredictionComplete(PredictionComplete predictionComplete) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (invalidSlots > 0) { + if (invalid > 0) { setbackIfAboveSetbackVL(); } - invalidSlots = 0; + invalid = 0; return; } if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { - for (; invalidSlots >= 1; invalidSlots--) { + for (; invalid >= 1; invalid--) { if (flagAndAlert()) { setbackIfAboveSetbackVL(); } } } - invalidSlots = 0; + invalid = 0; sent = false; } } From 74cca86bb6fbc3cb8d851730658582e128aeb7b8 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:10:13 -0700 Subject: [PATCH 39/52] add remaining entity actions to PacketOrderProcessor --- .../checks/impl/packetorder/PacketOrderProcessor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index 53650a1e51..2ff16f5d46 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -35,6 +35,9 @@ public PacketOrderProcessor(final GrimPlayer player) { private boolean closingInventory; private boolean quickMoveClicking; private boolean pickUpClicking; + private boolean leavingBed; + private boolean startingToGlide; + private boolean jumpingWithMount; @Override public void onPacketReceive(PacketReceiveEvent event) { @@ -67,6 +70,10 @@ public void onPacketReceive(PacketReceiveEvent event) { switch (new WrapperPlayClientEntityAction(event).getAction()) { case START_SPRINTING, STOP_SPRINTING -> sprinting = true; case STOP_SNEAKING, START_SNEAKING -> sneaking = true; + case LEAVE_BED -> leavingBed = true; + case START_FLYING_WITH_ELYTRA -> startingToGlide = true; + case OPEN_HORSE_INVENTORY -> openingInventory = true; + case START_JUMPING_WITH_HORSE, STOP_JUMPING_WITH_HORSE -> jumpingWithMount = true; } } @@ -128,6 +135,9 @@ private void onTick() { closingInventory = false; quickMoveClicking = false; pickUpClicking = false; + leavingBed = false; + startingToGlide = false; + jumpingWithMount = false; } @Contract(pure = true) From b0a5dbd07fb6251e5639adad446de9c3e99aeb48 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:12:40 -0700 Subject: [PATCH 40/52] and use them --- .../checks/impl/packetorder/PacketOrderE.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 953f4c9ccb..4a875ddef1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -22,7 +22,18 @@ public PacketOrderE(final GrimPlayer player) { @Override public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { - if (sent || player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isOpeningInventory() || player.packetOrderProcessor.isSwapping() || player.packetOrderProcessor.isDropping() || player.packetOrderProcessor.isReleasing()) { + if (player.packetOrderProcessor.isAttacking() + || player.packetOrderProcessor.isRightClicking() + || player.packetOrderProcessor.isOpeningInventory() + || player.packetOrderProcessor.isDropping() + || player.packetOrderProcessor.isSwapping() + || player.packetOrderProcessor.isReleasing() + || player.packetOrderProcessor.isSneaking() + || player.packetOrderProcessor.isSprinting() + || player.packetOrderProcessor.isLeavingBed() + || player.packetOrderProcessor.isStartingToGlide() + || player.packetOrderProcessor.isJumpingWithMount() + ) { if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) || flagAndAlert()) { invalid++; } From 93c1c7b4805cf0158fccebb03bd1def92936330a Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:13:15 -0700 Subject: [PATCH 41/52] remove sent variable --- .../grimac/checks/impl/packetorder/PacketOrderE.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 4a875ddef1..0d4c43b4bd 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -17,7 +17,6 @@ public PacketOrderE(final GrimPlayer player) { } private int invalid = 0; - private boolean sent = false; @Override public void onPacketReceive(PacketReceiveEvent event) { @@ -39,14 +38,6 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } - - if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { - sent = true; - } - - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - sent = false; - } } @Override @@ -69,6 +60,5 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { } invalid = 0; - sent = false; } } From be65dc5e517d37dbb27dca79f28930f7e8d78f13 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:13:45 -0700 Subject: [PATCH 42/52] remove invalid variable default --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 0d4c43b4bd..1aa4f3ec87 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -16,7 +16,7 @@ public PacketOrderE(final GrimPlayer player) { super(player); } - private int invalid = 0; + private int invalid; @Override public void onPacketReceive(PacketReceiveEvent event) { From af580c4d4861fb715d6a66e41baec5e58ff4f9e9 Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:14:04 -0700 Subject: [PATCH 43/52] only setback on item use --- .../checks/impl/packetorder/PacketOrderE.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 1aa4f3ec87..fc57a82522 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -8,7 +8,6 @@ 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 = "PacketOrderE", experimental = true) public class PacketOrderE extends Check implements PostPredictionCheck { @@ -17,6 +16,7 @@ public PacketOrderE(final GrimPlayer player) { } private int invalid; + private boolean setback; @Override public void onPacketReceive(PacketReceiveEvent event) { @@ -35,6 +35,10 @@ public void onPacketReceive(PacketReceiveEvent event) { ) { if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) || flagAndAlert()) { invalid++; + + if (player.packetOrderProcessor.isUsing()) { + setback = true; + } } } } @@ -43,17 +47,17 @@ public void onPacketReceive(PacketReceiveEvent event) { @Override public void onPredictionComplete(PredictionComplete predictionComplete) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { - if (invalid > 0) { + if (setback) { + setback = false; setbackIfAboveSetbackVL(); } - - invalid = 0; return; } if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { for (; invalid >= 1; invalid--) { - if (flagAndAlert()) { + if (flagAndAlert() && setback) { + setback = false; setbackIfAboveSetbackVL(); } } From f79e8c12a5f390dec29fa5c03c4407a359144bdb Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:14:31 -0700 Subject: [PATCH 44/52] fix false when dropping items --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index fc57a82522..bfa3589ba9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -24,7 +24,6 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isOpeningInventory() - || player.packetOrderProcessor.isDropping() || player.packetOrderProcessor.isSwapping() || player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isSneaking() From 5254a376c429db10d0f535b8811536d7624751ec Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:14:50 -0700 Subject: [PATCH 45/52] fix false when swapping offhand items --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index bfa3589ba9..0272c9581a 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -24,7 +24,6 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player.packetOrderProcessor.isAttacking() || player.packetOrderProcessor.isRightClicking() || player.packetOrderProcessor.isOpeningInventory() - || player.packetOrderProcessor.isSwapping() || player.packetOrderProcessor.isReleasing() || player.packetOrderProcessor.isSneaking() || player.packetOrderProcessor.isSprinting() From 30a346bd3fa116e7627b7e7139881fe8e0c9aa0e Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sat, 16 Nov 2024 18:29:05 -0700 Subject: [PATCH 46/52] fix a noslow --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index 4bf82b87cc..19eb9b50dc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -77,10 +77,6 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { if (flagAndAlert("release")) { setback = true; - if (shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); - } } } else { flags.add("release"); From 11d856ce0833582482ecbb467fdec609e5beacbe Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sun, 17 Nov 2024 17:25:57 -0700 Subject: [PATCH 47/52] fix falses --- .../checks/impl/packetorder/PacketOrderK.java | 42 ++++++++++++++++--- .../checks/impl/packetorder/PacketOrderL.java | 24 +++++++---- .../ac/grim/grimac/manager/CheckManager.java | 2 +- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index eda4559330..8a6e6f2c15 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -2,33 +2,63 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; 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.WrapperPlayClientClientStatus; +import java.util.ArrayDeque; + @CheckData(name = "PacketOrderK", experimental = true) -public class PacketOrderK extends Check implements PacketCheck { +public class PacketOrderK extends Check implements PostPredictionCheck { public PacketOrderK(final GrimPlayer player) { super(player); } + private final ArrayDeque flags = new ArrayDeque<>(); + @Override 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()) { - flagAndAlert(); + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + flagAndAlert("open"); + } else { + flags.add("open"); + } } } } if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) { - if (player.packetOrderProcessor.isOpeningInventory() && flagAndAlert() && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); + if (player.packetOrderProcessor.isOpeningInventory()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + flags.add(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close"); + } + } + } + } + + @Override + public void onPredictionComplete(PredictionComplete predictionComplete) { + // we don't need to check pre-1.9 players here (no tick skipping) + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; + + if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + for (String verbose : flags) { + flagAndAlert(verbose); } } + + flags.clear(); } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index 0d936abd03..a0a3430017 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -12,21 +12,29 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; +import java.util.ArrayDeque; + @CheckData(name = "PacketOrderL", experimental = true) public class PacketOrderL extends Check implements PostPredictionCheck { public PacketOrderL(final GrimPlayer player) { super(player); } - private int invalid; + private final ArrayDeque flags = new ArrayDeque<>(); @Override 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.isDropping() && flagAndAlert("inventory") && shouldModifyPackets()) { - event.setCancelled(true); - player.onPacketCancel(); + if (player.packetOrderProcessor.isDropping()) { + if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { + if (flagAndAlert("inventory") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } else { + flags.add("inventory"); + } } } } @@ -34,7 +42,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { if (new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.SWAP_ITEM_WITH_OFFHAND) { if (player.packetOrderProcessor.isDropping()) { - invalid++; + flags.add("swap"); } } } @@ -46,11 +54,11 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { - for (; invalid >= 1; invalid--) { - flagAndAlert("swap"); + for (String verbose : flags) { + flagAndAlert(verbose); } } - invalid = 0; + flags.clear(); } } diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 0ef3aa7f57..f476d6e441 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -105,7 +105,6 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderB.class, new PacketOrderB(player)) .put(PacketOrderC.class, new PacketOrderC(player)) .put(PacketOrderD.class, new PacketOrderD(player)) - .put(PacketOrderK.class, new PacketOrderK(player)) .put(PacketOrderP.class, new PacketOrderP(player)) .put(NoSlowB.class, new NoSlowB(player)) .put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets @@ -139,6 +138,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderH.class, new PacketOrderH(player)) .put(PacketOrderI.class, new PacketOrderI(player)) .put(PacketOrderJ.class, new PacketOrderJ(player)) + .put(PacketOrderK.class, new PacketOrderK(player)) .put(PacketOrderL.class, new PacketOrderL(player)) .put(PacketOrderM.class, new PacketOrderM(player)) .put(NoFallB.class, new NoFallB(player)) From aea66feb335ac823e4fb78bda2eb8cb6606962be Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sun, 17 Nov 2024 18:03:13 -0700 Subject: [PATCH 48/52] fix more falses --- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java | 2 +- .../ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index 3618c5a12b..1145b8eae9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -43,7 +43,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 0272c9581a..3d800a9a77 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -52,7 +52,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { return; } - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { if (flagAndAlert() && setback) { setback = false; diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index 92e5012843..e83dc97db6 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -50,7 +50,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index 418a268dac..ee96977935 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -58,7 +58,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java index 20f4aa7ec4..782302c1cf 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -40,7 +40,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index 19eb9b50dc..af6c32511f 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -109,7 +109,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { setbackIfAboveSetbackVL(); setback = false; } - } else if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + } else if (player.isTickingReliablyFor(3)) { for (String verbose : flags) { if (flagAndAlert(verbose) && setback) { setbackIfAboveSetbackVL(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java index b4ab513aab..92e4533cc6 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -38,7 +38,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index 8a6e6f2c15..d607ff35f2 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -53,7 +53,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (String verbose : flags) { flagAndAlert(verbose); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index a0a3430017..1e697e1e16 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -53,7 +53,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) { + if (player.isTickingReliablyFor(3)) { for (String verbose : flags) { flagAndAlert(verbose); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java index b7f6d8d898..9a57f2dbf3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java @@ -60,7 +60,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java index c70cd8fc1b..990cd9646d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java @@ -57,7 +57,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (!player.skippedTickInActualMovement) { + if (player.isTickingReliablyFor(3)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } From 43634772c780d578bcede4ede9f99ea8e0ff82ae Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 20 Nov 2024 16:19:51 -0700 Subject: [PATCH 49/52] remove PacketOrderO depends on too many factors --- .../checks/impl/packetorder/PacketOrderO.java | 60 ------------------- .../ac/grim/grimac/manager/CheckManager.java | 1 - 2 files changed, 61 deletions(-) delete mode 100644 src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java deleted file mode 100644 index eaad366da1..0000000000 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java +++ /dev/null @@ -1,60 +0,0 @@ -package ac.grim.grimac.checks.impl.packetorder; - -import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.BlockPlaceCheck; -import ac.grim.grimac.player.GrimPlayer; -import ac.grim.grimac.utils.anticheat.update.BlockPlace; -import com.github.retrooper.packetevents.PacketEvents; -import com.github.retrooper.packetevents.event.PacketReceiveEvent; -import com.github.retrooper.packetevents.manager.server.ServerVersion; -import com.github.retrooper.packetevents.protocol.player.ClientVersion; -import com.github.retrooper.packetevents.protocol.player.InteractionHand; -import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; - -@CheckData(name = "PacketOrderO", experimental = true) -public class PacketOrderO extends BlockPlaceCheck { - public PacketOrderO(final GrimPlayer player) { - super(player); - } - - private boolean sentMainhand; - - @Override - public void onBlockPlace(BlockPlace place) { - if (!isSupported()) { - return; - } - - if (place.getHand() == InteractionHand.OFF_HAND) { - if (!sentMainhand) { - if (flagAndAlert("Skipped Mainhand") && shouldModifyPackets() && shouldCancel()) { - place.resync(); - } - } - - sentMainhand = false; - } else { - if (sentMainhand) { - if (flagAndAlert("Skipped Offhand") && shouldModifyPackets() && shouldCancel()) { - place.resync(); - } - } - - sentMainhand = !place.isBlock(); - } - } - - @Override - public void onPacketReceive(PacketReceiveEvent event) { - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { - if (sentMainhand) { - sentMainhand = false; - flagAndAlert("Skipped Offhand (Tick)"); - } - } - } - - private boolean isSupported() { - return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9); - } -} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index f476d6e441..19f1f3d9c7 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -168,7 +168,6 @@ public CheckManager(GrimPlayer player) { .put(PositionPlace.class, new PositionPlace(player)) .put(RotationPlace.class, new RotationPlace(player)) .put(PacketOrderN.class, new PacketOrderN(player)) - .put(PacketOrderO.class, new PacketOrderO(player)) .put(DuplicateRotPlace.class, new DuplicateRotPlace(player)) .put(GhostBlockMitigation.class, new GhostBlockMitigation(player)) .build(); From b535b28661852589361a59f0673eea9686c90b3b Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Wed, 20 Nov 2024 16:20:24 -0700 Subject: [PATCH 50/52] rename PacketOrderP to PacketOrderO --- .../impl/packetorder/{PacketOrderP.java => PacketOrderO.java} | 4 ++-- src/main/java/ac/grim/grimac/manager/CheckManager.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/ac/grim/grimac/checks/impl/packetorder/{PacketOrderP.java => PacketOrderO.java} (96%) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java similarity index 96% rename from src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java rename to src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java index e58f1e7e7d..aab11c669d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java @@ -13,8 +13,8 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderP", experimental = true) -public class PacketOrderP extends Check implements PacketCheck { - public PacketOrderP(final GrimPlayer player) { +public class PacketOrderO extends Check implements PacketCheck { + public PacketOrderO(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 19f1f3d9c7..55bf12dbd6 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -105,7 +105,7 @@ public CheckManager(GrimPlayer player) { .put(PacketOrderB.class, new PacketOrderB(player)) .put(PacketOrderC.class, new PacketOrderC(player)) .put(PacketOrderD.class, new PacketOrderD(player)) - .put(PacketOrderP.class, new PacketOrderP(player)) + .put(PacketOrderO.class, new PacketOrderO(player)) .put(NoSlowB.class, new NoSlowB(player)) .put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets .build(); From 56e4fa75bf38463a4cbf8b2471fc21ab585dce2e Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 22 Nov 2024 14:13:32 -0700 Subject: [PATCH 51/52] cleanup imports --- .../ac/grim/grimac/predictionengine/UncertaintyHandler.java | 1 - .../ac/grim/grimac/utils/data/packetentity/PacketEntity.java | 1 - src/main/java/ac/grim/grimac/utils/lists/RunningMode.java | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java index c94220b549..d96d981576 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java +++ b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java @@ -13,7 +13,6 @@ import com.github.retrooper.packetevents.protocol.attribute.Attributes; import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; import com.github.retrooper.packetevents.protocol.world.BlockFace; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import org.bukkit.util.Vector; import java.util.*; diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java index bd65dd30a4..7f8b9df081 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java @@ -32,7 +32,6 @@ import lombok.Getter; import java.util.ArrayList; -import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; import java.util.OptionalInt; diff --git a/src/main/java/ac/grim/grimac/utils/lists/RunningMode.java b/src/main/java/ac/grim/grimac/utils/lists/RunningMode.java index 6726c7d6e7..146a365415 100644 --- a/src/main/java/ac/grim/grimac/utils/lists/RunningMode.java +++ b/src/main/java/ac/grim/grimac/utils/lists/RunningMode.java @@ -4,8 +4,6 @@ import it.unimi.dsi.fastutil.doubles.Double2IntMap; import it.unimi.dsi.fastutil.doubles.Double2IntOpenHashMap; -import java.util.HashMap; -import java.util.Map; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; From 1799a560722b36f1b4b434eb127a8bcd6f417c2f Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Fri, 22 Nov 2024 14:28:02 -0700 Subject: [PATCH 52/52] fix falses --- .../checks/impl/packetorder/PacketOrderA.java | 2 +- .../checks/impl/packetorder/PacketOrderE.java | 2 +- .../checks/impl/packetorder/PacketOrderF.java | 2 +- .../checks/impl/packetorder/PacketOrderG.java | 2 +- .../checks/impl/packetorder/PacketOrderH.java | 2 +- .../checks/impl/packetorder/PacketOrderI.java | 2 +- .../checks/impl/packetorder/PacketOrderJ.java | 2 +- .../checks/impl/packetorder/PacketOrderK.java | 2 +- .../checks/impl/packetorder/PacketOrderL.java | 2 +- .../checks/impl/packetorder/PacketOrderM.java | 2 +- .../checks/impl/packetorder/PacketOrderN.java | 2 +- .../packetorder/PacketOrderProcessor.java | 56 +++++++------------ .../ac/grim/grimac/manager/CheckManager.java | 2 +- 13 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index 1145b8eae9..7849935432 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -43,7 +43,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index 3d800a9a77..3c6bf544d7 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -52,7 +52,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { return; } - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { if (flagAndAlert() && setback) { setback = false; diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index e83dc97db6..dd6a157f7d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -50,7 +50,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index ee96977935..f6ecdb06ec 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -58,7 +58,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java index 782302c1cf..212760d032 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -40,7 +40,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index af6c32511f..1c9de80724 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -109,7 +109,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { setbackIfAboveSetbackVL(); setback = false; } - } else if (player.isTickingReliablyFor(3)) { + } else if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (String verbose : flags) { if (flagAndAlert(verbose) && setback) { setbackIfAboveSetbackVL(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java index 92e4533cc6..bbe57054a1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -38,7 +38,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index d607ff35f2..5462f9b158 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -53,7 +53,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (String verbose : flags) { flagAndAlert(verbose); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index 1e697e1e16..634bd5bc67 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -53,7 +53,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (String verbose : flags) { flagAndAlert(verbose); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java index 9a57f2dbf3..462e24e712 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java @@ -60,7 +60,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java index 990cd9646d..c36e737ef3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java @@ -57,7 +57,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) { // we don't need to check pre-1.9 players here (no tick skipping) if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return; - if (player.isTickingReliablyFor(3)) { + if (player.isTickingReliablyFor(3) && !player.uncertaintyHandler.lastVehicleSwitch.hasOccurredSince(0)) { for (; invalid >= 1; invalid--) { flagAndAlert(); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index 2ff16f5d46..295125facb 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -3,11 +3,8 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; -import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; -import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; -import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.protocol.world.BlockFace; import com.github.retrooper.packetevents.wrapper.play.client.*; import lombok.Getter; @@ -41,7 +38,7 @@ public PacketOrderProcessor(final GrimPlayer player) { @Override public void onPacketReceive(PacketReceiveEvent event) { - final PacketTypeCommon packetType = event.getPacketType(); + final var packetType = event.getPacketType(); if (packetType == PacketType.Play.Client.CLIENT_STATUS) { if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) { @@ -106,40 +103,29 @@ public void onPacketReceive(PacketReceiveEvent event) { closingInventory = true; } - if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) { - onTick(); + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { + openingInventory = false; + swapping = false; + dropping = false; + attacking = false; + interacting = false; + releasing = false; + digging = false; + placing = false; + using = false; + picking = false; + sprinting = false; + sneaking = false; + clickingInInventory = false; + closingInventory = false; + quickMoveClicking = false; + pickUpClicking = false; + leavingBed = false; + startingToGlide = false; + jumpingWithMount = false; } } - @Override - public void onPredictionComplete(PredictionComplete predictionComplete) { - if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) { - onTick(); - } - } - - private void onTick() { - openingInventory = false; - swapping = false; - dropping = false; - attacking = false; - interacting = false; - releasing = false; - digging = false; - placing = false; - using = false; - picking = false; - sprinting = false; - sneaking = false; - clickingInInventory = false; - closingInventory = false; - quickMoveClicking = false; - pickUpClicking = false; - leavingBed = false; - startingToGlide = false; - jumpingWithMount = false; - } - @Contract(pure = true) public boolean isRightClicking() { return placing || using || interacting; diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 55bf12dbd6..912c5699ae 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -67,6 +67,7 @@ public class CheckManager { public CheckManager(GrimPlayer player) { // Include post checks in the packet check too packetChecks = new ImmutableClassToInstanceMap.Builder() + .put(PacketOrderProcessor.class, player.packetOrderProcessor) .put(Reach.class, new Reach(player)) .put(PacketEntityReplication.class, new PacketEntityReplication(player)) .put(PacketChangeGameState.class, new PacketChangeGameState(player)) @@ -129,7 +130,6 @@ public CheckManager(GrimPlayer player) { .put(KnockbackHandler.class, new KnockbackHandler(player)) .put(GhostBlockDetector.class, new GhostBlockDetector(player)) .put(Phase.class, new Phase(player)) - .put(PacketOrderProcessor.class, player.packetOrderProcessor) .put(Post.class, new Post(player)) .put(PacketOrderA.class, new PacketOrderA(player)) .put(PacketOrderE.class, new PacketOrderE(player))