-
Notifications
You must be signed in to change notification settings - Fork 331
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
36a394d
commit 0719c5b
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.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,60 @@ | ||
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 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.player.ClientVersion; | ||
import com.github.retrooper.packetevents.protocol.player.InteractionHand; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; | ||
|
||
@CheckData(name = "PacketOrderO", experimental = true) | ||
public class PacketOrderO extends BlockPlaceCheck { | ||
public PacketOrderO(final GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private boolean sentMainhand; | ||
|
||
@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(); | ||
} | ||
} | ||
|
||
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)"); | ||
} | ||
} | ||
} | ||
|
||
private boolean isSupported() { | ||
return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.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,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.PacketCheck; | ||
import ac.grim.grimac.player.GrimPlayer; | ||
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.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 = "PacketOrderP", experimental = true) | ||
public class PacketOrderP extends Check implements PacketCheck { | ||
public PacketOrderP(final GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private boolean sentMainhand; | ||
private int requiredEntity; | ||
private boolean requiredSneaking; | ||
|
||
@Override | ||
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; | ||
} | ||
} | ||
} | ||
|
||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { | ||
sentMainhand = 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