-
Notifications
You must be signed in to change notification settings - Fork 332
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
0e08dbc
commit 36a394d
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.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,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; | ||
} | ||
} |
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