-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1485 from ManInMyVan/BadPackets1
Add BadPacketsV
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsV.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,40 @@ | ||
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.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.util.Vector3d; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; | ||
|
||
@CheckData(name = "BadPacketsV", description = "Did not move far enough", experimental = true) | ||
public class BadPacketsV extends Check implements PacketCheck { | ||
public BadPacketsV(GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private final boolean supported = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) || player.supportsEndTick(); | ||
private int noReminderTicks; | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (supported && isTickPacket(event.getPacketType())) { | ||
if (event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION || event.getPacketType() == PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION) { | ||
if (noReminderTicks < 20 && !player.uncertaintyHandler.lastTeleportTicks.hasOccurredSince(1)) { | ||
final double deltaSq = new WrapperPlayClientPlayerFlying(event).getLocation().getPosition() | ||
.distanceSquared(new Vector3d(player.lastX, player.lastY, player.lastZ)); | ||
if (deltaSq <= player.getMovementThreshold() * player.getMovementThreshold()) { | ||
flagAndAlert("delta=" + Math.sqrt(deltaSq)); | ||
} | ||
} | ||
|
||
noReminderTicks = 0; | ||
} else { | ||
noReminderTicks++; | ||
} | ||
} | ||
} | ||
} |
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