-
Notifications
You must be signed in to change notification settings - Fork 326
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
21c119d
commit b80b239
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPackets3.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,73 @@ | ||
package ac.grim.grimac.checks.impl.badpackets; | ||
|
||
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 = "BadPackets3") | ||
public class BadPackets3 extends Check implements PacketCheck, PostPredictionCheck { | ||
public BadPackets3(GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private float sprints = 0; | ||
private float sneaks = 0; | ||
|
||
@Override | ||
public void onPredictionComplete(final PredictionComplete predictionComplete) { | ||
// we don't need to check pre-1.9 players here (no tick skipping) | ||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) return; | ||
|
||
if (player.skippedTickInActualMovement) { | ||
sprints *= 0.05f; | ||
sneaks *= 0.05f; | ||
} | ||
|
||
for (; sneaks > 1; sneaks--) flagAndAlert("sneak"); | ||
for (; sprints > 1; sprints--) flagAndAlert("sprint"); | ||
sneaks = 0; | ||
sprints = 0; | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && !player.packetStateData.lastPacketWasTeleport) { | ||
sprints = 0; | ||
sneaks = 0; | ||
return; | ||
} | ||
|
||
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) { | ||
switch (new WrapperPlayClientEntityAction(event).getAction()) { | ||
case START_SNEAKING: | ||
case STOP_SNEAKING: | ||
sneaks++; | ||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sneaks > 1) { | ||
if (flagAndAlert("sneak") && shouldModifyPackets()) { | ||
event.setCancelled(true); | ||
player.onPacketCancel(); | ||
} | ||
} | ||
break; | ||
case START_SPRINTING: | ||
case STOP_SPRINTING: | ||
sprints++; | ||
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sprints > 1) { | ||
if (flagAndAlert("sprint") && shouldModifyPackets()) { | ||
event.setCancelled(true); | ||
player.onPacketCancel(); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} |
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