Rise 5.99 NoRot module 2 files, 98 lines

Rise 5.99 NoRot: Full Source Analysis

NoRot intercepts S08PacketPlayerPosLook and rewrites or delays the forced rotation so the camera never snaps to what the server orders.

dev/rise/module/impl/other/NoRot.java · GitHub source ↗

Published 2026-08-13 · Updated 2026-08-13

Analysis

Overview

NoRot intercepts S08PacketPlayerPosLook and rewrites or delays the forced rotation so the camera never snaps to what the server orders. The Mode setting registers six values but only three have switch cases: Vanilla overwrites the S08 yaw and pitch fields with the client's current rotation before the vanilla handler runs, so the teleport applies position-only and the C06 ack the client sends immediately after carries the client's own look; Delay lets the S08 snap and restores the pre-teleport rotation on the next PreMotion; Legit rewrites the S08 like Vanilla, saves both the server rotation and the player's starting rotation, then reports the saved server rotation on every subsequent PreMotion while the player's view is unchanged, gated on the event yaw still matching the starting yaw. Packet, Edit and Hypixel have no case branches and are dead modes. The vanilla handler that consumes the modified packet (handlePlayerPosLook) sets position and rotation and immediately emits a C06 ack with the same position and look, which is why the module's field rewrite changes what the server measures.

Mode matrix

The switch in onPacketReceive runs before the vanilla handler, so field writes change what the client applies and acks. Vanilla stores the server's yaw and pitch into the module fields and overwrites the packet fields with mc.thePlayer.rotationYaw and rotationPitch; the stored values are never read again, making Vanilla a pure drop of the forced rotation. Delay does not touch the packet at all: it saves the client's current rotation and restores it in onPreMotion one tick later, so the snap exists for exactly one tick. Legit rewrites the packet like Vanilla, saves the server rotation and the player's starting rotation, and on later PreMotions reports the server rotation via event.setYaw and event.setPitch, but only while the event yaw still equals the starting yaw, so the first mouse movement clears the pin. Packet, Edit and Hypixel register no case and execute nothing.

Vanilla teleport contract

The fork's vanilla handler defines the wire effect. handlePlayerPosLook applies the packet's position and rotation to the player and immediately sends C06PacketPlayerPosLook with that same position, yaw and pitch, which the server treats as the teleport acknowledgement. NoRot's rewrite therefore does not just spare the camera: it changes the ack. In Vanilla and Legit the ack reports the client's pre-teleport rotation instead of the server's forced one, while the position part matches exactly. In Delay the ack reports the forced rotation (the packet was untouched) and the restore appears only on the next regular C03, one tick later.

Legit pin behavior

Legit is the mode with a persistent signature. Because the camera never snapped and the equality gate requires the event yaw and pitch to match the starting values, the pin survives until the mouse moves: every PreMotion in between reports the saved server rotation verbatim, so the C03 stream carries one constant yaw and pitch pair for potentially many ticks. The moment the player moves the view, the gate fails and all four saved fields are nulled, releasing the pin. The mode is a rotation desync rather than a freeze: the local camera stays at the player's rotation while the packets claim the server's.

source NoRot.java

NoRot.java83 lines · JavaOriginal ↗
1
/*
2
 Copyright Alan Wood 2021
3
 None of this code to be reused without my written permission
4
 Intellectual Rights owned by Alan Wood
5
 */
6
package dev.rise.module.impl.other;
7
8
import dev.rise.event.impl.motion.PreMotionEvent;
9
import dev.rise.event.impl.packet.PacketReceiveEvent;
10
import dev.rise.module.Module;
11
import dev.rise.module.api.ModuleInfo;
12
import dev.rise.module.enums.Category;
13
import dev.rise.setting.impl.ModeSetting;
14
import net.minecraft.network.Packet;
15
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
16
17
@ModuleInfo(name = "NoRot", description = "Prevents servers from modifying your rotation", category = Category.OTHER)
18
public final class NoRot extends Module {
19
20
    private final ModeSetting mode = new ModeSetting("Mode", this, "Vanilla", "Vanilla", "Packet", "Delay", "Legit", "Edit", "Hypixel");
21
    private Float yaw, pitch;
22
    private Float startingYaw, startingPitch;
23
24
    @Override
25
    public void onPacketReceive(final PacketReceiveEvent event) {
26
        final Packet<?> packet = event.getPacket();
27
28
        if (packet instanceof S08PacketPlayerPosLook) {
29
            final S08PacketPlayerPosLook teleport = (S08PacketPlayerPosLook) packet;
30
31
            switch (mode.getMode()) {
32
                case "Vanilla":
33
                    yaw = teleport.yaw;
34
                    pitch = teleport.pitch;
35
36
                    teleport.yaw = mc.thePlayer.rotationYaw;
37
                    teleport.pitch = mc.thePlayer.rotationPitch;
38
                    break;
39
40
                case "Delay":
41
                    yaw = mc.thePlayer.rotationYaw;
42
                    pitch = mc.thePlayer.rotationPitch;
43
                    break;
44
45
                case "Legit":
46
                    yaw = teleport.getYaw();
47
                    pitch = teleport.getPitch();
48
                    startingYaw = mc.thePlayer.rotationYaw;
49
                    startingPitch = mc.thePlayer.rotationPitch;
50
51
                    teleport.yaw = mc.thePlayer.rotationYaw;
52
                    teleport.pitch = mc.thePlayer.rotationPitch;
53
                    break;
54
            }
55
        }
56
    }
57
58
    @Override
59
    public void onPreMotion(final PreMotionEvent event) {
60
        switch (mode.getMode()) {
61
            case "Delay":
62
                if (yaw != null && pitch != null) {
63
                    mc.thePlayer.rotationYaw = yaw;
64
                    mc.thePlayer.rotationPitch = pitch;
65
66
                    yaw = null;
67
                    pitch = null;
68
                }
69
                break;
70
71
            case "Legit":
72
                if (yaw != null && pitch != null && startingYaw != null && startingPitch != null) {
73
                    if (startingYaw == event.getYaw() && startingPitch == event.getPitch()) {
74
                        event.setYaw(yaw);
75
                        event.setPitch(pitch);
76
                    } else {
77
                        startingPitch = startingYaw = yaw = pitch = null;
78
                    }
79
                }
80
                break;
81
        }
82
    }
83
}

What this file does

The module is the complete technique: the ModeSetting with six registered values, the three live switch cases in onPacketReceive (Vanilla, Delay, Legit), and the two live onPreMotion restore paths (Delay and Legit). The yaw, pitch, startingYaw and startingPitch fields carry the state between the receive handler and the motion handler, and the null-out logic in the Legit gate is what releases the pin on mouse movement. The dead modes (Packet, Edit, Hypixel) are visible as registered strings with no case, a decompiled-client artifact worth stating rather than glossing over.

source PreMotionEvent.java (rotation carrier)

PreMotionEvent.java15 lines · JavaOriginal ↗
1
package dev.rise.event.impl.motion;
2
3
import dev.rise.event.api.Event;
4
import lombok.AllArgsConstructor;
5
import lombok.Getter;
6
import lombok.Setter;
7
8
@Getter
9
@Setter
10
@AllArgsConstructor
11
public final class PreMotionEvent extends Event {
12
    private float yaw, pitch;
13
    private boolean ground;
14
    private double x, y, z;
15
}

What this file does

The event that carries the client's per-tick rotation into the module layer, fired before the tick's C03 is built. NoRot's Delay restore writes mc.thePlayer.rotationYaw and rotationPitch directly, while the Legit pin works through the event itself: event.setYaw and event.setPitch overwrite the values that become the C03 look, and the getYaw and getPitch accessors feed the equality gate that decides whether the pin is still live. The class is a plain yaw, pitch, ground, x, y, z carrier, but it is the exact seam where a rotation-only module can change what the wire reports without moving the camera, which is the whole mechanism of the Legit mode.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat EqualRotation (duplicate rotation stream)

PacketAnalysisEqualRotation.java120 lines · Java
1
package de.photon.anticheataddition.modules.checks.packetanalysis;
2
3
import com.github.retrooper.packetevents.event.PacketListenerPriority;
4
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
5
import de.photon.anticheataddition.ServerVersion;
6
import de.photon.anticheataddition.modules.ModuleLoader;
7
import de.photon.anticheataddition.modules.ViolationModule;
8
import de.photon.anticheataddition.util.protocol.PacketAdapterBuilder;
9
import de.photon.anticheataddition.util.protocol.PacketEventUtils;
10
import de.photon.anticheataddition.user.User;
11
import de.photon.anticheataddition.user.data.TimeKey;
12
import de.photon.anticheataddition.util.datastructure.SetUtil;
13
import de.photon.anticheataddition.util.minecraft.world.material.MaterialUtil;
14
import de.photon.anticheataddition.util.violationlevels.Flag;
15
import de.photon.anticheataddition.util.violationlevels.ViolationLevelManagement;
16
import de.photon.anticheataddition.util.violationlevels.ViolationManagement;
17
import org.bukkit.block.BlockFace;
18
import org.bukkit.entity.Player;
19
import org.bukkit.event.EventHandler;
20
import org.bukkit.event.Listener;
21
import org.bukkit.event.vehicle.VehicleEnterEvent;
22
import org.bukkit.event.vehicle.VehicleExitEvent;
23
24
import java.util.concurrent.TimeUnit;
25
26
public final class PacketAnalysisEqualRotation extends ViolationModule implements Listener
27
{
28
    public static final PacketAnalysisEqualRotation INSTANCE = new PacketAnalysisEqualRotation();
29
30
    private PacketAnalysisEqualRotation()
31
    {
32
        super("PacketAnalysis.parts.EqualRotation");
33
    }
34
35
    private static boolean changedHitboxMaterialsPresent(User user)
36
    {
37
        return ServerVersion.is18() &&
38
               user.getClientVersion() != ServerVersion.MC18 &&
39
               SetUtil.containsAny(user.getHitboxLocation().getPartiallyIncludedMaterials(), MaterialUtil.INSTANCE.getChangedHitboxMaterials());
40
    }
41
42
    @Override
43
    protected ModuleLoader createModuleLoader()
44
    {
45
        final var packetAdapter = PacketAdapterBuilder
46
                .of(this, PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION, PacketType.Play.Client.PLAYER_ROTATION)
47
                .priority(PacketListenerPriority.LOW)
48
                .onReceiving((event, user) -> {
49
                    final PacketEventUtils.Rotation rotation = PacketEventUtils.getRotationFromEvent(event);
50
51
                    // Equal rotation.
52
                    // LookPacketData automatically updates these values.
53
                    if (rotation.yaw() != user.getData().floating.lastPacketYaw ||
54
                        rotation.pitch() != user.getData().floating.lastPacketPitch) return;
55
56
                    // Interactions with firework as well as entering and exiting vehicles fast can cause false positives.
57
                    if (user.getTimeMap().at(TimeKey.PACKET_ANALYSIS_EQUAL_ROTATION_INTERACTION).recentlyUpdated(100) ||
58
                        // Boat false positive (usually worse cheats in vehicles as well)
59
                        user.getPlayer().isInsideVehicle() ||
60
                        // Not recently teleported
61
                        user.hasTeleportedRecently(5000) ||
62
                        // 1.17 client false positive when throwing exp bottles.
63
                        user.getTimeMap().at(TimeKey.EXPERIENCE_BOTTLE_THROWN).recentlyUpdated(5000) ||
64
                        // LabyMod fp when standing still / hit in corner fp
65
                        !user.hasMovedRecently(TimeKey.XZ_MOVEMENT, 100) ||
66
                        // 1.17 false positives
67
                        user.getTimeMap().at(TimeKey.HOTBAR_SWITCH).recentlyUpdated(3000) && user.hasSneakedRecently(3000) ||
68
                        user.getTimeMap().at(TimeKey.RIGHT_CLICK_ITEM_EVENT).recentlyUpdated(400) ||
69
                        !PacketAdapterBuilder.checkSync(10, TimeUnit.SECONDS,
70
                                                        // False positive when jumping from great heights into a pool with slime blocks / beds on the bottom.
71
                                                        () -> !(user.isInLiquids() && MaterialUtil.INSTANCE.getBounceMaterials().contains(user.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType())) &&
72
                                                              // Fixes false positives on versions 1.9+ because of changed hitboxes
73
                                                              !changedHitboxMaterialsPresent(user))) return;
74
75
                    // Cancelled packets may cause problems.
76
                    if (user.getData().bool.packetAnalysisEqualRotationExpected) {
77
                        user.getData().bool.packetAnalysisEqualRotationExpected = false;
78
                        return;
79
                    }
80
81
                    getManagement().flag(Flag.of(user).setDebug(() -> "PacketAnalysisData-Debug | Player: " + user.getPlayer().getName() + " sent equal rotations."));
82
                }).build();
83
84
        return ModuleLoader.builder(this)
85
                           .addPacketListeners(packetAdapter)
86
                           .build();
87
    }
88
89
    private void handleEqualRotationExpectedInteraction(Player player)
90
    {
91
        final var user = User.getUser(player);
92
        if (User.isUserInvalid(user, this)) return;
93
94
        user.getTimeMap().at(TimeKey.PACKET_ANALYSIS_EQUAL_ROTATION_INTERACTION).update();
95
    }
96
97
    @EventHandler
98
    public void onVehicleEnter(VehicleEnterEvent event)
99
    {
100
        if (event.getEntered() instanceof Player player) {
101
            handleEqualRotationExpectedInteraction(player);
102
        }
103
    }
104
105
    @EventHandler
106
    public void onVehicleExit(VehicleExitEvent event)
107
    {
108
        if (event.getExited() instanceof Player player) {
109
            handleEqualRotationExpectedInteraction(player);
110
        }
111
    }
112
113
    @Override
114
    protected ViolationManagement createViolationManagement()
115
    {
116
        return ViolationLevelManagement.builder(this)
117
                                       .emptyThresholdManagement()
118
                                       .withDecay(100, 5).build();
119
    }
120
}

How it counteracts this module

PacketAnalysisEqualRotation flags a C03 whose yaw and pitch exactly equal the previous packet's pair, with a battery of gates: out of vehicles, not within 5000 ms of a teleport, XZ movement within the last 100 ms, no recent interactions or right-clicks, and a sync sanity check. The Legit pin is precisely this signature: while the mouse is still, every reported rotation equals the server-forced pair, so once the 5-second post-teleport grace expires and the player is strafing, consecutive packets with identical yaw and pitch trip the flag. Vanilla and Delay never produce equal consecutive rotations (the live stream or the one-tick snap keeps deltas nonzero), so the check is a mode-specific counter: it punishes the desync mode that reports a constant rotation and is blind to the modes that drop or briefly restore it.

anticheat RotationSnapHeuristic (teleport-coupled snap detection)

RotationSnapHeuristic.java351 lines · Java
1
/*
2
 * Copyright 2026 Intave
3
 *
4
 * This software is licensed under the PolyForm Perimeter License 1.0.0.
5
 * You may use this software for any purpose, except for providing to
6
 * others any product that competes with the software.
7
 *
8
 * A copy of the license is available at:
9
 *   https://polyformproject.org/licenses/perimeter/1.0.0/
10
 */
11
12
package de.jpx3.intave.check.combat.heuristics.combatpatterns.rotation;
13
14
import com.comphenix.protocol.events.PacketEvent;
15
import de.jpx3.intave.check.combat.Heuristics;
16
import de.jpx3.intave.check.combat.heuristics.ClassicHeuristic;
17
import de.jpx3.intave.check.combat.heuristics.HeuristicsClassicType;
18
import de.jpx3.intave.math.MathHelper;
19
import de.jpx3.intave.module.linker.bukkit.BukkitEventSubscription;
20
import de.jpx3.intave.module.linker.packet.ListenerPriority;
21
import de.jpx3.intave.module.linker.packet.PacketSubscription;
22
import de.jpx3.intave.module.tracker.entity.Entity;
23
import de.jpx3.intave.packet.reader.EntityUseReader;
24
import de.jpx3.intave.share.BoundingBox;
25
import de.jpx3.intave.share.ClientMath;
26
import de.jpx3.intave.user.User;
27
import de.jpx3.intave.user.meta.AttackMetadata;
28
import de.jpx3.intave.user.meta.CheckCustomMetadata;
29
import de.jpx3.intave.user.meta.MovementMetadata;
30
import de.jpx3.intave.world.raytrace.EntityRaytraceBlockConstraint;
31
import de.jpx3.intave.world.raytrace.Raytrace;
32
import de.jpx3.intave.world.raytrace.Raytracing;
33
import org.bukkit.entity.Player;
34
import org.bukkit.event.block.BlockPlaceEvent;
35
36
import java.util.concurrent.atomic.AtomicLong;
37
38
import static de.jpx3.intave.check.movement.physics.environment.MoveMetric.TELEPORT;
39
import static de.jpx3.intave.module.linker.packet.PacketId.Client.*;
40
41
public final class RotationSnapHeuristic extends ClassicHeuristic<RotationSnapHeuristic.RotationSnapHeuristicMeta> {
42
  // Defines how long after a block place, arm swing or attack the VL for mitigations should be increased. 
43
  private static final long VL_BOOST_MODIFIER_TIME = (1000 / 20) * 3; // Set to 3 ticks. (150ms)
44
45
  public RotationSnapHeuristic(Heuristics parentCheck) {
46
    super(parentCheck, HeuristicsClassicType.ROTATION_SNAP, RotationSnapHeuristicMeta.class);
47
  }
48
49
  @PacketSubscription(
50
    priority = ListenerPriority.HIGH,
51
    packetsIn = {
52
      ARM_ANIMATION
53
    }
54
  )
55
  public void receiveSwingPacket(PacketEvent event) {
56
    Player player = event.getPlayer();
57
    User user = userOf(player);
58
    RotationSnapHeuristicMeta meta = metaOf(user);
59
60
    meta.lastSwing = System.currentTimeMillis();
61
  }
62
63
  @BukkitEventSubscription
64
  public void on(BlockPlaceEvent place) {
65
    Player player = place.getPlayer();
66
    User user = userOf(player);
67
    RotationSnapHeuristicMeta meta = metaOf(user);
68
    meta.lastBlockPlace.set(System.currentTimeMillis());
69
  }
70
71
  @PacketSubscription(
72
    priority = ListenerPriority.HIGH,
73
    packetsIn = {
74
      ATTACK_ENTITY, USE_ENTITY
75
    }
76
  )
77
  public void receiveAttackPacket(
78
    User user, EntityUseReader reader
79
  ) {
80
    if (reader.isAttackPacket()) {
81
      metaOf(user).lastAttack = System.currentTimeMillis();
82
    }
83
  }
84
85
  @PacketSubscription(
86
    priority = ListenerPriority.HIGH,
87
    packetsIn = {
88
      POSITION_LOOK, LOOK
89
    }
90
  )
91
  public void receiveRotationPacket(PacketEvent event) {
92
    metaOf(userOf(event.getPlayer())).rotationPacketCounter++;
93
  }
94
95
  private double keysToRotation(int strafe, int forward) {
96
    return Math.toDegrees(Math.atan2(strafe, forward)) - 90;
97
  }
98
99
  static double computeYawMotion(float lastRotationYaw, float rotationYaw) {
100
    return Math.abs(lastRotationYaw - rotationYaw);
101
  }
102
103
  static boolean isRotationSnapDetected(
104
    double previousYawMotion, double lastYawMotion, double currentYawMotion,
105
    boolean recentSwingOrAttack, int rotationPacketCounter, int ticksPastTeleport
106
  ) {
107
    boolean isSuspicious = previousYawMotion < 9 && lastYawMotion > 40 && currentYawMotion < 9;
108
    return isSuspicious && recentSwingOrAttack && rotationPacketCounter > 10 && ticksPastTeleport > 7;
109
  }
110
111
  private double floorModDouble(double x, double y) {
112
    return (x - Math.floor(x / y) * y);
113
  }
114
115
  @PacketSubscription(
116
    priority = ListenerPriority.HIGH,
117
    packetsIn = {
118
      FLYING, LOOK, POSITION, POSITION_LOOK
119
    }
120
  )
121
  public void receiveMovementPacket(PacketEvent event) {
122
    Player player = event.getPlayer();
123
    User user = userOf(player);
124
    MovementMetadata movementData = user.meta().movement();
125
126
    if (movementData.ticksPast(TELEPORT) == 0) {
127
      return;
128
    }
129
    RotationSnapHeuristicMeta meta = metaOf(user);
130
131
    if (movementData.offsetMotionX() != 0 && movementData.offsetMotionZ() != 0) {
132
      meta.internalViolation -= 0.01f;
133
      if (meta.internalViolation < 0)
134
        meta.internalViolation = 0;
135
    }
136
137
    double yawMotion = computeYawMotion(movementData.lastRotationYaw, movementData.rotationYaw);
138
    AttackMetadata attackData = user.meta().attack();
139
140
    if ((yawMotion > 40 && meta.yawMotions[1] < 9) || (yawMotion > 25 && meta.yawMotions[1] == 0)) {
141
      if (meta.lastKeyStrafe != movementData.keyStrafe || meta.lastKeyForward != movementData.keyForward) {
142
        double directionLast = movementData.rotationYaw + keysToRotation(meta.lastKeyStrafe, meta.lastKeyForward);
143
        double direction = movementData.lastRotationYaw + keysToRotation(movementData.keyStrafe, movementData.keyForward);
144
145
        direction = floorModDouble(direction, 360);
146
        directionLast = floorModDouble(directionLast, 360);
147
148
//      String key = resolveKeysFromInput(movementData.keyForward, movementData.keyStrafe);
149
//      String lastKey = resolveKeysFromInput(meta.lastKeyForward, meta.lastKeyStrafe);
150
        boolean silentMovement = (int) (ClientMath.wrapAngleTo180_double(directionLast - direction) / 45d) == 0;
151
        if (movementData.keyForward != meta.lastKeyForward || movementData.keyStrafe != meta.lastKeyStrafe) {
152
          if (silentMovement && (movementData.keyForward != 0 || movementData.keyStrafe != 0) && (meta.lastKeyForward != 0 || meta.lastKeyStrafe != 0)) {
153
            meta.silentMovements[0] = KeyStates.SILENTMOVE;
154
          } else {
155
            meta.silentMovements[0] = KeyStates.CHANGED;
156
          }
157
        }
158
      }
159
160
      Tick tick = new Tick(
161
        meta.lastLastPosX, meta.lastLastPosY, meta.lastLastPosZ,
162
        movementData.lastRotationYaw, movementData.lastRotationPitch
163
      );
164
      meta.movementAtTick[0] = tick;
165
    }
166
167
    boolean isSuspicious = (meta.yawMotions[1] == 0 && meta.yawMotions[0] > 25 && yawMotion < 9);
168
    boolean liteFlag = isSuspicious && meta.silentMovements[1] == KeyStates.SILENTMOVE && meta.rotationPacketCounter > 10 && movementData.ticksPast(TELEPORT) > 7;
169
170
    boolean snapDetected = isRotationSnapDetected(
171
      meta.yawMotions[1], meta.yawMotions[0], yawMotion,
172
      wasRecent(meta.lastSwing) || wasRecent(meta.lastAttack),
173
      meta.rotationPacketCounter,
174
      movementData.ticksPast(TELEPORT)
175
    );
176
177
    if (snapDetected) {
178
      double valueOfSnap = meta.yawMotions[0];
179
      String details = "yaw: ["
180
        + MathHelper.formatDouble(meta.yawMotions[1], 2)
181
        + "/" + MathHelper.formatDouble(meta.yawMotions[0], 2)
182
        + "/" + MathHelper.formatDouble(yawMotion, 2) + "]";
183
184
      if (meta.silentMovements[1] == KeyStates.SILENTMOVE) {
185
        details += ", movement: silent";
186
      } else if (meta.silentMovements[1] == KeyStates.CHANGED) {
187
        details += ", movement: changed";
188
      }
189
190
      boolean changedLookToEntity = false;
191
      if (attackData.lastAttackedEntity() != null && attackData.lastAttackedEntity().positionHistory.size() > 2) {
192
        Entity entity = attackData.lastAttackedEntity();
193
194
        Tick tick = meta.movementAtTick[1];
195
        Entity.EntityPositionContext lastEntityPosition = entity.lastPosition;
196
197
        if (lastEntityPosition != null && tick != null) {
198
          BoundingBox lastBoundingBox = Entity.entityBoundingBoxFrom(lastEntityPosition, entity);
199
          Raytrace last = Raytracing.entityRaytrace(
200
            player,
201
            lastBoundingBox,
202
            0,
203
            tick.posX, tick.posY, tick.posZ,
204
            tick.yaw, tick.pitch,
205
            0.1f,
206
            EntityRaytraceBlockConstraint.IGNORE_BLOCKS
207
          );
208
209
          Raytrace raytrace = Raytracing.entityRaytrace(
210
            player,
211
            entity.boundingBox(),
212
            0,
213
            movementData.lastPositionX, movementData.lastPositionY, movementData.lastPositionZ,
214
            movementData.lastRotationYaw, movementData.lastRotationPitch,
215
            0.1f,
216
            EntityRaytraceBlockConstraint.IGNORE_BLOCKS
217
          );
218
219
          changedLookToEntity = (last.reach() != 10) != (raytrace.reach() != 10);
220
          if (changedLookToEntity) {
221
            details += ", look changed to entity";
222
          }
223
        }
224
      }
225
226
      double vl = calculateViolation(valueOfSnap, changedLookToEntity, user, liteFlag);
227
      liteFlag = false;
228
229
      handleConfidence(user, (int) vl, "rotation snapped suspiciously", details);
230
    }
231
232
    if (liteFlag) {
233
      String details = "yaw: " + MathHelper.formatDouble(meta.yawMotions[0], 2);
234
      int addedViolationLevel = 30;
235
      handleConfidence(user, addedViolationLevel, "rotation snapped suspiciously while scaffolding", details);
236
    }
237
238
    prepareNextTick(meta, yawMotion, user);
239
  }
240
241
  private void handleConfidence(User user, int violationToAdd, String message, String details) {
242
    RotationSnapHeuristicMeta meta = metaOf(user);
243
244
    meta.internalViolation += violationToAdd;
245
246
    if (meta.internalViolation >= 30) {
247
      meta.internalViolation -= 30;
248
249
      if (user.protocolVersion() > 47) {
250
        details += ", protocol: " + user.protocolVersion();
251
      }
252
253
      flag(user, message, details);
254
    } else if (meta.internalViolation > 5) {
255
      // flag(user, message, details + ", debug");
256
    }
257
  }
258
259
  private double calculateViolation(double valueOfSnap, boolean changedLookToEntity, User user, boolean liteFlag) {
260
    RotationSnapHeuristicMeta meta = metaOf(user);
261
    double vl = 7;
262
    if (valueOfSnap > 360) {
263
      vl = 120;
264
    } else if (valueOfSnap > 178) {
265
      vl = 50;
266
    } else if (valueOfSnap > 90) {
267
      vl = 20;
268
    } else if (valueOfSnap > 50) {
269
      vl = 10;
270
    }
271
    if (wasRecent(meta.lastBlockPlace.get())) {
272
      vl *= 1.5;
273
    }
274
    if (changedLookToEntity) {
275
      vl *= 2;
276
    }
277
    if (meta.silentMovements[1] == KeyStates.SILENTMOVE) {
278
      vl *= 3;
279
    } else if (meta.silentMovements[1] == KeyStates.CHANGED) {
280
      vl *= 1.7;
281
    }
282
    if (liteFlag) {
283
      vl += 10;
284
    }
285
    // added the division because there are false flaggs when a player has less than 20 fps
286
    vl /= 3;
287
    if (vl > 160 && valueOfSnap < 360) {
288
      vl = 160;
289
    }
290
    return vl;
291
  }
292
293
  private boolean wasRecent(long milliseconds) {
294
    return System.currentTimeMillis() - milliseconds < VL_BOOST_MODIFIER_TIME;
295
  }
296
297
  private void prepareNextTick(RotationSnapHeuristicMeta meta, double yawMotion, User user) {
298
    MovementMetadata movementData = user.meta().movement();
299
    meta.lastKeyForward = movementData.keyForward;
300
    meta.lastKeyStrafe = movementData.keyStrafe;
301
302
    meta.lastLastPosX = movementData.lastPositionX;
303
    meta.lastLastPosY = movementData.lastPositionY;
304
    meta.lastLastPosZ = movementData.lastPositionZ;
305
306
    meta.yawMotions[1] = meta.yawMotions[0];
307
    meta.yawMotions[0] = yawMotion;
308
309
    meta.silentMovements[1] = meta.silentMovements[0];
310
    meta.silentMovements[0] = KeyStates.NONE;
311
312
    meta.movementAtTick[1] = meta.movementAtTick[0];
313
    meta.movementAtTick[0] = null;
314
  }
315
316
  enum KeyStates {
317
    NONE, CHANGED, SILENTMOVE
318
  }
319
320
  public static final class RotationSnapHeuristicMeta extends CheckCustomMetadata {
321
    //    Map<Integer, Po> entityPositions = new HashMap<>();
322
    private final Tick[] movementAtTick = new Tick[2];
323
    private final double[] yawMotions = new double[2];
324
    private final KeyStates[] silentMovements = new KeyStates[2];
325
    double lastLastPosX, lastLastPosY, lastLastPosZ;
326
    private float internalViolation;
327
    private int lastKeyForward;
328
    private int lastKeyStrafe;
329
    // used to disable the check on startup
330
    private int rotationPacketCounter;
331
    private long lastSwing;
332
    private long lastAttack;
333
334
    // AtomicLong is being used because it gets set in a Bukkit thread.
335
    private AtomicLong lastBlockPlace = new AtomicLong();
336
  }
337
338
  static class Tick {
339
    double posX, posY, posZ;
340
    float yaw, pitch;
341
342
    public Tick(double posX, double posY, double posZ, float yaw, float pitch) {
343
      this.posX = posX;
344
      this.posY = posY;
345
      this.posZ = posZ;
346
347
      this.yaw = yaw;
348
      this.pitch = pitch;
349
    }
350
  }
351
}

How it counteracts this module

intave's snap detector requires the yaw-motion triple (previous under 9 degrees, current over 40, next under 9) plus a swing or attack within 150 ms, more than 10 rotation packets processed and more than 7 ticks since the last teleport. Delay mode produces exactly a snap-and-restore: the S08 forces a rotation jump and the next PreMotion restores it, so the C03 stream shows a single over-40 spike between two quiet ticks. The check's own teleport grace defeats it: the spike lands one or two ticks after the S08, inside the 7-tick exemption window, so the snap is never evaluated. Vanilla and Legit produce no spike at all (the forced rotation never enters the stream, or enters as a constant), so the heuristic is an honest miss whose mechanism explains why: it is built for aimbot snaps that follow attacks, not for anti-correction restores that follow teleports.

anticheat TeleportQueue (teleport ack ledger)

TeleportQueue.java370 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.net.model;
16
17
import java.util.Iterator;
18
import java.util.LinkedList;
19
import java.util.concurrent.locks.Lock;
20
import java.util.concurrent.locks.ReentrantLock;
21
22
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
23
24
/**
25
 * Queue outgoing teleport locations (DataPacketFlying), in order to cancel
26
 * other moving until the client acknowledges previous teleport locations. In
27
 * fact this might only queue a single location.
28
 * 
29
 * @author asofold
30
 *
31
 */
32
public class TeleportQueue {
33
34
    public static enum AckResolution {
35
        /** Waiting for ACK. */
36
        WAITING,
37
        /** Packet is ACK. */
38
        ACK,
39
        /** Not waiting for an ACK. */
40
        IDLE
41
    }
42
43
    public static class AckReference {
44
        public int lastOutgoingId = Integer.MIN_VALUE;
45
        /**
46
         * The maximum of confirmed ids. Once lastOutgoingId is reached, we
47
         * assume all teleports are done. Until then this id may get adjusted if
48
         * lower than lastOutgoingId. Note that the id will be circling within 0
49
         * to Integer.MAX_VALUE - 1, systematically increasing until back to 0,
50
         * thus this value can be greater than lastOutGoingId, which should be
51
         * treated as 'bad luck', resetting this to Integer.MIN_VALUE.
52
         */
53
        public int maxConfirmedId = Integer.MIN_VALUE;
54
    }
55
56
    // TODO: Consider passing a reentrant lock in the constructor (e.g. one lock per NetData).
57
    private final Lock lock = new ReentrantLock();
58
59
    /** Validated outgoing teleport locations, expected to be confirmed by the client. */
60
    private final LinkedList<CountableLocation> expectIncoming = new LinkedList<CountableLocation>();
61
    /** Location from a Bukkit event, which we expect an outgoing teleport for. */
62
    private DataLocation expectOutgoing = null;
63
64
    private long maxAge = 4000; // TODO: configurable
65
    private int maxQueueSize = 60; // TODO: configurable
66
67
    /**
68
     * Queried from the primary thread (read only), reset with outgoing
69
     * teleport.
70
     */
71
    private CountableLocation lastAck = null;
72
73
    private AckReference lastAckReference = new AckReference();
74
75
    /**
76
     * Maximum age in milliseconds, older entries expire.
77
     * @return
78
     */
79
    public long getMaxAge() {
80
        return maxAge;
81
    }
82
83
    /**
84
     * The last confirmed teleport location (read-only by primary thread),
85
     * resets with outgoing teleport.
86
     * 
87
     * @return
88
     */
89
    public CountableLocation getLastAck() {
90
        return lastAck;
91
    }
92
93
    /**
94
     * Get the reference of the last ack, not resetting, but updating with
95
     * incoming acks. This always is the same object, it might only by updated
96
     * on a successful ACK, depending on what's needed (current use is to cancel
97
     * packets on processAck returning WAITING).
98
     * 
99
     * @return
100
     */
101
    public AckReference getLastAckReference() {
102
        return lastAckReference;
103
    }
104
105
    /**
106
     * Compact diagnostic snapshot for NET_MOVING false-positive analysis.
107
     */
108
    public String getDebugState(final long now) {
109
        final StringBuilder builder = new StringBuilder(300);
110
        lock.lock();
111
        builder.append("expectOutgoing=").append(expectOutgoing == null ? "none" : expectOutgoing.toString());
112
        builder.append(",expectIncomingSize=").append(expectIncoming.size());
113
        if (!expectIncoming.isEmpty()) {
114
            builder.append(",incomingFirst=").append(formatCountable(expectIncoming.getFirst(), now));
115
            builder.append(",incomingLast=").append(formatCountable(expectIncoming.getLast(), now));
116
        }
117
        builder.append(",lastAck=").append(lastAck == null ? "none" : formatCountable(lastAck, now));
118
        builder.append(",ackRef=lastOutgoing:").append(lastAckReference.lastOutgoingId)
119
                .append("/maxConfirmed:").append(lastAckReference.maxConfirmedId);
120
        builder.append(",maxAge=").append(maxAge);
121
        lock.unlock();
122
        return builder.toString();
123
    }
124
125
    private String formatCountable(final CountableLocation ref, final long now) {
126
        final StringBuilder builder = new StringBuilder(160);
127
        builder.append(ref.toString());
128
        builder.append(",age=");
129
        builder.append(now >= ref.time ? now - ref.time : -(ref.time - now));
130
        return builder.toString();
131
    }
132
133
    /**
134
     * Call for Bukkit events (expect this packet to be sent).<br>
135
     * TODO: The method name is misleading, as this also should be called with
136
     * expected outgoing packet.
137
     * 
138
     * @param packetData
139
     */
140
    public void onTeleportEvent(final double x, final double y, final double z, final float yaw, final float pitch) {
141
        lock.lock();
142
        lastAck = null;
143
        expectOutgoing = new DataLocation(x, y, z, yaw, pitch);
144
        lock.unlock();
145
    }
146
147
    /**
148
     * Call for outgoing teleport packets. Lazily checks for expiration and max
149
     * queue size. Update teleportId (Integer.MIN_VALUE means that it isn't
150
     * provided).
151
     * 
152
     * @param x
153
     * @param y
154
     * @param z
155
     * @param yaw
156
     * @param pitch
157
     * @param teleportId
158
     * @return
159
     */
160
    public CountableLocation onOutgoingTeleport(final double x, final double y, final double z, 
161
            final float yaw, final float pitch, final int teleportId) {
162
        CountableLocation res = null;
163
        final long time = System.currentTimeMillis();
164
        lock.lock();
165
        lastAckReference.lastOutgoingId = teleportId;
166
        if (lastAckReference.maxConfirmedId > lastAckReference.lastOutgoingId) {
167
            lastAckReference.maxConfirmedId = Integer.MIN_VALUE; // Some data loss accepted here.
168
        }
169
        // Only register this location, if it matches the location from a Bukkit event.
170
        if (expectOutgoing != null) {
171
            if (expectOutgoing.isSamePosAndLook(x, y, z, yaw, pitch)) {
172
                // Add to queue.
173
                if (!expectIncoming.isEmpty()) {
174
                    // Lazy expiration check.
175
                    final Iterator<CountableLocation> it = expectIncoming.iterator();
176
                    while (it.hasNext()) {
177
                        final CountableLocation ref = it.next();
178
                        if (time < ref.time) {
179
                            // Time ran backwards. Force keep entries.
180
                            ref.time = time;
181
                        }
182
                        else if (time - maxAge > ref.time) {
183
                            it.remove();
184
                        } else {
185
                            break;
186
                        }
187
                    }
188
                    if (!expectIncoming.isEmpty()) {
189
                        final CountableLocation last = expectIncoming.getLast();
190
                        if (last.isSamePosAndLook(x, y, z, yaw, pitch)) {
191
                            last.time = time;
192
                            last.count ++;
193
                            last.teleportId = teleportId;
194
                            res = last;
195
                        }
196
                    }
197
                }
198
                // Add a new entry, if not merged with last.
199
                if (res == null) {
200
                    res = new CountableLocation(x, y, z, yaw, pitch, 1, time, teleportId);
201
                    expectIncoming.addLast(res);
202
                    // Don't exceed maxQueueSize.
203
                    if (expectIncoming.size() > maxQueueSize) {
204
                        expectIncoming.removeFirst();
205
                    }
206
                }
207
            }
208
            // Reset in any case.
209
            expectOutgoing = null;
210
        }
211
        lock.unlock();
212
        return res;
213
    }
214
215
    /**
216
     * Process ack on receiving a 'confirm teleport' packet.
217
     * 
218
     * @param teleportId
219
     * @return YES, if this teleport id is explicitly matched (not necessarily
220
     *         the latest one), MAYBE if it's a unique id smaller than than
221
     *         maxConfirmedId. NO, if it's not a valid ack - it could be some
222
     *         other special condition, like Integer overflow, or timeout.
223
     */
224
    public AlmostBoolean processAck(final int teleportId) {
225
        /*
226
         * Return values are subject to change, e.g.: (ACK_LATEST_POS),
227
         * ACK_LATEST_ID, ACK_OUTDATED_POS, ACK_OUTDATED_ID, UNKNOWN
228
         */
229
        if (teleportId == Integer.MIN_VALUE) {
230
            // Could consider to return MAYBE for not knowing, needs elaborating on context and use cases.
231
            return AlmostBoolean.NO;
232
        }
233
        lock.lock();
234
        if (teleportId == lastAckReference.lastOutgoingId) {
235
            lastAckReference.maxConfirmedId = teleportId;
236
            // Abort here for efficiency.
237
            expectIncoming.clear();
238
            lock.unlock();
239
            return AlmostBoolean.YES;
240
        }
241
        AlmostBoolean ackState = AlmostBoolean.NO;
242
        final Iterator<CountableLocation> it = expectIncoming.iterator();
243
        while (it.hasNext()) {
244
            final CountableLocation ref = it.next();
245
            // No expiration checks here.
246
            if (ref.teleportId == teleportId) {
247
                // Match an outdated id.
248
                // Remove all preceding older entries and this one.
249
                while (ref != expectIncoming.getFirst()) {
250
                    expectIncoming.removeFirst();
251
                }
252
                expectIncoming.removeFirst();
253
                // The count doesn't count anymore.
254
                ref.count = 0;
255
                ackState = AlmostBoolean.YES;
256
                break;
257
            }
258
        }
259
        // Update lastAckReference only if within the safe area.
260
        if (teleportId < lastAckReference.lastOutgoingId 
261
                && teleportId > lastAckReference.maxConfirmedId) {
262
            // Allow update.
263
            lastAckReference.maxConfirmedId = teleportId;
264
            if (ackState == AlmostBoolean.NO) {
265
                // Adjust to maybe, as long as the id is increasing within unique range.
266
                ackState = AlmostBoolean.MAYBE;
267
            }
268
        }
269
        else {
270
            lastAckReference.maxConfirmedId = Integer.MIN_VALUE;
271
        }
272
        lock.unlock();
273
        return ackState;
274
    }
275
276
    /**
277
     * Accept a movement packet that matches the teleport location from a Bukkit
278
     * event before ProtocolLib has observed the matching outgoing position.
279
     */
280
    public boolean consumeExpectedOutgoingPosition(final DataPacketFlying packetData) {
281
        if (packetData == null || !packetData.hasPos) {
282
            return false;
283
        }
284
        lock.lock();
285
        final boolean match = expectOutgoing != null && expectOutgoing.isSamePos(packetData);
286
        if (match) {
287
            expectOutgoing = null;
288
        }
289
        lock.unlock();
290
        return match;
291
    }
292
293
    /**
294
     * Test if the move is an ACK move (or no ACK is expected), adjust internals
295
     * if necessary.
296
     * 
297
     * @param packetData
298
     * @return ACK, if the packet matches an expected ACK position. IDLE, if no
299
     *         ACK is expected or on timeout. CANCEL, if still waiting for an
300
     *         ACK.
301
     */
302
    public AckResolution processAck(final DataPacketFlying packetData) {
303
        // Check packet.
304
        if (!packetData.hasPos || !packetData.hasLook) {
305
            // Applies, if we don't have a teleport-confirm event.
306
            return AckResolution.IDLE;
307
        }
308
        // Check queue.
309
        final AckResolution res;
310
311
        lock.lock();
312
        if (expectIncoming.isEmpty()) {
313
            res = AckResolution.IDLE;
314
        } else {
315
            res = getAckResolution(packetData);
316
        }
317
        lock.unlock();
318
319
        return res;
320
    }
321
322
    /**
323
     * Check queue (lock is handled outside of this method). Does check for
324
     * expiration of entries. Must only be called under lock.
325
     * 
326
     * @param packetData
327
     * @return
328
     */
329
    private AckResolution getAckResolution(final DataPacketFlying packetData) {
330
        // Iterate from oldest to newest.
331
        final Iterator<CountableLocation> it = expectIncoming.iterator();
332
        while (it.hasNext()) {
333
            final CountableLocation ref = it.next();
334
            if (packetData.time - maxAge >= ref.time) {
335
                it.remove();
336
            }
337
            else if (packetData.isSamePosAndLook(ref)) {
338
                // Match.
339
                // Remove all preceding older entries.
340
                while (ref != expectIncoming.getFirst()) {
341
                    expectIncoming.removeFirst();
342
                }
343
                // Decrease count and remove the matching entry if count is down to 0.
344
                if (--ref.count <= 0) { // (Lots of safety margin.)
345
                    expectIncoming.removeFirst(); // Do not use the iterator here.
346
                }
347
                lastAck = ref;
348
                return AckResolution.ACK;
349
            }
350
            else {
351
                // Skip until match or none found.
352
                // TODO: Consider settings like maxSkipCount or strictly return WAITING.
353
                if (packetData.time < ref.time) {
354
                    // Time ran backwards, update to now.
355
                    ref.time = packetData.time;
356
                }
357
            }
358
        }
359
        // No match.
360
        return expectIncoming.isEmpty() ? AckResolution.IDLE : AckResolution.WAITING;
361
    }
362
363
    public void clear() {
364
        lock.lock();
365
        expectIncoming.clear();
366
        expectOutgoing = null;
367
        lock.unlock();
368
    }
369
370
}

How it counteracts this module

NoCheatPlus queues every outbound S08 teleport and matches the client's next position-and-look packet against it with exact equality via isSamePosAndLook, so the acknowledgement must reproduce the teleport's yaw and pitch as well as its position. Vanilla and Legit rewrite the S08 fields before the vanilla handler acks, which means the C06 reports the client's rotation and never matches the queued entry: the ledger stays WAITING until the entry ages out at 4000 ms. On 1.8 the WAITING branch does not cancel the move (the cancel path is gated on the 1.9-plus CONFIRM_TELEPORT packet type), so the practical effect is a stale queue entry and the ack being treated as an ordinary move. Delay mode sends the correct forced look in its ack and closes the ledger normally, so the check separates the modes exactly along the rewrite boundary.

anticheat AimbotHeuristic (rotation delta analysis)

AimbotHeuristic.java164 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.movement.look;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.CustomCheck;
23
import me.islandscout.hawk.check.Cancelless;
24
import me.islandscout.hawk.event.*;
25
import me.islandscout.hawk.util.Debug;
26
import me.islandscout.hawk.util.MathPlus;
27
import org.bukkit.entity.Player;
28
import org.bukkit.util.Vector;
29
30
import java.util.*;
31
32
/**
33
 * AimbotHeuristic exploits flaws in aim-bot cheats by
34
 * analyzing mouse movement patterns during interaction. Although
35
 * easily bypassed, it catches a significant number of cheaters.
36
 * Caution is advised since this check may false flag during
37
 * certain circumstances. This check should only be used as a
38
 * hint that the player might be cheating.
39
 */
40
public class AimbotHeuristic extends CustomCheck implements Cancelless {
41
42
    private final Map<UUID, List<Vector>> mouseMoves;
43
    private final Map<UUID, List<Long>> clickTimes;
44
45
    private static final int MOVES_PER_SAMPLE = 4; //must be greater than 0
46
    private final int MOVES_AFTER_HIT;
47
    private final boolean DEBUG;
48
49
    public AimbotHeuristic() {
50
        super("aimbotheuristic", false, -1, 5, 0.99, 5000, "&7%player% failed aimbot (heuristic), VL %vl%", null);
51
        mouseMoves = new HashMap<>();
52
        clickTimes = new HashMap<>();
53
54
        MOVES_AFTER_HIT = MOVES_PER_SAMPLE - MOVES_PER_SAMPLE / 2;
55
56
        DEBUG = (boolean) customSetting("debug", "", false);
57
    }
58
59
    public void check(Event e) {
60
        if (e instanceof MoveEvent) {
61
            processMove((MoveEvent) e);
62
        } else if (e instanceof InteractEntityEvent || e instanceof InteractWorldEvent) {
63
            processClick(e);
64
        }
65
    }
66
67
    private void processMove(MoveEvent e) {
68
        Player p = e.getPlayer();
69
        HawkPlayer pp = e.getHawkPlayer();
70
        UUID uuid = p.getUniqueId();
71
72
        List<Vector> lastMoves = mouseMoves.getOrDefault(uuid, new ArrayList<>());
73
        Vector mouseMove = new Vector(e.getTo().getYaw() - e.getFrom().getYaw(), e.getTo().getPitch() - e.getFrom().getPitch(), 0);
74
75
        lastMoves.add(mouseMove);
76
        //make size 1 bigger so that we can get the move before
77
        //the first move that we check
78
        if(lastMoves.size() > MOVES_PER_SAMPLE + 1) {
79
            lastMoves.remove(0);
80
        }
81
        mouseMoves.put(uuid, lastMoves);
82
83
        if(clickedXMovesBefore(MOVES_AFTER_HIT, pp)) {
84
            double minSpeed = Double.MAX_VALUE;
85
            double maxSpeed = 0D;
86
            double maxAngle = 0D;
87
            for(int i = 1; i < lastMoves.size(); i++) {
88
                Vector lastMouseMove = lastMoves.get(i - 1);
89
                Vector currMouseMove = lastMoves.get(i);
90
                double speed = currMouseMove.length();
91
                double lastSpeed = lastMouseMove.length();
92
                double angle = (lastSpeed != 0 && lastSpeed != 0) ? MathPlus.angle(lastMouseMove, currMouseMove) : 0D;
93
                if(Double.isNaN(angle))
94
                    angle = 0D;
95
                maxSpeed = Math.max(speed, maxSpeed);
96
                minSpeed = Math.min(speed, minSpeed);
97
                maxAngle = Math.max(angle, maxAngle);
98
99
                //stutter
100
                if(maxSpeed - minSpeed > 4 && minSpeed < 0.01 && maxAngle < 0.1 && lastSpeed > 1) { //this lastSpeed check eliminates a false positive
101
                    if(DEBUG) {
102
                        p.sendMessage("AimbotHeuristic: A");
103
                    }
104
                    punishEm(pp, e);
105
                }
106
                //twitching or zig zags
107
                else if(speed > 20 && lastSpeed > 20 && angle > 2.86) {
108
                    if(DEBUG) {
109
                        p.sendMessage("AimbotHeuristic: B");
110
                    }
111
                    punishEm(pp, e);
112
                }
113
                //jump discontinuity
114
                else if(speed - lastSpeed < -30 && angle > 0.8) {
115
                    if(DEBUG) {
116
                        p.sendMessage("AimbotHeuristic: C");
117
                    }
118
                    punishEm(pp, e);
119
                }
120
                else {
121
                    reward(pp);
122
                }
123
            }
124
        }
125
    }
126
127
    private boolean clickedXMovesBefore(long x, HawkPlayer pp) {
128
        List<Long> clickTimess = clickTimes.getOrDefault(pp.getUuid(), new ArrayList<>());
129
        long time = pp.getCurrentTick() - x;
130
        for(int i = 0; i < clickTimess.size(); i++) {
131
            if(time == clickTimess.get(i)) {
132
                clickTimess.remove(i);
133
                return true;
134
            }
135
        }
136
        return false;
137
    }
138
139
    private void processClick(Event e) {
140
        UUID uuid = e.getPlayer().getUniqueId();
141
        List<Long> clickTimess = clickTimes.getOrDefault(uuid, new ArrayList<>());
142
        long currTick = e.getHawkPlayer().getCurrentTick();
143
        if(!clickTimess.contains(currTick))
144
            clickTimess.add(e.getHawkPlayer().getCurrentTick());
145
146
        //memory leak fail-safe, if necessary?
147
        for(int i = clickTimess.size() - 1; i >= 0; i--) {
148
            if(currTick - clickTimess.get(i) > MOVES_PER_SAMPLE + 1)
149
                clickTimess.remove(i);
150
        }
151
152
        clickTimes.put(uuid, clickTimess);
153
    }
154
155
    private void punishEm(HawkPlayer pp, MoveEvent e) {
156
        punish(pp, false, e);
157
    }
158
159
    @Override
160
    public void removeData(Player p) {
161
        mouseMoves.remove(p.getUniqueId());
162
        clickTimes.remove(p.getUniqueId());
163
    }
164
}

How it counteracts this module

Hawk's rotation-stream heuristic scores the delta pattern of C03 looks but arms only on entity interactions, so a NoRot session without combat never activates it, and the streams the module produces are not the pattern it hunts: Vanilla keeps the player's live rotation with human deltas, Delay shows one spike then continuity, and Legit shows a frozen pair with zero deltas, none of which is a snap-to-target signature. It is the honest boundary for the rotation family: the check catches aimbot-style rotation jumps toward entities, while NoRot is an anti-correction module whose whole point is that the server's rotation never appears as a client-side aim change.

← Back to Analysis Hub