Skip to content

Commit

Permalink
Add MultiInteract Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Sep 19, 2024
1 parent fad39af commit a38f341
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package ac.grim.grimac.checks.impl.combat;

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;

import java.util.ArrayList;

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

private final ArrayList<String> flags = new ArrayList<>();
private int lastEntity;
private boolean hasInteracted = false;

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
int entity = new WrapperPlayClientInteractEntity(event).getEntityId();

if (hasInteracted && entity != lastEntity) {
String verbose = "lastEntity=" + lastEntity + ", entity=" + entity;
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add(verbose);
}
}

lastEntity = entity;
hasInteracted = true;
}

if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) {
hasInteracted = 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 (String verbose : flags) {
flagAndAlert(verbose);
}
}

flags.clear();
hasInteracted = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ac.grim.grimac.checks.impl.combat;

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.MessageUtil;
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.util.Vector3f;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;

import java.util.ArrayList;

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

private final ArrayList<String> flags = new ArrayList<>();
private Vector3f lastPos;
private boolean hasInteracted = false;

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
Vector3f pos = new WrapperPlayClientInteractEntity(event).getTarget().orElse(null);

if (pos == null) {
return;
}

if (hasInteracted && !pos.equals(lastPos)) {
String verbose = "pos=" + MessageUtil.toUnlabledString(pos) + ", lastPos=" + MessageUtil.toUnlabledString(lastPos);
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
if (flagAndAlert(verbose) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add(verbose);
}
}

lastPos = pos;
hasInteracted = true;
}

if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && !player.packetStateData.lastPacketWasTeleport) {
hasInteracted = 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 (String verbose : flags) {
flagAndAlert(verbose);
}
}

flags.clear();
hasInteracted = false;
}
}
4 changes: 4 additions & 0 deletions src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import ac.grim.grimac.checks.impl.aim.AimModulo360;
import ac.grim.grimac.checks.impl.aim.processor.AimProcessor;
import ac.grim.grimac.checks.impl.badpackets.*;
import ac.grim.grimac.checks.impl.combat.MultiInteractA;
import ac.grim.grimac.checks.impl.combat.MultiInteractB;
import ac.grim.grimac.checks.impl.combat.Reach;
import ac.grim.grimac.checks.impl.crash.*;
import ac.grim.grimac.checks.impl.exploit.ExploitA;
Expand Down Expand Up @@ -129,6 +131,8 @@ public CheckManager(GrimPlayer player) {
.put(NoSlowC.class, new NoSlowC(player))
.put(NoSlowD.class, new NoSlowD(player))
.put(NoSlowE.class, new NoSlowE(player))
.put(MultiInteractA.class, new MultiInteractA(player))
.put(MultiInteractB.class, new MultiInteractB(player))
.put(SetbackTeleportUtil.class, new SetbackTeleportUtil(player)) // Avoid teleporting to new position, update safe pos last
.put(CompensatedFireworks.class, player.compensatedFireworks)
.put(SneakingEstimator.class, new SneakingEstimator(player))
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/punishments/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Punishments:
Combat:
remove-violations-after: 300
checks:
- "Interact"
- "Killaura"
- "Aim"
commands:
Expand Down

0 comments on commit a38f341

Please sign in to comment.