Skip to content

Commit

Permalink
Merge remote-tracking branch 'maninmyvan/packetorder' into merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java
#	src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java
#	src/main/java/ac/grim/grimac/manager/CheckManager.java
  • Loading branch information
Axionize committed Nov 23, 2024
2 parents 1a7949a + 1799a56 commit ff780d4
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +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.BlockPlaceCheck;
import ac.grim.grimac.checks.type.PacketCheck;
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.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 = "PacketOrderO", experimental = true)
public class PacketOrderO extends BlockPlaceCheck {
@CheckData(name = "PacketOrderP", experimental = true)
public class PacketOrderO extends Check implements PacketCheck {
public PacketOrderO(final GrimPlayer player) {
super(player);
}

private boolean sentMainhand;
private int requiredEntity;
private boolean requiredSneaking;

@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();
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;
}
}

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)");
}
sentMainhand = false;
}
}

private boolean isSupported() {
return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
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;
Expand Down Expand Up @@ -137,40 +135,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;
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class CheckManager {
public CheckManager(GrimPlayer player) {
// Include post checks in the packet check too
packetChecks = new ImmutableClassToInstanceMap.Builder<PacketCheck>()
.put(PacketOrderProcessor.class, player.packetOrderProcessor)
.put(Reach.class, new Reach(player))
.put(PacketEntityReplication.class, new PacketEntityReplication(player))
.put(PacketChangeGameState.class, new PacketChangeGameState(player))
Expand Down Expand Up @@ -112,6 +113,10 @@ public CheckManager(GrimPlayer player) {
.put(PacketOrderC.class, new PacketOrderC(player))
.put(PacketOrderD.class, new PacketOrderD(player))
.put(PacketOrderP.class, new PacketOrderP(player))
.put(PacketOrderB.class, new PacketOrderB(player))
.put(PacketOrderC.class, new PacketOrderC(player))
.put(PacketOrderD.class, new PacketOrderD(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();
Expand Down Expand Up @@ -148,6 +153,17 @@ public CheckManager(GrimPlayer player) {
.put(PacketOrderK.class, new PacketOrderK(player))
.put(PacketOrderL.class, new PacketOrderL(player))
.put(PacketOrderM.class, new PacketOrderM(player))
.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))
.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))
.put(OffsetHandler.class, new OffsetHandler(player))
.put(SuperDebug.class, new SuperDebug(player))
Expand Down Expand Up @@ -175,7 +191,6 @@ public CheckManager(GrimPlayer player) {
.put(FabricatedPlace.class, new FabricatedPlace(player))
.put(PositionPlace.class, new PositionPlace(player))
.put(PacketOrderN.class, new PacketOrderN(player))
.put(PacketOrderO.class, new PacketOrderO(player))
.put(DuplicateRotPlace.class, new DuplicateRotPlace(player))
.put(LineOfSightPlace.class, new LineOfSightPlace(player))
.put(GhostBlockMitigation.class, new GhostBlockMitigation(player))
Expand Down Expand Up @@ -318,7 +333,6 @@ public <T extends PacketCheck> T getPrePredictionCheck(Class<T> check) {
return (T) prePredictionChecks.get(check);
}


private PacketEntityReplication packetEntityReplication = null;

public PacketEntityReplication getEntityReplication() {
Expand Down

0 comments on commit ff780d4

Please sign in to comment.