-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fad39af
commit a38f341
Showing
13 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters