diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 5cfde8bcf9..937e827970 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -10,6 +10,7 @@ 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; @CheckData(name = "PacketOrderC", experimental = true) public class PacketOrderC extends Check implements PacketCheck { @@ -20,10 +21,15 @@ public PacketOrderC(final GrimPlayer player) { // 1.7 players do not send INTERACT_AT, so we cannot check them private final boolean exempt = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10); private boolean sentInteractAt = false; + private int requiredEntity; @Override public void onPacketReceive(PacketReceiveEvent event) { - if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY && !exempt) { + if (exempt) { + return; + } + + if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event); @@ -43,6 +49,11 @@ public void onPacketReceive(PacketReceiveEvent event) { event.setCancelled(true); player.onPacketCancel(); } + } else if (wrapper.getEntityId() != requiredEntity) { + if (flagAndAlert("Wrong Entity, required=" + requiredEntity + ", entity=" + wrapper.getEntityId()) && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } } sentInteractAt = false; break; @@ -53,9 +64,19 @@ public void onPacketReceive(PacketReceiveEvent event) { player.onPacketCancel(); } } + requiredEntity = wrapper.getEntityId(); sentInteractAt = true; break; } } + + if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { + if (sentInteractAt) { + if (flagAndAlert("Missed Interact (Tick)") && shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + } + } } }