Rise 6.1.30 KillAura module 4 files, 1341 lines

Rise 6.1.30 KillAura: Full Source Analysis

Rise 6.1.30's KillAura is the combat core of the 6.x branch: three attack modes (Single, Switch, Multiple), four rotation modes (Legit/Normal, Snap, NCP, Autistic AntiCheat), fourteen auto-block modes, and a full movement-correction layer.

com/alan/clients/module/impl/combat/KillAura.java · GitHub source ↗

Published 2026-08-12 · Updated 2026-08-12

Analysis

Overview

Rise 6.1.30's KillAura is the combat core of the 6.x branch: three attack modes (Single, Switch, Multiple), four rotation modes (Legit/Normal, Snap, NCP, Autistic AntiCheat), fourteen auto-block modes, and a full movement-correction layer. All aiming funnels through the shared RotationComponent engine, which multiplies the configured rotation speed by 36, walks a randomized randomAngle offset toward the target, gates every intermediate rotation with a ray-cast predicate so the smoothed path stays inside the hitbox, and fixes the GCD with RotationUtil.applySensitivityPatch on every smoothing iteration. Attacks dispatch through playerController.attackEntity or a raw C02PacketUseEntity when keepSprint is on; the block/unblock pair emits C08/C07, and the Grim, Watchdog 1.17, New NCP and Old Intave modes swap held-item slots with paired C09 packets to desync the server's view of the sword.

Architecture

The module is event-driven with priority-ordered listeners. onHighPreUpdate (Priorities.HIGH) is the target and rotation pass: it refreshes the mouse over, computes allowAttack from BadPacketsComponent (unless the bad-packets check is disabled), decays the attack counter, applies the expandRange heuristic (every 20 ticks it sets expandRange to 3 + Math.random() * 0.5, a 3.0-3.5 block range expansion used when no targets are found), calls getTargets() which delegates to TargetComponent.getTargets(range), picks targets.get(0), runs preBlock() for the auto-block mode, then rotations(). onMediumPriorityPreUpdate carries no priority tag and therefore runs after other modules have had their chance to override the rotations; only then does it call doAttack(targets) and postAttackBlock(), so the module attacks with the final rotation state of the tick. onPreMotionEvent flushes the packetQueue (a ConcurrentLinkedQueue of packets queued by the blink and ping-spoof block modes) via sendNoEvent, increments hitTicks, clears blocking when the held item is not a sword, and runs the Watchdog auto-block cycle which spoofs mc.objectMouseOver from RotationComponent.lastRotations before calling mc.rightClickMouse() so the server sees a right click aimed at the last rotation. onPacketSend tracks swing state (C0A sets swing true, C03 resets it) and dispatches the Intave packetBlock mode, which cancels the outgoing C03, unblocks, re-sends the C03 without events, and re-blocks.

Rotation engine

All aiming goes through RotationComponent.setRotations(rotations, rotationSpeed, correctMovement, raycast), which stores the target, multiplies rotationSpeed by 36, and calls smooth(). smooth() only runs its randomization when a raycast predicate was supplied and the target differs from the current rotations by more than 5 degrees: it accumulates a randomAngle offset whose sign flips every 10 ticks (ticksExisted / 10 % 2 == 0 ? -1 : 1), advances the offset by sin/cos of that angle scaled by speed = (Math.random()^3) * 20, and after each advance applies the raycast predicate (in KillAura, RayCastUtil.rayCast(rotations, range, -0.1f) must hit an entity). A miss inverts the walk direction and retries; a second miss zeroes the offset and falls back to targetRotations plus up to 2 degrees of jitter. The smoothed result comes from RotationUtil.smooth, which distributes the per-tick speed across yaw and pitch proportionally to the remaining deltas, adds per-iteration micro-jitter (yaw += (random - 0.5) / 1000, pitch -= random / 200) for FPS/20 plus random iterations, and applies applySensitivityPatch to every iteration so the final stream stays on the mouse-sensitivity GCD grid. The component's onPreMotionEvent listener writes the smoothed rotations into the outgoing motion event (event.setYaw/Pitch), sets rotationYawHead and renderPitchHead, and records lastServerRotations; when the smoothed rotations come within 1 degree of the player's real rotations it deactivates and calls correctDisabledRotations(), which snaps the view back onto the GCD grid via RotationUtil.resetRotation(RotationUtil.applySensitivityPatch(rotations, lastRotations)). MovementFix is an enum with OFF, NORMAL (Rise), TRADITIONAL and BACKWARDS_SPRINT: NORMAL rewrites the input yaw on MoveInputEvent through MoveUtil.fixMovement and sets movementYaw/velocityYaw to the smoothed yaw on StrafeEvent and JumpEvent, TRADITIONAL only sets yaw on StrafeEvent and JumpEvent, and BACKWARDS_SPRINT force-releases the sprint key whenever the smoothed yaw differs from MoveUtil.direction() by more than 45 degrees. The NCP rotation mode additionally predicts both entities' motion, applies applySensitivityPatch to the computed axis, and with 10% probability feeds RotationComponent a random offset of up to 10 yaw and 3 pitch instead.

Attack dispatch and autoblock

doAttack() gates on the attackStopWatch/clickStopWatch pair: clicks are drawn from cps.getRandomBetween() * 1.5 (so the 1-20 bounds produce 1.5-30 clicks per second), nextSwing becomes 1000 / clicks, and the attack fires when attackStopWatch.finished(nextSwing) and (clickStopWatch.finished(delay * 50) or the Hit Select flag) hold, with a nonsense extra gate Math.sin(nextSwing) + 1 > Math.random(). attack() posts an AttackEvent on the bus, calls the (empty) attackBlock(), swings via swingItem(), then either playerController.attackEntity or, with keepSprint on, syncCurrentPlayItem plus a direct C02PacketUseEntity ATTACK send with a critical-hit check when falling. Single and Switch modes attack the primary target when it is within range (or when rayCast is on and the ray hits it), fall through to attack whatever entity the ray cast actually hit when it is not a fireball, and otherwise abort if curBlockDamageMP is nonzero; Multiple mode removes out-of-range targets and attacks every survivor in one tick. Auto-block modes range from pure rendering (Fake/None cancel the RightClickEvent and force EnumAction.BLOCK through onRenderItem) through post-attack C08 blocks (Vanilla, Imperfect Vanilla, Vanilla ReBlock), C09 slot-swap pairs (Grim, Watchdog 1.17, New NCP, Old Intave), the Universal blockTicks 2-3 cycle with PingSpoofComponent.blink()/dispatch(), and the Intave C03 cancel-resend-block sequence.

source KillAura.java

KillAura.java942 lines · JavaOriginal ↗
1
package com.alan.clients.module.impl.combat;
2
3
import com.alan.clients.Client;
4
import com.alan.clients.component.impl.player.*;
5
import com.alan.clients.component.impl.player.rotationcomponent.MovementFix;
6
import com.alan.clients.component.impl.render.ESPComponent;
7
import com.alan.clients.component.impl.render.espcomponent.api.ESPColor;
8
import com.alan.clients.component.impl.render.espcomponent.impl.AboveBox;
9
import com.alan.clients.component.impl.render.espcomponent.impl.FullBox;
10
import com.alan.clients.component.impl.render.espcomponent.impl.SigmaRing;
11
import com.alan.clients.event.Listener;
12
import com.alan.clients.event.Priorities;
13
import com.alan.clients.event.annotations.EventLink;
14
import com.alan.clients.event.impl.input.RightClickEvent;
15
import com.alan.clients.event.impl.motion.PostMotionEvent;
16
import com.alan.clients.event.impl.motion.PreMotionEvent;
17
import com.alan.clients.event.impl.motion.PreUpdateEvent;
18
import com.alan.clients.event.impl.motion.SlowDownEvent;
19
import com.alan.clients.event.impl.other.AttackEvent;
20
import com.alan.clients.event.impl.other.WorldChangeEvent;
21
import com.alan.clients.event.impl.packet.PacketSendEvent;
22
import com.alan.clients.event.impl.render.MouseOverEvent;
23
import com.alan.clients.event.impl.render.RenderItemEvent;
24
import com.alan.clients.module.Module;
25
import com.alan.clients.module.api.Category;
26
import com.alan.clients.module.api.ModuleInfo;
27
import com.alan.clients.module.impl.player.Scaffold;
28
import com.alan.clients.util.EvictingList;
29
import com.alan.clients.util.RayCastUtil;
30
import com.alan.clients.util.packet.PacketUtil;
31
import com.alan.clients.util.player.MoveUtil;
32
import com.alan.clients.util.player.PlayerUtil;
33
import com.alan.clients.util.render.RenderUtil;
34
import com.alan.clients.util.rotation.RotationUtil;
35
import com.alan.clients.util.vector.Vector2f;
36
import com.alan.clients.util.vector.Vector3d;
37
import com.alan.clients.value.impl.*;
38
import net.minecraft.entity.EntityLivingBase;
39
import net.minecraft.entity.projectile.EntityFireball;
40
import net.minecraft.item.*;
41
import net.minecraft.network.Packet;
42
import net.minecraft.network.play.client.*;
43
import net.minecraft.potion.Potion;
44
import net.minecraft.util.*;
45
import rip.vantage.commons.util.time.StopWatch;
46
47
import java.awt.*;
48
import java.util.Comparator;
49
import java.util.List;
50
import java.util.Queue;
51
import java.util.concurrent.ConcurrentLinkedQueue;
52
53
@ModuleInfo(aliases = {"module.combat.killaura.name", "Aura", "Force Field"}, description = "module.combat.killaura.description", category = Category.COMBAT)
54
public final class KillAura extends Module {
55
    private final ModeValue mode = new ModeValue("Attack Mode", this)
56
            .add(new SubMode("Single"))
57
            .add(new SubMode("Switch"))
58
            .add(new SubMode("Multiple"))
59
            .setDefault("Single");
60
61
    private final BoundsNumberValue switchDelay = new BoundsNumberValue("Switch Delay", this, 0, 0, 0, 10, 1, () -> !mode.getValue().getName().equals("Switch"));
62
    public final ModeValue autoBlock = new ModeValue("Auto Block", this)
63
            .add(new SubMode("None"))
64
            .add(new SubMode("Fake"))
65
            .add(new SubMode("Vanilla"))
66
            .add(new SubMode("NCP"))
67
            .add(new SubMode("Legit"))
68
            .add(new SubMode("Grim"))
69
            .add(new SubMode("Intave"))
70
            .add(new SubMode("Old Intave"))
71
            .add(new SubMode("Imperfect Vanilla"))
72
            .add(new SubMode("Vanilla ReBlock"))
73
            .add(new SubMode("Watchdog 1.17"))
74
            .add(new SubMode("New NCP"))
75
            .add(new SubMode("Universal"))
76
            .add(new SubMode("Watchdog"))
77
            // .add(new SubMode("Watchdog2"))
78
            .setDefault("None");
79
80
    private final BooleanValue rightClickOnly = new BooleanValue("Right Click Only", this, false, () -> autoBlock.getValue().getName().equals("None") || autoBlock.getValue().getName().equals("Fake"));
81
    private final BooleanValue preventServerSideBlocking = new BooleanValue("Prevent Serverside Blocking", this, false, () -> !(autoBlock.getValue().getName().equals("None") || autoBlock.getValue().getName().equals("Fake")));
82
    private final ModeValue sorting = new ModeValue("Sorting", this)
83
            .add(new SubMode("Distance"))
84
            .add(new SubMode("Health"))
85
            .add(new SubMode("Hurt Time"))
86
            .setDefault("Distance");
87
    private final ModeValue clickMode = new ModeValue("Click Delay Mode", this)
88
            .add(new SubMode("Normal"))
89
            .add(new SubMode("Hit Select"))
90
            .add(new SubMode("1.9+"))
91
            .add(new SubMode("1.9+ With 1.8 Animations"))
92
            .setDefault("Normal");
93
    private final NumberValue range = new NumberValue("Range", this, 3, 3, 6, 0.1);
94
    private final BoundsNumberValue cps = new BoundsNumberValue("CPS", this, 10, 15, 1, 20, 1);
95
    private final BoundsNumberValue rotationSpeed = new BoundsNumberValue("Rotation speed", this, 5, 10, 0, 10, 1);
96
    private final ListValue<MovementFix> movementCorrection = new ListValue<>("Movement correction", this);
97
    private final BooleanValue keepSprint = new BooleanValue("Keep sprint", this, false);
98
99
    private final ModeValue espMode = new ModeValue("Target ESP Mode", this)
100
            .add(new SubMode("Ring"))
101
            .add(new SubMode("Box"))
102
            .add(new SubMode("None"))
103
            .setDefault("Ring");
104
105
    public final ModeValue boxMode = new ModeValue("Box Mode", this, () -> !(espMode.getValue()).getName().equals("Box"))
106
            .add(new SubMode("Above"))
107
            .add(new SubMode("Full"))
108
            .setDefault("Ring");
109
110
    private final BooleanValue rayCast = new BooleanValue("Ray cast", this, false);
111
    private final BooleanValue throughWalls = new BooleanValue("Through Walls", this, false, () -> !rayCast.getValue());
112
113
    private final BooleanValue advanced = new BooleanValue("Advanced", this, false);
114
    private final ModeValue rotationMode = new ModeValue("Rotation Mode", this, () -> !advanced.getValue())
115
            .add(new SubMode("Legit/Normal"))
116
            .add(new SubMode("Snap"))
117
            .add(new SubMode("NCP"))
118
            .add(new SubMode("Autistic AntiCheat"))
119
            .setDefault("Legit/Normal");
120
    private final BooleanValue attackWhilstScaffolding = new BooleanValue("Attack whilst Scaffolding", this, false, () -> !advanced.getValue());
121
    private final BooleanValue noSwing = new BooleanValue("No swing", this, false, () -> !advanced.getValue());
122
    private final BooleanValue autoDisable = new BooleanValue("Auto disable", this, false, () -> !advanced.getValue());
123
    private final BooleanValue showTargets = new BooleanValue("Targets", this, false);
124
    public final BooleanValue player = new BooleanValue("Player", this, true, () -> !showTargets.getValue());
125
    public final BooleanValue invisibles = new BooleanValue("Invisibles", this, false, () -> !showTargets.getValue());
126
    public final BooleanValue animals = new BooleanValue("Animals", this, false, () -> !showTargets.getValue());
127
    public final BooleanValue mobs = new BooleanValue("Mobs", this, false, () -> !showTargets.getValue());
128
    public final BooleanValue teams = new BooleanValue("Player Teammates", this, true, () -> !showTargets.getValue());
129
130
    private final Queue<Packet<?>> packetQueue = new ConcurrentLinkedQueue<>();
131
132
    private final StopWatch attackStopWatch = new StopWatch();
133
    private final StopWatch clickStopWatch = new StopWatch();
134
135
    private boolean blocking, swing, allowAttack;
136
    private long nextSwing;
137
138
    private List<EntityLivingBase> targets;
139
    public EntityLivingBase target;
140
141
    private int attack, expandRange, blockTicks, switchTicks;
142
    public int hitTicks;
143
    boolean shouldBlink;
144
    public boolean swingg;
145
146
    // Pointless to remember past 9 because hurt resistance is 10 ticks
147
    private final EvictingList<EntityLivingBase> pastTargets = new EvictingList<>(9);
148
149
    public KillAura() {
150
        for (MovementFix movementFix : MovementFix.values()) {
151
            movementCorrection.add(movementFix);
152
        }
153
154
        movementCorrection.setDefault(MovementFix.OFF);
155
    }
156
157
    @EventLink
158
    public final Listener<PreMotionEvent> onPreMotionEvent = event -> {
159
        this.packetQueue.forEach(PacketUtil::sendNoEvent);
160
        this.packetQueue.clear();
161
162
        this.hitTicks++;
163
164
        // Set blocking to false when switching items
165
        if (getComponent(Slot.class).getItemStack() == null || !(getComponent(Slot.class).getItemStack().getItem() instanceof ItemSword)) {
166
            blocking = false;
167
        }
168
169
        if (GUIDetectionComponent.inGUI()) {
170
            return;
171
        }
172
173
        if (target == null || mc.thePlayer.isDead || getModule(Scaffold.class).isEnabled()) {
174
            if (!BadPacketsComponent.bad()) {
175
                this.unblock(false);
176
                target = null;
177
            }
178
        }
179
        Color color = /*getTheme().getFirstColor()*/ Color.WHITE;
180
181
        switch (espMode.getValue().getName()) {
182
            case "Ring":
183
                ESPComponent.add(new SigmaRing(new ESPColor(color, color, color)));
184
                break;
185
            case "Box":
186
                switch (boxMode.getValue().getName()) {
187
                    case "Full":
188
                        ESPComponent.add(new FullBox(new ESPColor(color, color, color)));
189
                        break;
190
                    case "Above":
191
                        ESPComponent.add(new AboveBox(new ESPColor(color, color, color)));
192
                        break;
193
                }
194
                break;
195
        }
196
197
        if (autoBlock.getValue().getName().equals("Watchdog")) {
198
            if (target != null
199
                    && mc.thePlayer.getHeldItem() != null
200
                    && mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) {
201
                blockTicks++;
202
                if (blockTicks == 1) {
203
                    blockTicks = 0;
204
                    BlinkComponent.dispatch();
205
                }
206
207
                if (blockTicks == 0) {
208
                    MovingObjectPosition movingObjectPosition = mc.objectMouseOver;
209
                    mc.objectMouseOver = RayCastUtil.rayCast(RotationComponent.lastRotations, 3);
210
                    mc.rightClickMouse();
211
                    mc.objectMouseOver = movingObjectPosition;
212
                    BlinkComponent.blinking = true;
213
214
                }
215
            } else {
216
                BlinkComponent.dispatch();
217
            }
218
219
        }
220
    };
221
222
    @Override
223
    public void onEnable() {
224
        this.attack = 0;
225
        this.blockTicks = 0;
226
        this.nextSwing = 0;
227
//        Client.INSTANCE.setClickGUI(new RiseClickGUI());
228
    }
229
230
    @Override
231
    public void onDisable() {
232
        this.packetQueue.forEach(PacketUtil::sendNoEvent);
233
        this.packetQueue.clear();
234
        BlinkComponent.dispatch();
235
        target = null;
236
237
        this.unblock(false);
238
        mc.gameSettings.keyBindUseItem.setPressed(false);
239
        BlinkComponent.blinking = false;
240
    }
241
242
    @EventLink
243
    public final Listener<WorldChangeEvent> onWorldChange = event -> {
244
        if (this.autoDisable.getValue()) {
245
            this.toggle();
246
        }
247
    };
248
249
    public void getTargets() {
250
        double range = this.range.getValue().doubleValue();
251
252
        targets = TargetComponent.getTargets(range);
253
254
        if (mode.getValue().getName().equals("Switch")) {
255
            targets.removeAll(pastTargets);
256
        }
257
258
        if (targets.isEmpty()) {
259
            pastTargets.clear();
260
            targets = TargetComponent.getTargets(range + expandRange);
261
        }
262
263
        switch (sorting.getValue().getName()) {
264
            case "Health":
265
                targets.sort(Comparator.comparingDouble(EntityLivingBase::getHealth));
266
                sortByTargets();
267
                break;
268
269
            case "Hurt Time":
270
                targets.sort(Comparator.comparingDouble(entity -> entity.hurtTime));
271
                sortByTargets();
272
                break;
273
        }
274
    }
275
276
    private void sortByTargets() {
277
        targets.sort((o1, o2) -> {
278
            boolean isTarget1 = UserFriendAndTargetComponent.isTarget(o1.getCommandSenderName());
279
            boolean isTarget2 = UserFriendAndTargetComponent.isTarget(o2.getCommandSenderName());
280
            if (isTarget1 && !isTarget2) {
281
                return -1;
282
            } else if (!isTarget1 && isTarget2) {
283
                return 1;
284
            }
285
            return 0;
286
        });
287
    }
288
289
    @EventLink(value = Priorities.HIGH)
290
    public final Listener<PreUpdateEvent> onHighPreUpdate = event -> {
291
        if (RotationComponent.isSmoothed()) {
292
            return;
293
        }
294
295
        mc.entityRenderer.getMouseOver(1);
296
297
        this.allowAttack = !BadPacketsComponent.bad(false, false, false, true, true);
298
299
        if (mc.thePlayer.getHealth() <= 0.0 && this.autoDisable.getValue()) {
300
            this.toggle();
301
        }
302
303
        if (getModule(Scaffold.class).isEnabled() && !attackWhilstScaffolding.getValue()) {
304
            return;
305
        }
306
307
        this.attack = Math.max(Math.min(this.attack, this.attack - 2), 0);
308
309
        /*
310
         * Heuristic fix
311
         */
312
        if (mc.thePlayer.ticksExisted % 20 == 0) {
313
            expandRange = (int) (3 + Math.random() * 0.5);
314
        }
315
316
        if (GUIDetectionComponent.inGUI()) {
317
            return;
318
        }
319
320
        /*
321
         * Getting targets and selecting the nearest one
322
         */
323
        this.getTargets();
324
325
        if (targets.isEmpty()) {
326
            target = null;
327
            this.cantPreBlock();
328
            return;
329
        }
330
331
        target = targets.get(0);
332
333
        if (target == null || mc.thePlayer.isDead) {
334
            this.cantPreBlock();
335
            return;
336
        }
337
338
        if (this.canBlock()) {
339
            this.preBlock();
340
        } else {
341
            this.cantPreBlock();
342
        }
343
344
        /*
345
         * Calculating rotations to target
346
         */
347
        this.rotations();
348
    };
349
350
    // We attack on an event after all others, because other modules may have overridden the rotations
351
    // this way we won't attack if a module has overriden the killaura's rotations
352
    @EventLink()
353
    public final Listener<PreUpdateEvent> onMediumPriorityPreUpdate = event -> {
354
        if (target == null || mc.thePlayer.isDead) {
355
            return;
356
        }
357
358
        /*
359
         * Doing the attack
360
         */
361
        this.doAttack(targets);
362
363
        /*
364
         * Blocking
365
         */
366
        if (this.canBlock()) {
367
            this.postAttackBlock();
368
        }
369
    };
370
371
    public void cantPreBlock() {
372
        switch (autoBlock.getValue().getName()) {
373
            case "Universal":
374
                this.blockTicks = -1;
375
                break;
376
        }
377
    }
378
379
    public void rotations() {
380
        final float rotationSpeed = this.rotationSpeed.getRandomBetween().floatValue();
381
382
        switch (rotationMode.getValue().getName()) {
383
            case "Legit/Normal":
384
                Vector2f targetRotations = RotationUtil.calculate(target, true, range.getValue().doubleValue());
385
386
                if (rotationSpeed != 0) RotationComponent.setRotations(targetRotations, rotationSpeed,
387
                        movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue(),
388
                        rotations -> {
389
                            MovingObjectPosition movingObjectPosition = RayCastUtil.rayCast(rotations, range.getValue().floatValue(), -0.1f);
390
391
                            return movingObjectPosition != null && movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY;
392
                        });
393
                break;
394
395
            case "NCP":
396
                int predict = (int) (Math.random() * 1);
397
                Vector3d position = new Vector3d(target.posX, target.posY, target.posZ);
398
                Vector3d playerPosition = new Vector3d(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ);
399
                Vector3d predictedPosition = MoveUtil.predictMovement(target, new Vector2f(0, 1), predict, mc.thePlayer.isSprinting());
400
                target.setPosition(predictedPosition.x, predictedPosition.y, predictedPosition.z);
401
                mc.thePlayer.setPosition(mc.thePlayer.posX + mc.thePlayer.motionX * predict, mc.thePlayer.posY + (mc.thePlayer.motionY + 0.17) * predict, mc.thePlayer.posZ + mc.thePlayer.motionZ * predict);
402
                final Vector2f axis = RotationUtil.applySensitivityPatch(RotationUtil.calculate(target, true, range.getValue().doubleValue()));
403
                target.setPosition(position.x, position.y, position.z);
404
                mc.thePlayer.setPosition(playerPosition.x, playerPosition.y, playerPosition.z);
405
406
                if (rotationSpeed != 0) {
407
                    if (Math.random() > 0.1) {
408
                        RotationComponent.setRotations(axis, rotationSpeed,
409
                                movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue());
410
                    } else {
411
                        RotationComponent.setRotations(RotationComponent.targetRotations.add((float) ((Math.random() - 0.5) * 10), (float) ((Math.random() - 0.5) * 3)), rotationSpeed,
412
                                movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue());
413
414
                    }
415
                }
416
                //ChatUtil.display("Prediction Position: " + position.x + position.y + position.z);
417
                break;
418
419
            case "Snap":
420
                final Vector2f rotations = RotationUtil.calculate(target, true, range.getValue().doubleValue());
421
422
                if (rotationSpeed != 0 && lastSafeUnBlockTick()) {
423
                    RotationComponent.setRotations(rotations, rotationSpeed,
424
                            movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue());
425
                } else {
426
                    RotationComponent.setRotations(new Vector2f(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch), rotationSpeed, movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue());
427
                }
428
                break;
429
430
            case "Autistic AntiCheat":
431
                RotationComponent.setRotations(new Vector2f(RotationComponent.rotations.x + rotationSpeed * 10, 0), (rotationSpeed * 10) / 18,
432
                        movementCorrection.getValue() == MovementFix.OFF ? MovementFix.OFF : movementCorrection.getValue());
433
                break;
434
        }
435
436
    }
437
438
    @EventLink
439
    public final Listener<MouseOverEvent> onMouseOver = event ->
440
            event.setRange(event.getRange() + range.getValue().doubleValue() - 3);
441
442
    @EventLink
443
    public final Listener<PostMotionEvent> onPostMotion = event -> {
444
        if (target != null && this.canBlock()) {
445
            this.postBlock();
446
        }
447
    };
448
449
    public Tuple<Boolean, Double> getDelay() {
450
        double delay = -1;
451
        boolean flag = false;
452
453
        switch (clickMode.getValue().getName()) {
454
            case "1.9+ With 1.8 Animations":
455
            case "1.9+": {
456
                if (clickMode.getValue().getName().equals("1.9+ With 1.8 Animations") && Math.random() > 0.2) {
457
                    RenderUtil.renderAttack(target);
458
                }
459
460
                double speed = 4;
461
462
                if (mc.thePlayer.getHeldItem() != null) {
463
                    final Item item = mc.thePlayer.getHeldItem().getItem();
464
465
                    if (item instanceof ItemSword) {
466
                        speed = 1.6;
467
                    } else if (item instanceof ItemSpade) {
468
                        speed = 1;
469
                    } else if (item instanceof ItemPickaxe) {
470
                        speed = 1.2;
471
                    } else if (item instanceof ItemAxe) {
472
                        switch (((ItemAxe) item).getToolMaterial()) {
473
                            case WOOD:
474
                            case STONE:
475
                                speed = 0.8;
476
                                break;
477
478
                            case IRON:
479
                                speed = 0.9;
480
                                break;
481
482
                            default:
483
                                speed = 1;
484
                                break;
485
                        }
486
                    } else if (item instanceof ItemHoe) {
487
                        switch (((ItemHoe) item).getToolMaterial()) {
488
                            case WOOD:
489
                            case GOLD:
490
                                speed = 1;
491
                                break;
492
493
                            case STONE:
494
                                speed = 2;
495
                                break;
496
497
                            case IRON:
498
                                speed = 3;
499
                                break;
500
                        }
501
                    }
502
                }
503
504
                delay = 1 / speed * 20 - 1;
505
                break;
506
            }
507
        }
508
509
        delay = clickDelayBlock(delay);
510
511
        return new Tuple<>(flag, delay);
512
    }
513
514
    private void doAttack(final List<EntityLivingBase> targets) {
515
        Tuple<Boolean, Double> tuple = getDelay();
516
        final double delay = tuple.getSecond();
517
        final boolean flag = tuple.getFirst();
518
519
        if (attackStopWatch.finished(this.nextSwing) && target != null && (clickStopWatch.finished((long) (delay * 50)) || flag)) {
520
            final long clicks = (long) (this.cps.getRandomBetween().longValue() * 1.5);
521
            this.nextSwing = 1000 / clicks;
522
523
            if (Math.sin(nextSwing) + 1 > Math.random() || attackStopWatch.finished(this.nextSwing + 500) || Math.random() > 0.5) {
524
                if (this.allowAttack) {
525
                    /*
526
                     * Attacking target
527
                     */
528
                    final double range = this.range.getValue().doubleValue();
529
                    final Vec3 rotationVector = mc.thePlayer.getVectorForRotation(RotationComponent.rotations.getY(), RotationComponent.rotations.getX());
530
                    MovingObjectPosition movingObjectPosition = RayCastUtil.rayCast(RotationComponent.rotations, range);
531
532
                    if (throughWalls.getValue()) {
533
                        Vec3 eyes = mc.thePlayer.getPositionEyes(1);
534
                        movingObjectPosition = target.getEntityBoundingBox().expand(0.1, 0.1, 0.1).calculateIntercept(eyes,
535
                                eyes.addVector(rotationVector.xCoord * range, rotationVector.yCoord * range, rotationVector.zCoord * range));
536
537
                        if (movingObjectPosition != null) {
538
                            movingObjectPosition.typeOfHit = MovingObjectPosition.MovingObjectType.ENTITY;
539
                            movingObjectPosition.entityHit = target;
540
                        }
541
                    }
542
543
                    switch (this.mode.getValue().getName()) {
544
                        case "Switch":
545
                        case "Single": {
546
                            if ((mc.thePlayer.getDistanceToEntity(target) <= range && !rayCast.getValue()) ||
547
                                    (rayCast.getValue() && movingObjectPosition != null && movingObjectPosition.entityHit == target)) {
548
                                this.attack(target);
549
                            } else if (movingObjectPosition != null && movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
550
                                if (!(movingObjectPosition.entityHit instanceof EntityFireball))
551
                                    this.attack((EntityLivingBase) movingObjectPosition.entityHit);
552
                            } else {
553
                                switch (clickMode.getValue().getName()) {
554
                                    case "Normal":
555
                                    case "Hit Select":
556
                                        if (mc.playerController.curBlockDamageMP != 0) return;
557
//                                        PacketUtil.send(new C0APacketAnimation());
558
                                        break;
559
                                }
560
                            }
561
                            break;
562
                        }
563
564
                        case "Multiple": {
565
                            targets.removeIf(target -> mc.thePlayer.getDistanceToEntity(target) > range);
566
567
                            if (!targets.isEmpty()) {
568
                                targets.forEach(this::attack);
569
                            }
570
                            break;
571
                        }
572
                    }
573
574
                    this.attackStopWatch.reset();
575
                }
576
            }
577
        }
578
    }
579
580
    private boolean lastSafeUnBlockTick() {
581
        Tuple<Boolean, Double> tuple = getDelay();
582
        final double delay = tuple.getSecond();
583
        final boolean flag = tuple.getFirst();
584
585
        return attackStopWatch.finished(this.nextSwing - 50) && target != null && (clickStopWatch.finished((long) (delay * 50) - 50) || flag) && !(clickMode.getValue().getName().equals("Hit Select") && target.hurtTime > (PingComponent.getPing() / 50 - 1) && mc.thePlayer.ticksSinceVelocity > 11) && allowAttack;
586
    }
587
588
    private void attack(final EntityLivingBase target) {
589
        final AttackEvent event = new AttackEvent(target);
590
        Client.INSTANCE.getEventBus().handle(event);
591
592
        if (this.canBlock()) {
593
            this.attackBlock();
594
        }
595
596
        mc.thePlayer.swingItem();
597
        if (this.keepSprint.getValue()) {
598
            mc.playerController.syncCurrentPlayItem();
599
600
            PacketUtil.send(new C02PacketUseEntity(target, C02PacketUseEntity.Action.ATTACK));
601
602
            if (mc.thePlayer.fallDistance > 0 && !mc.thePlayer.onGround && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInWater() && !mc.thePlayer.isPotionActive(Potion.blindness) && mc.thePlayer.ridingEntity == null) {
603
                mc.thePlayer.onCriticalHit(target);
604
            }
605
        } else {
606
            mc.playerController.attackEntity(mc.thePlayer, target);
607
        }
608
609
//        if (target == mc.thePlayer || clickMode.getValue().getName().equals("Hit Select") && target.hurtTime > (PingComponent.getPing() / 50 + 1) && mc.thePlayer.ticksSinceVelocity > 11) {
610
//            return;
611
//        }
612
//
613
//        switchTicks++;
614
//        if (switchTicks >= switchDelay.getRandomBetween().intValue()) {
615
//            pastTargets.add(target);
616
//            switchTicks = 0;
617
//        }
618
//
619
//        this.attack = Math.min(Math.max(this.attack, this.attack + 2), 5);
620
//
621
//        if (!this.noSwing.getValue() && ViaLoadingBase.getInstance().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
622
//            Client.INSTANCE.getEventBus().handle(new ClickEvent());
623
//            mc.thePlayer.swingItem();
624
//        }
625
//
626
//        final AttackEvent event = new AttackEvent(target);
627
//        Client.INSTANCE.getEventBus().handle(event);
628
//
629
//        if (!event.isCancelled()) {
630
//            if (this.canBlock()) {
631
//                this.attackBlock();
632
//            }
633
//
634
//            if (this.keepSprint.getValue()) {
635
//                mc.playerController.syncCurrentPlayItem();
636
//
637
//                PacketUtil.send(new C02PacketUseEntity(event.getTarget(), C02PacketUseEntity.Action.ATTACK));
638
//
639
//                if (mc.thePlayer.fallDistance > 0 && !mc.thePlayer.onGround && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInWater() && !mc.thePlayer.isPotionActive(Potion.blindness) && mc.thePlayer.ridingEntity == null) {
640
//                    mc.thePlayer.onCriticalHit(target);
641
//                }
642
//            } else {
643
//                mc.playerController.attackEntity(mc.thePlayer, target);
644
//            }
645
//        }
646
//
647
//        if (!this.noSwing.getValue() && ViaLoadingBase.getInstance().getTargetVersion().newerThan(ProtocolVersion.v1_8)) {
648
//            Client.INSTANCE.getEventBus().handle(new ClickEvent());
649
//            mc.thePlayer.swingItem();
650
//        }
651
//
652
        this.clickStopWatch.reset();
653
        this.hitTicks = 0;
654
    }
655
656
    private void block(final boolean check, final boolean interact) {
657
        if (!blocking || !check) {
658
            MovingObjectPosition movingObjectPosition = RayCastUtil.rayCast(RotationComponent.lastRotations, 3);
659
660
            if (interact && movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
661
                this.interact(movingObjectPosition);
662
            }
663
664
//            ChatUtil.display("MC " + mc.thePlayer.getHeldItem());
665
//            ChatUtil.display("Rise " + getComponent(SlotComponent.class).getItemStack());
666
            PacketUtil.send(new C08PacketPlayerBlockPlacement(getComponent(Slot.class).getItemStack()));
667
668
            blocking = true;
669
        }
670
    }
671
672
    public void interact(MovingObjectPosition mouse) {
673
        if (!mc.playerController.isPlayerRightClickingOnEntity(mc.thePlayer, mouse.entityHit, mouse)) {
674
            mc.playerController.interactWithEntitySendPacket(mc.thePlayer, mouse.entityHit);
675
        }
676
    }
677
678
    private void unblock(final boolean swingCheck) {
679
        if (blocking && (!swingCheck || !swing)) {
680
            PacketUtil.send(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
681
            blocking = false;
682
        }
683
684
        if (mc.gameSettings.keyBindUseItem.isKeyDown() && getComponent(Slot.class).getItemStack() != null && getComponent(Slot.class).getItemStack().getItem() instanceof ItemSword) {
685
            //mc.gameSettings.keyBindUseItem.setPressed(false);
686
        }
687
    }
688
689
    @EventLink(value = Priorities.HIGH)
690
    public final Listener<RenderItemEvent> onRenderItem = event -> {
691
        if (target != null && !autoBlock.getValue().getName().equals("None") && this.canBlock()) {
692
            event.setEnumAction(EnumAction.BLOCK);
693
            event.setUseItem(true);
694
        }
695
    };
696
697
    int ticks = 0;
698
    @EventLink
699
    public final Listener<PacketSendEvent> onPacketSend = event -> {
700
        if (event.isCancelled()) {
701
            return;
702
        }
703
704
        final Packet<?> packet = event.getPacket();
705
706
        if (packet instanceof C0APacketAnimation) {
707
            swing = true;
708
        } else if (packet instanceof C03PacketPlayer) {
709
            swing = false;
710
        }
711
712
        this.packetBlock(event);
713
    };
714
715
    public double clickDelayBlock(double delay) {
716
        switch (autoBlock.getValue().getName()) {
717
            case "Universal":
718
                delay = blockTicks >= 4 ? -1 : 500;
719
                break;
720
        }
721
722
        return delay;
723
    }
724
725
    public void packetBlock(final PacketSendEvent event) {
726
        final Packet<?> p = event.getPacket();
727
728
        switch (autoBlock.getValue().getName()) {
729
            case "Intave": {
730
                if (p instanceof C03PacketPlayer) {
731
                    event.setCancelled();
732
                    this.unblock(false);
733
                    PacketUtil.sendNoEvent(p);
734
                    this.block(false, true);
735
                }
736
                break;
737
            }
738
739
        }
740
    }
741
742
    @EventLink
743
    public final Listener<RightClickEvent> onRightClick = event -> {
744
        if (target == null || getComponent(Slot.class).getItemStack() == null || !(getComponent(Slot.class).getItemStack().getItem() instanceof ItemSword))
745
            return;
746
747
        switch (autoBlock.getValue().getName()) {
748
            case "Fake":
749
            case "None":
750
                if (!preventServerSideBlocking.getValue() || getComponent(Slot.class).getItemStack() == null || !(getComponent(Slot.class).getItemStack().getItem() instanceof ItemSword)) {
751
                    return;
752
                }
753
754
                event.setCancelled();
755
                break;
756
757
            // case "Watchdog":
758
            case "Legit":
759
                break;
760
761
            default:
762
                event.setCancelled();
763
                break;
764
        }
765
    };
766
767
    @EventLink
768
    public final Listener<SlowDownEvent> onSlowDown = event -> {
769
        switch (autoBlock.getValue().getName()) {
770
            case "Legit":
771
//                event.setStrafeMultiplier(0.2f);
772
//                event.setForwardMultiplier(0.2f);
773
//                event.setCancelled(false);
774
//                event.setUseItem(true);
775
                break;
776
777
            case "Watchdog":
778
                //prevent from noslowing without a target or while using items when killaura is enabled
779
                if (target != null && mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)
780
                    event.setCancelled();
781
                break;
782
        }
783
    };
784
785
    private void attackBlock() {
786
//        switch (autoBlock.getValue().getName()) {
787
//            case "Legit":
788
//                break;
789
//        }
790
791
    }
792
793
    private void postAttackBlock() {
794
        switch (autoBlock.getValue().getName()) {
795
            case "Legit":
796
797
                break;
798
799
            case "Intave":
800
                this.block(false, false);
801
                break;
802
803
            case "Vanilla":
804
                if (this.hitTicks != 0) {
805
                    this.block(false, true);
806
                }
807
                break;
808
809
            case "Imperfect Vanilla":
810
                if (this.hitTicks == 1 && mc.thePlayer.isSwingInProgress && Math.random() > 0.1) {
811
                    this.block(false, true);
812
                }
813
                break;
814
815
            case "Vanilla ReBlock":
816
                if (this.hitTicks == 1 /*|| !this.blocking*/) {
817
                    this.block(false, true);
818
                }
819
                break;
820
        }
821
    }
822
823
    private void preBlock() {
824
        switch (autoBlock.getValue().getName()) {
825
            case "Legit":
826
                double range = PlayerUtil.calculatePerfectRangeToEntity(target);
827
                mc.gameSettings.keyBindUseItem.setPressed(range < 3 && hitTicks <= 5 && mc.thePlayer.ticksSinceVelocity >= 5);
828
                blockTicks++;
829
                if (mc.gameSettings.keyBindUseItem.isPressed() || mc.thePlayer.isUsingItem()) {
830
                    blockTicks = 0;
831
                }
832
833
                allowAttack = blockTicks >= 2;
834
835
                break;
836
837
            case "NCP":
838
            case "Intave":
839
                allowAttack = true;
840
                this.unblock(false);
841
                break;
842
843
            case "Grim":
844
                PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex() % 8 + 1));
845
                PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex()));
846
                this.block(false, false);
847
                break;
848
849
            case "Watchdog 1.17":
850
                PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex() % 8 + 1));
851
                PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex()));
852
                this.block(false, false);
853
                break;
854
855
            case "New NCP":
856
                if (this.blocking) {
857
                    PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex() % 8 + 1));
858
                    PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex()));
859
                    this.blocking = false;
860
                }
861
                break;
862
863
            case "Old Intave":
864
//                InventoryDeSyncComponent.setActive("/booster");
865
866
                if (mc.thePlayer.isUsingItem()) {
867
                    PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex() % 8 + 1));
868
                    PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex()));
869
                }
870
                break;
871
872
            case "Universal":
873
                if ((mc.playerController.curBlockDamageMP != 0 && mc.objectMouseOver.typeOfHit ==
874
                        MovingObjectPosition.MovingObjectType.BLOCK)) {
875
                    blockTicks = 0;
876
                    return;
877
                }
878
879
                blockTicks++;
880
                if (blockTicks > 5) blockTicks = 2;
881
882
                PingSpoofComponent.blink();
883
884
                switch (blockTicks) {
885
                    case 2:
886
                        this.block(false, true);
887
                        break;
888
889
                    case 3:
890
                        this.unblock(false);
891
                        break;
892
                }
893
894
                break;
895
896
            case "Watchdog":
897
898
//                allowAttack = false;
899
//                blockTicks++;
900
//                PingSpoofComponent.blink();
901
//
902
//                if (blockTicks == 1) {
903
//                    if (rayCast.getValue()) {
904
//                        mc.clickMouse();
905
//                    } else {
906
//                        attack(target);
907
//                    }
908
//                    mc.rightClickMouse();
909
//                } else if (blockTicks >= 2) {
910
//                    blockTicks = 0;
911
//                }
912
                break;
913
        }
914
    }
915
916
    private void postBlock() {
917
        switch (autoBlock.getValue().getName()) {
918
            case "NCP":
919
            case "New NCP":
920
                this.block(true, false);
921
                break;
922
923
            case "Universal":
924
                if (this.blockTicks == 2) {
925
                    PingSpoofComponent.dispatch();
926
                }
927
                break;
928
929
            case "Watchdog":
930
                if (blockTicks == 1) {
931
                    //PingSpoofComponent.dispatch();
932
                }
933
                break;
934
935
        }
936
    }
937
938
    public boolean canBlock() {
939
        return (!rightClickOnly.getValue() || mc.gameSettings.keyBindUseItem.isKeyDown()) && getComponent(Slot.class).getItemStack() != null && getComponent(Slot.class).getItemStack().getItem() instanceof ItemSword;
940
    }
941
}

What this file does

The 942-line module file contains the full module surface: the three attack modes (Single, Switch, Multiple), the click-delay calculator (getDelay() scales the attack interval by weapon material in the 1.9+ modes: 1.6 speed for swords, 1.0 for spades, 1.2 for pickaxes, per-material axe speeds 0.8-1.0, per-material hoe speeds 1-3, computed as 1/speed*20-1 ticks), the target pipeline (getTargets() with the pastTargets EvictingList of size 9 and the expandRange retry that expands the range by a random 3.0-3.5 blocks every 20 ticks when no targets are found), and the sort orders (Distance default, Health and Hurt Time each re-sorting with sortByTargets() so UserFriendAndTargetComponent-marked targets float to the front). The attack gate in doAttack() combines attackStopWatch.finished(nextSwing) with clickStopWatch.finished(delay*50) or the Hit Select flag, allowAttack from BadPacketsComponent, and the sin-based randomness gate; with keepSprint the C02PacketUseEntity is sent directly after syncCurrentPlayItem, otherwise playerController.attackEntity is used, and the critical-hit check fires when falling and not on a ladder, in water, blinded or riding.

The block/unblock pair is the auto-block core: block(check, interact) ray-casts from RotationComponent.lastRotations at range 3 and sends C08PacketPlayerBlockPlacement, unblock() sends C07PacketPlayerDigging RELEASE_USE_ITEM, and onRenderItem forces the block animation on the client. The Grim and Watchdog 1.17 preBlock modes send a paired C09PacketHeldItemChange to a different slot and back before blocking, which desyncs the server's held-item view while the client still renders the sword; New NCP and Old Intave emit the same C09 pair while the sword is blocked to mask the block state. Universal cycles blockTicks 2-3 with PingSpoofComponent.blink() and dispatch() inflating the transaction ping during the cycle, Intave cancels the outgoing C03, unblocks, re-sends it without events and re-blocks, and the Watchdog mode in onPreMotionEvent uses BlinkComponent.dispatch() plus a spoofed objectMouseOver to right-click with the last rotation.

Several settings are dead or broken in this revision. switchDelay is declared but only referenced inside the large commented block, so it never affects anything. The attack counter decays via Math.max(Math.min(this.attack, this.attack - 2), 0) but is never incremented anywhere (the increment lives in the same commented block), so it is permanently 0. pastTargets is never populated because the adding code is commented out, so Switch mode's removeAll(pastTargets) exclusion never excludes anything. The NCP rotation mode's predict is (int)(Math.random() * 1), which is always 0, so the movement prediction it feeds MoveUtil.predictMovement is a no-op, and the doAttack gate's Math.sin(nextSwing) + 1 > Math.random() is a meaningless random pass that still requires the watch timers. The MouseOverEvent handler extends the attack range by setRange(range - 3 + range), so a 6-range setting grants a 9-block mouse-over reach that only affects what the client's own ray cast can select, not the server's distance check.

source RotationComponent.java (rotation engine)

RotationComponent.java201 lines · JavaOriginal ↗
1
package com.alan.clients.component.impl.player;
2
3
import com.alan.clients.component.Component;
4
import com.alan.clients.component.impl.player.rotationcomponent.MovementFix;
5
import com.alan.clients.event.Listener;
6
import com.alan.clients.event.Priorities;
7
import com.alan.clients.event.annotations.EventLink;
8
import com.alan.clients.event.impl.input.MoveInputEvent;
9
import com.alan.clients.event.impl.motion.JumpEvent;
10
import com.alan.clients.event.impl.motion.PreMotionEvent;
11
import com.alan.clients.event.impl.motion.PreUpdateEvent;
12
import com.alan.clients.event.impl.motion.StrafeEvent;
13
import com.alan.clients.event.impl.render.LookEvent;
14
import com.alan.clients.util.player.MoveUtil;
15
import com.alan.clients.util.rotation.RotationUtil;
16
import com.alan.clients.util.vector.Vector2f;
17
import lombok.Getter;
18
import lombok.Setter;
19
import net.minecraft.util.MathHelper;
20
21
import java.util.function.Function;
22
23
public final class RotationComponent extends Component {
24
    @Setter@Getter
25
    private static boolean active, smoothed;
26
    public static Vector2f rotations, lastRotations = new Vector2f(0, 0), targetRotations, lastServerRotations;
27
    private static double rotationSpeed;
28
    private static MovementFix correctMovement;
29
    private static Function<Vector2f, Boolean> raycast;
30
    private static float randomAngle;
31
    private static final Vector2f offset = new Vector2f(0, 0);
32
33
    /*
34
     * This method must be called on Pre Update Event to work correctly
35
     */
36
    public static void setRotations(final Vector2f rotations, final double rotationSpeed, final MovementFix correctMovement) {
37
        setRotations(rotations, rotationSpeed, correctMovement, null);
38
    }
39
40
    /*
41
     * This method must be called on Pre Update Event to work correctly
42
     */
43
    public static void setRotations(final Vector2f rotations, final double rotationSpeed, final MovementFix correctMovement, final Function<Vector2f, Boolean> raycast) {
44
        RotationComponent.targetRotations = rotations;
45
        RotationComponent.rotationSpeed = rotationSpeed * 36;
46
        RotationComponent.correctMovement = correctMovement;
47
        RotationComponent.raycast = raycast;
48
        active = true;
49
50
        smooth();
51
    }
52
53
    @EventLink(value = Priorities.VERY_LOW)
54
    public final Listener<PreUpdateEvent> onPreUpdate = event -> {
55
        if (!active || rotations == null || lastRotations == null || targetRotations == null || lastServerRotations == null) {
56
            rotations = lastRotations = targetRotations = lastServerRotations = new Vector2f(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
57
        }
58
59
        if (active) {
60
            smooth();
61
        }
62
63
//        mc.thePlayer.rotationYaw = rotations.x;
64
//        mc.thePlayer.rotationPitch = rotations.y;
65
66
        if (correctMovement == MovementFix.BACKWARDS_SPRINT && active) {
67
            if (Math.abs(rotations.x % 360 - Math.toDegrees(MoveUtil.direction()) % 360) > 45) {
68
                mc.gameSettings.keyBindSprint.setPressed(false);
69
                mc.thePlayer.setSprinting(false);
70
            }
71
        }
72
    };
73
74
    @EventLink(value = Priorities.LOW)
75
    public final Listener<MoveInputEvent> onMove = event -> {
76
        if (active && correctMovement == MovementFix.NORMAL && rotations != null) {
77
            /*
78
             * Calculating movement fix
79
             */
80
            final float yaw = rotations.x;
81
            MoveUtil.fixMovement(event, yaw);
82
        }
83
    };
84
85
    @EventLink(value = Priorities.VERY_LOW)
86
    public final Listener<LookEvent> onLook = event -> {
87
        if (active && rotations != null) {
88
            event.setRotation(rotations);
89
        }
90
    };
91
92
    @EventLink(value = Priorities.VERY_LOW)
93
    public final Listener<StrafeEvent> onStrafe = event -> {
94
        if (active && (correctMovement == MovementFix.NORMAL || correctMovement == MovementFix.TRADITIONAL) && rotations != null) {
95
            event.setYaw(rotations.x);
96
        }
97
    };
98
99
    @EventLink(value = Priorities.VERY_LOW)
100
    public final Listener<JumpEvent> onJump = event -> {
101
        if (active && (correctMovement == MovementFix.NORMAL || correctMovement == MovementFix.TRADITIONAL || correctMovement == MovementFix.BACKWARDS_SPRINT) && rotations != null) {
102
            event.setYaw(rotations.x);
103
        }
104
    };
105
106
    @EventLink(value = Priorities.VERY_LOW)
107
    public final Listener<PreMotionEvent> onPreMotionEvent = event -> {
108
        if (active && rotations != null) {
109
            final float yaw = rotations.x;
110
            final float pitch = rotations.y;
111
112
            event.setYaw(yaw);
113
            event.setPitch(pitch);
114
115
          //  mc.thePlayer.renderYawOffset = yaw;
116
            mc.thePlayer.rotationYawHead = yaw;
117
            mc.thePlayer.renderPitchHead = pitch;
118
119
            lastServerRotations = new Vector2f(yaw, pitch);
120
121
            if (Math.abs((rotations.x - mc.thePlayer.rotationYaw) % 360) < 1 && Math.abs((rotations.y - mc.thePlayer.rotationPitch)) < 1) {
122
                active = false;
123
124
                this.correctDisabledRotations();
125
            }
126
127
            lastRotations = rotations;
128
        } else {
129
            lastRotations = new Vector2f(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
130
        }
131
132
        targetRotations = new Vector2f(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
133
        smoothed = false;
134
    };
135
136
    private void correctDisabledRotations() {
137
        final Vector2f rotations = new Vector2f(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
138
        final Vector2f fixedRotations = RotationUtil.resetRotation(RotationUtil.applySensitivityPatch(rotations, lastRotations));
139
140
        mc.thePlayer.rotationYaw = fixedRotations.x;
141
        mc.thePlayer.rotationPitch = fixedRotations.y;
142
    }
143
144
    public static void smooth() {
145
        if (!smoothed) {
146
            float targetYaw = targetRotations.x;
147
            float targetPitch = targetRotations.y;
148
149
            // Randomisation
150
            if (raycast != null && (Math.abs(targetYaw - rotations.x) > 5 || Math.abs(targetPitch - rotations.y) > 5)) {
151
                final Vector2f trueTargetRotations = new Vector2f(targetRotations.getX(), targetRotations.getY());
152
153
                double speed = /*Math.min(*/(Math.random() * Math.random() * Math.random()) * 20/*, MoveUtil.speed() * 30)*/;
154
                randomAngle += (float) ((20 + (float) (Math.random() - 0.5) * (Math.random() * Math.random() * Math.random() * 360)) * (mc.thePlayer.ticksExisted / 10 % 2 == 0 ? -1 : 1));
155
156
                offset.setX((float) (offset.getX() + -MathHelper.sin((float) Math.toRadians(randomAngle)) * speed));
157
                offset.setY((float) (offset.getY() + MathHelper.cos((float) Math.toRadians(randomAngle)) * speed));
158
159
                targetYaw += offset.getX();
160
                targetPitch += offset.getY();
161
162
                if (!raycast.apply(new Vector2f(targetYaw, targetPitch))) {
163
                    randomAngle = (float) Math.toDegrees(Math.atan2(trueTargetRotations.getX() - targetYaw, targetPitch - trueTargetRotations.getY())) - 180;
164
165
                    targetYaw -= offset.getX();
166
                    targetPitch -= offset.getY();
167
168
                    offset.setX((float) (offset.getX() + -MathHelper.sin((float) Math.toRadians(randomAngle)) * speed));
169
                    offset.setY((float) (offset.getY() + MathHelper.cos((float) Math.toRadians(randomAngle)) * speed));
170
171
                    targetYaw = targetYaw + offset.getX();
172
                    targetPitch = targetPitch + offset.getY();
173
                }
174
175
                if (!raycast.apply(new Vector2f(targetYaw, targetPitch))) {
176
                    offset.setX(0);
177
                    offset.setY(0);
178
179
                    targetYaw = (float) (targetRotations.x + Math.random() * 2);
180
                    targetPitch = (float) (targetRotations.y + Math.random() * 2);
181
                }
182
            }
183
184
            rotations = RotationUtil.smooth(new Vector2f(targetYaw, targetPitch),
185
                    rotationSpeed + Math.random());
186
187
            if (correctMovement == MovementFix.NORMAL || correctMovement == MovementFix.TRADITIONAL) {
188
                mc.thePlayer.movementYaw = rotations.x;
189
            }
190
191
            mc.thePlayer.velocityYaw = rotations.x;
192
        }
193
194
        smoothed = true;
195
196
        /*
197
         * Updating MouseOver
198
         */
199
        mc.entityRenderer.getMouseOver(1);
200
    }
201
}

What this file does

This is the shared rotation engine every combat module drives. setRotations() stores the target rotations, multiplies the caller's rotationSpeed by 36, stores the MovementFix mode and the optional raycast predicate, sets active, and immediately calls smooth(). smooth() is where the anti-detection work happens: when a raycast predicate is present and the target is more than 5 degrees away from the current rotations, it builds a randomized walk. The walk speed is (Math.random() * Math.random() * Math.random()) * 20, and randomAngle accumulates (20 + (random - 0.5) * random^3 * 360) with the whole term multiplied by -1 or +1 depending on whether ticksExisted / 10 is even, so the walk direction flips every 10 ticks. Each step advances a persistent offset vector by -sin(randomAngle) on x and cos(randomAngle) on y scaled by speed, adds it to the target, and tests the result with the raycast predicate; a miss sets randomAngle to the atan2-based reverse direction and re-advances the offset, and a second miss zeroes the offset and falls back to the raw target plus up to 2 degrees of random jitter. The final rotations come from RotationUtil.smooth(targetYaw, targetPitch, rotationSpeed + Math.random()), which interpolates with GCD-fixed per-iteration steps.

The component's event listeners apply the result everywhere the game reads the look: onLook overwrites the render event's rotations, onPreMotionEvent writes yaw/pitch into the outgoing motion packet, sets mc.thePlayer.rotationYawHead and renderPitchHead to the smoothed values, and records lastServerRotations so other code can see exactly what was sent. The movement fix is applied on MoveInputEvent (MoveUtil.fixMovement with the smoothed yaw for MovementFix.NORMAL), on StrafeEvent and JumpEvent (yaw override for NORMAL and TRADITIONAL, plus BACKWARDS_SPRINT on jump), and BACKWARDS_SPRINT additionally force-releases the sprint key when the smoothed yaw differs from the movement direction by more than 45 degrees, so the client does not sprint into the target. When the smoothed rotations come within 1 degree of the player's real rotations the component deactivates and correctDisabledRotations() snaps the view back onto the GCD grid using RotationUtil.resetRotation(RotationUtil.applySensitivityPatch(rotations, lastRotations)), which is what prevents the visible snap-back when the aura releases the look.

The rotation speed of every module is effectively capped by the * 36 multiplier in setRotations: KillAura's Rotation speed setting runs 0-10, so the effective per-tick smoothing speed is 0-360 with the + Math.random() jitter added on top. smooth() also writes rotations.x into movementYaw for NORMAL/TRADITIONAL and velocityYaw unconditionally, and finishes with mc.entityRenderer.getMouseOver(1) so the client-side mouse-over reflects the smoothed look immediately. The smoothed flag prevents re-smoothing within the same tick, and onPreUpdate re-initializes any null rotation state from the player's actual yaw/pitch so the engine self-heals when a module enables it mid-tick.

source RotationUtil.java

RotationUtil.java180 lines · JavaOriginal ↗
1
package com.alan.clients.util.rotation;
2
3
import com.alan.clients.component.impl.player.RotationComponent;
4
import com.alan.clients.util.Accessor;
5
import com.alan.clients.util.RayCastUtil;
6
import com.alan.clients.util.math.MathConst;
7
import com.alan.clients.util.vector.Vector2f;
8
import com.alan.clients.util.vector.Vector3d;
9
import lombok.experimental.UtilityClass;
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.entity.Entity;
12
import net.minecraft.util.*;
13
14
@UtilityClass
15
public class RotationUtil implements Accessor {
16
17
    public Vector2f calculate(final Vector3d from, final Vector3d to) {
18
        final Vector3d diff = to.subtract(from);
19
        final double distance = Math.hypot(diff.getX(), diff.getZ());
20
        final float yaw = (float) (MathHelper.atan2(diff.getZ(), diff.getX()) * MathConst.TO_DEGREES) - 90.0F;
21
        final float pitch = (float) (-(MathHelper.atan2(diff.getY(), distance) * MathConst.TO_DEGREES));
22
        return new Vector2f(yaw, pitch);
23
    }
24
25
    public Vector2f calculate(final Entity entity) {
26
        return calculate(entity.getCustomPositionVector().add(0, Math.max(0, Math.min(mc.thePlayer.posY - entity.posY +
27
                mc.thePlayer.getEyeHeight(), (entity.getEntityBoundingBox().maxY - entity.getEntityBoundingBox().minY) * 0.9)), 0));
28
    }
29
30
    public Vector2f calculate(final Entity entity, final boolean adaptive, final double range) {
31
        Vector2f normalRotations = calculate(entity);
32
        if (!adaptive || RayCastUtil.rayCast(normalRotations, range).typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
33
            return normalRotations;
34
        }
35
36
        for (double yPercent = 1; yPercent >= 0; yPercent -= 0.25 + Math.random() * 0.1) {
37
            for (double xPercent = 1; xPercent >= -0.5; xPercent -= 0.5) {
38
                for (double zPercent = 1; zPercent >= -0.5; zPercent -= 0.5) {
39
                    Vector2f adaptiveRotations = calculate(entity.getCustomPositionVector().add(
40
                            (entity.getEntityBoundingBox().maxX - entity.getEntityBoundingBox().minX) * xPercent,
41
                            (entity.getEntityBoundingBox().maxY - entity.getEntityBoundingBox().minY) * yPercent,
42
                            (entity.getEntityBoundingBox().maxZ - entity.getEntityBoundingBox().minZ) * zPercent));
43
44
                    if (RayCastUtil.rayCast(adaptiveRotations, range).typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
45
                        return adaptiveRotations;
46
                    }
47
                }
48
            }
49
        }
50
51
        return normalRotations;
52
    }
53
54
    public Vector2f calculate(final Vec3 to, final EnumFacing enumFacing) {
55
        return calculate(new Vector3d(to.xCoord, to.yCoord, to.zCoord), enumFacing);
56
    }
57
58
    public Vector2f calculate(final Vec3 to) {
59
        return calculate(mc.thePlayer.getCustomPositionVector().add(0, mc.thePlayer.getEyeHeight(), 0), new Vector3d(to.xCoord, to.yCoord, to.zCoord));
60
    }
61
62
    public Vector2f calculate(final BlockPos to) {
63
        return calculate(mc.thePlayer.getCustomPositionVector().add(0, mc.thePlayer.getEyeHeight(), 0), new Vector3d(to.getX(), to.getY(), to.getZ()).add(0.5, 0.5, 0.5));
64
    }
65
66
    public Vector2f calculate(final Vector3d to) {
67
        return calculate(mc.thePlayer.getCustomPositionVector().add(0, mc.thePlayer.getEyeHeight(), 0), to);
68
    }
69
70
    public Vector2f calculate(final Vector3d position, final EnumFacing enumFacing) {
71
        double x = position.getX() + 0.5D;
72
        double y = position.getY() + 0.5D;
73
        double z = position.getZ() + 0.5D;
74
75
        x += (double) enumFacing.getDirectionVec().getX() * 0.5D;
76
        y += (double) enumFacing.getDirectionVec().getY() * 0.5D;
77
        z += (double) enumFacing.getDirectionVec().getZ() * 0.5D;
78
        return calculate(new Vector3d(x, y, z));
79
    }
80
81
    public Vector2f applySensitivityPatch(final Vector2f rotation) {
82
        final Vector2f previousRotation = mc.thePlayer.getPreviousRotation();
83
        final float mouseSensitivity = (float) (mc.gameSettings.mouseSensitivity * (1 + Math.random() / 10000000) * 0.6F + 0.2F);
84
        final double multiplier = mouseSensitivity * mouseSensitivity * mouseSensitivity * 8.0F * 0.15D;
85
        final float yaw = previousRotation.x + (float) (Math.round((rotation.x - previousRotation.x) / multiplier) * multiplier);
86
        final float pitch = previousRotation.y + (float) (Math.round((rotation.y - previousRotation.y) / multiplier) * multiplier);
87
        return new Vector2f(yaw, MathHelper.clamp_float(pitch, -90, 90));
88
    }
89
90
    public Vector2f applySensitivityPatch(final Vector2f rotation, final Vector2f previousRotation) {
91
        final float mouseSensitivity = (float) (mc.gameSettings.mouseSensitivity * (1 + Math.random() / 10000000) * 0.6F + 0.2F);
92
        final double multiplier = mouseSensitivity * mouseSensitivity * mouseSensitivity * 8.0F * 0.15D;
93
        final float yaw = previousRotation.x + (float) (Math.round((rotation.x - previousRotation.x) / multiplier) * multiplier);
94
        final float pitch = previousRotation.y + (float) (Math.round((rotation.y - previousRotation.y) / multiplier) * multiplier);
95
        return new Vector2f(yaw, MathHelper.clamp_float(pitch, -90, 90));
96
    }
97
98
    public Vector2f relateToPlayerRotation(final Vector2f rotation) {
99
        final Vector2f previousRotation = mc.thePlayer.getPreviousRotation();
100
        final float yaw = previousRotation.x + MathHelper.wrapAngleTo180_float(rotation.x - previousRotation.x);
101
        final float pitch = MathHelper.clamp_float(rotation.y, -90, 90);
102
        return new Vector2f(yaw, pitch);
103
    }
104
105
    public Vector2f resetRotation(final Vector2f rotation) {
106
        if (rotation == null) {
107
            return null;
108
        }
109
110
        final float yaw = rotation.x + MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw - rotation.x);
111
        final float pitch = mc.thePlayer.rotationPitch;
112
        return new Vector2f(yaw, pitch);
113
    }
114
115
    public Vector2f move(final Vector2f targetRotation, final double speed) {
116
        return move(RotationComponent.lastRotations, targetRotation, speed);
117
    }
118
119
    public Vector2f move(final Vector2f lastRotation, final Vector2f targetRotation, double speed) {
120
        if (speed != 0) {
121
122
            double deltaYaw = MathHelper.wrapAngleTo180_float(targetRotation.x - lastRotation.x);
123
            final double deltaPitch = (targetRotation.y - lastRotation.y);
124
125
            final double distance = Math.sqrt(deltaYaw * deltaYaw + deltaPitch * deltaPitch);
126
            final double distributionYaw = Math.abs(deltaYaw / distance);
127
            final double distributionPitch = Math.abs(deltaPitch / distance);
128
129
            final double maxYaw = speed * distributionYaw;
130
            final double maxPitch = speed * distributionPitch;
131
132
            final float moveYaw = (float) Math.max(Math.min(deltaYaw, maxYaw), -maxYaw);
133
            final float movePitch = (float) Math.max(Math.min(deltaPitch, maxPitch), -maxPitch);
134
135
            return new Vector2f(moveYaw, movePitch);
136
        }
137
138
        return new Vector2f(0, 0);
139
    }
140
141
    public Vector2f smooth(final Vector2f targetRotation, final double speed) {
142
        return smooth(RotationComponent.lastRotations, targetRotation, speed);
143
    }
144
145
    public Vector2f smooth(final Vector2f lastRotation, final Vector2f targetRotation, final double speed) {
146
        float yaw = targetRotation.x;
147
        float pitch = targetRotation.y;
148
        final float lastYaw = lastRotation.x;
149
        final float lastPitch = lastRotation.y;
150
151
        if (speed != 0) {
152
            Vector2f move = move(targetRotation, speed);
153
154
            yaw = lastYaw + move.x;
155
            pitch = lastPitch + move.y;
156
157
            for (int i = 1; i <= (int) (Minecraft.getDebugFPS() / 20f + Math.random() * 10); ++i) {
158
159
                if (Math.abs(move.x) + Math.abs(move.y) > 0.0001) {
160
                    yaw += (Math.random() - 0.5) / 1000;
161
                    pitch -= Math.random() / 200;
162
                }
163
164
                /*
165
                 * Fixing GCD
166
                 */
167
                final Vector2f rotations = new Vector2f(yaw, pitch);
168
                final Vector2f fixedRotations = RotationUtil.applySensitivityPatch(rotations);
169
170
                /*
171
                 * Setting rotations
172
                 */
173
                yaw = fixedRotations.x;
174
                pitch = Math.max(-90, Math.min(90, fixedRotations.y));
175
            }
176
        }
177
178
        return new Vector2f(yaw, pitch);
179
    }
180
}

What this file does

The math behind every rotation. calculate(from, to) is the plain atan2 look: yaw = atan2(diffZ, diffX) - 90, pitch = -atan2(diffY, horizontalDistance). The entity overload aims at the target's custom position vector plus a vertical offset clamped between 0 and 90% of the entity's bounding box height, so the aim point tracks the victim's eye band instead of its feet. The adaptive overload used by KillAura's Legit/Normal and Snap modes first computes the normal rotations and ray-casts them at the given range; if that hits an entity it returns immediately, otherwise it sweeps a grid of candidate aim points, decrementing yPercent from 1 to 0 in steps of 0.25 + random * 0.1 and x/z percents from 1 to -0.5 in steps of 0.5, and returns the first grid point whose ray cast hits an entity, falling back to the normal rotations if none do. That sweep is what lets the module aim at an exposed edge or chest of a target whose head ray is blocked.

applySensitivityPatch is the GCD fix. It computes mouseSensitivity = (mc.gameSettings.mouseSensitivity * (1 + Math.random() / 10000000) * 0.6 + 0.2), then multiplier = sensitivity^3 * 8.0 * 0.15 (equivalently sensitivity^3 * 1.2), and rounds the rotation delta to the nearest multiple of that multiplier relative to the previous rotation, clamping pitch to -90..90. The tiny random perturbation on sensitivity (1 + random/1e7) varies the multiplier imperceptibly so the quantized deltas do not form an exact repeating pattern. Every smoothing iteration in smooth() applies the patch, which is what keeps the whole yaw/pitch stream on the grid a real mouse at that sensitivity could produce. The NCP rotation mode applies it to the predicted axis before handing it to the engine.

smooth()/move() implement the actual interpolation: move() distributes the per-tick speed across yaw and pitch in proportion to the remaining deltas (so a mostly-yaw target turn spends most of the speed on yaw), and smooth() applies move() then loops for (Minecraft.getDebugFPS() / 20f + Math.random() * 10) iterations, adding micro-jitter (yaw += (random - 0.5) / 1000, pitch -= random / 200) and re-patching the GCD each iteration, finally clamping pitch. resetRotation() and relateToPlayerRotation() wrap the delta into the -180..180 range relative to the player's real rotation, and resetRotation() is what RotationComponent.correctDisabledRotations() uses to return the view to the player's actual yaw/pitch on the GCD grid when the aura stops aiming.

source MovementFix.java

MovementFix.java18 lines · JavaOriginal ↗
1
package com.alan.clients.component.impl.player.rotationcomponent;
2
3
import lombok.AllArgsConstructor;
4
5
@AllArgsConstructor
6
public enum MovementFix {
7
    OFF("Off"),
8
    NORMAL("Rise"),
9
    TRADITIONAL("Traditional"),
10
    BACKWARDS_SPRINT("Backwards Sprint");
11
12
    final String name;
13
14
    @Override
15
    public String toString() {
16
        return name;
17
    }
18
}

What this file does

The enum that selects how the rotation engine rewrites the player's movement input while the aura is aiming. OFF leaves the input untouched, which is the default KillAura setting (movementCorrection.setDefault(MovementFix.OFF)). NORMAL (displayed as Rise) rewrites the movement input yaw to the smoothed rotations.yaw via MoveUtil.fixMovement on MoveInputEvent and additionally forces movementYaw and velocityYaw to the smoothed yaw, which keeps strafe and forward input aligned with the aim direction so the player moves exactly where the aura looks without the server seeing movement that disagrees with the yaw in the motion packets. TRADITIONAL applies the yaw override only on StrafeEvent and JumpEvent without the MoveInput rewrite, the classic fix used by older clients. BACKWARDS_SPRINT releases the sprint key whenever the smoothed yaw is more than 45 degrees away from the movement direction, preventing the player from sprinting toward a target the aura is not actually facing while allowing sprint in the aim direction.

The enum is constructed with Lombok @AllArgsConstructor and stores a display name per constant, so the KillAura's movementCorrection ListValue can iterate MovementFix.values() in the constructor to populate the dropdown. The rotation engine branches on the enum in three places: onMove (NORMAL only), onStrafe and onJump (NORMAL and TRADITIONAL, plus BACKWARDS_SPRINT on jump), and smooth() (NORMAL and TRADITIONAL set movementYaw). BACKWARDS_SPRINT is handled in onPreUpdate by comparing Math.abs(rotations.x % 360 - Math.toDegrees(MoveUtil.direction()) % 360) against 45 degrees and pressing/releasing the sprint bind accordingly.

The distinction between NORMAL and TRADITIONAL matters for anticheat geometry: NORMAL rewrites the raw input so the client-side movement vector and the sent yaw always agree, which keeps serverside prediction consistent, while TRADITIONAL only touches the strafe/jump yaw and leaves the input vector alone, which is the mode for servers that compare the pre-move yaw with the post-move delta. OFF is the mode that lets the player move in any direction relative to the aim, which the movement checks on strict servers flag when the aura spins the yaw faster than the movement can follow.

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 Reach (lag-compensated ray trace with hitbox result)

Reach.java404 lines · Java
1
// This file was designed and is an original check for GrimAC
2
// Copyright (C) 2021 DefineOutside
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
package ac.grim.grimac.checks.impl.combat;
17
18
import ac.grim.grimac.api.config.ConfigManager;
19
import ac.grim.grimac.api.storage.verbose.Verbose;
20
import ac.grim.grimac.checks.Check;
21
import ac.grim.grimac.checks.CheckData;
22
import ac.grim.grimac.checks.type.PacketReceiveListener;
23
import ac.grim.grimac.player.GrimPlayer;
24
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
25
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
26
import ac.grim.grimac.utils.data.packetentity.PacketEntitySizeable;
27
import ac.grim.grimac.utils.data.packetentity.dragon.PacketEntityEnderDragonPart;
28
import ac.grim.grimac.utils.math.Vector3dm;
29
import ac.grim.grimac.utils.nmsutil.ReachUtils;
30
import ac.grim.grimac.utils.viaversion.ViaVersionUtil;
31
import com.github.retrooper.packetevents.PacketEvents;
32
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
33
import com.github.retrooper.packetevents.manager.server.ServerVersion;
34
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
35
import com.github.retrooper.packetevents.protocol.component.ComponentTypes;
36
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttackRange;
37
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
38
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
39
import com.github.retrooper.packetevents.protocol.item.ItemStack;
40
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
41
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
42
import com.github.retrooper.packetevents.protocol.player.GameMode;
43
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
44
import com.github.retrooper.packetevents.util.Vector3d;
45
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientAttack;
46
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
47
import com.viaversion.viaversion.api.Via;
48
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
49
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
50
import org.jetbrains.annotations.NotNull;
51
52
import java.util.ArrayList;
53
import java.util.Arrays;
54
import java.util.Collections;
55
import java.util.List;
56
57
// You may not copy the check unless you are licensed under GPL
58
@CheckData(name = "Reach", stableKey = "grim.combat.reach", description = "Attacked an entity from too far away")
59
public class Reach extends Check implements PacketReceiveListener {
60
    private static final Verbose V = Verbose.of("{f64:%.5f} blocks, type={entity}");
61
62
    private static final List<EntityType> blacklisted = Arrays.asList(
63
            EntityTypes.BOAT,
64
            EntityTypes.CHEST_BOAT,
65
            EntityTypes.SHULKER);
66
    private static final CheckResult NONE = new CheckResult(ResultType.NONE, 0, 0, false);
67
    // Only one flag per reach attack, per entity, per tick.
68
    // We store position because lastX isn't reliable on teleports.
69
    private final Int2ObjectMap<InteractionData> playerAttackQueue = new Int2ObjectOpenHashMap<>();
70
    private boolean cancelImpossibleHits;
71
    private double threshold;
72
    private double cancelBuffer; // For the next 4 hits after using reach, we aggressively cancel reach
73
74
    public Reach(GrimPlayer player) {
75
        super(player);
76
    }
77
78
    @Override
79
    public void onPacketReceive(final PacketReceiveEvent event) {
80
        if (!player.disableGrim && event.getPacketType() == PacketType.Play.Client.ATTACK) {
81
            WrapperPlayClientAttack packet = new WrapperPlayClientAttack(event);
82
            onInteract(event, packet.getEntityId(), InteractionHand.MAIN_HAND);
83
        }
84
85
        if (!player.disableGrim && event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
86
            WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event);
87
            onInteract(event, packet.getEntityId(), packet.getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK ? InteractionHand.MAIN_HAND : packet.getHand());
88
        }
89
90
        // If the player set their look, or we know they have a new tick
91
        if (isUpdate(event.getPacketType())) {
92
            tickBetterReachCheckWithAngle();
93
        }
94
    }
95
96
    private void onInteract(PacketReceiveEvent event, int entityId, InteractionHand hand) {
97
        // Don't let the player teleport to bypass reach
98
        if (player.getSetbackTeleportUtil().shouldBlockMovement()) {
99
            event.setCancelled(true);
100
            player.onPacketCancel();
101
            return;
102
        }
103
104
        PacketEntity entity = player.compensatedEntities.entityMap.get(entityId);
105
        // Stop people from freezing transactions before an entity spawns to bypass reach
106
        // TODO: implement dragon parts?
107
        if (entity == null || entity instanceof PacketEntityEnderDragonPart) {
108
            // Only cancel if and only if we are tracking this entity
109
            // This is because we don't track paintings.
110
            if (shouldModifyPackets() && player.compensatedEntities.serverPositionsMap.containsKey(entityId)) {
111
                event.setCancelled(true);
112
                player.onPacketCancel();
113
            }
114
            return;
115
        }
116
117
        // Dead entities cause false flags (https://github.com/GrimAnticheat/Grim/issues/546)
118
        if (entity.isDead) return;
119
120
        // TODO: Remove when in front of via
121
        if (entity.getType() == EntityTypes.ARMOR_STAND && player.getClientVersion().isOlderThan(ClientVersion.V_1_8))
122
            return;
123
        // Prevents Happy Ghast Reach false on 1.21.6+ servers with ViaBackwards set up
124
        if (entity.getType() == EntityTypes.HAPPY_GHAST && player.getClientVersion().isOlderThan(ClientVersion.V_1_21_6))
125
            return;
126
        if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
127
            return;
128
        if (player.inVehicle()) return;
129
        if (entity.riding != null) return;
130
131
        ItemStack currentStack = player.inventory.getItemInHand(hand);
132
        ItemStack startStack = player.inventory.getStartOfTickStack();
133
134
        boolean hasRange = false;
135
        float maxReach = 0f;
136
        float hitboxMargin = 0f;
137
        Vector3dm attackRangeMovement = null;
138
139
        boolean clientAttackRangeExists = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_11);
140
        boolean clientAndServerAgrees = clientAttackRangeExists && ATTACK_RANGE_COMPONENT_EXISTS;
141
142
        boolean viaVersionAvailable = false;
143
        if (USE_1_8_HITBOX_MARGIN && ViaVersionUtil.isAvailable) {
144
            viaVersionAvailable = Via.getConfig().getValues().containsKey("use-1_8-hitbox-margin") && Via.getConfig().use1_8HitboxMargin();
145
        }
146
147
        boolean clientAndViaVersion = clientAttackRangeExists && viaVersionAvailable;
148
        if (clientAndServerAgrees || clientAndViaVersion) {
149
            ItemAttackRange startRange = startStack.getComponentOr(ComponentTypes.ATTACK_RANGE, null);
150
            ItemAttackRange currentRange = currentStack.getComponentOr(ComponentTypes.ATTACK_RANGE, null);
151
152
            if (clientAndViaVersion) {
153
                if (startStack != ItemStack.EMPTY) {
154
                    startRange = new ItemAttackRange(0F, 3F, 0F, 4F, 0.1F, 1F);
155
                }
156
157
                if (currentStack != ItemStack.EMPTY) {
158
                    currentRange = new ItemAttackRange(0F, 3F, 0F, 4F, 0.1F, 1F);
159
                }
160
            }
161
162
            // If the start stack has no range component, the client defaults to vanilla reach behavior,
163
            // regardless of what the current stack is (No Range -> X = No Range used).
164
            if (startRange != null) {
165
                hasRange = true;
166
                if (currentRange == null) {
167
                    // Range (Start) -> No Range (Current)
168
                    // Client logic uses Start Range, including the attack_range movement projection.
169
                    if (!clientAndViaVersion) {
170
                        attackRangeMovement = player.clientVelocity.clone();
171
                    }
172
                    maxReach = startRange.getMaxRange();
173
                    hitboxMargin = startRange.getHitboxMargin();
174
                } else {
175
                    // Range (Start) -> Range (Current)
176
                    // Client logic requires satisfying BOTH constraints
177
                    maxReach = Math.min(startRange.getMaxRange(), currentRange.getMaxRange());
178
                    hitboxMargin = Math.min(startRange.getHitboxMargin(), currentRange.getHitboxMargin());
179
                }
180
            }
181
        }
182
183
        boolean tooManyAttacks = playerAttackQueue.size() > 10;
184
        if (!tooManyAttacks) {
185
            playerAttackQueue.put(entityId, new InteractionData(
186
                    player.x, player.y, player.z,
187
                    hasRange, maxReach, hitboxMargin, attackRangeMovement
188
            )); // Queue for next tick for very precise check
189
        }
190
191
        boolean knownInvalid = attackRangeMovement == null && isKnownInvalid(entity, hasRange, maxReach, hitboxMargin);
192
193
        if ((shouldModifyPackets() && cancelImpossibleHits && knownInvalid) || tooManyAttacks) {
194
            event.setCancelled(true);
195
            player.onPacketCancel();
196
        }
197
    }
198
199
    // This method finds the most optimal point at which the user should be aiming at
200
    // and then measures the distance between the player's eyes and this target point
201
    //
202
    // It will not cancel every invalid attack but should cancel 3.05+ or so in real-time
203
    // Let the post look check measure the distance, as it will always return equal or higher
204
    // than this method.  If this method flags, the other method WILL flag.
205
    //
206
    // Meaning that the other check should be the only one that flags.
207
    private boolean isKnownInvalid(PacketEntity reachEntity, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin) {
208
        // If the entity doesn't exist, or if it is exempt, or if it is dead
209
        if ((blacklisted.contains(reachEntity.getType()) || !reachEntity.isLivingEntity) && reachEntity.getType() != EntityTypes.END_CRYSTAL)
210
            return false; // exempt
211
212
        if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
213
            return false;
214
        if (player.inVehicle()) return false;
215
216
        // Filter out what we assume to be cheats
217
        if (cancelBuffer != 0) {
218
            CheckResult result = checkReach(reachEntity, player.x, player.y, player.z, hasAttackRange, itemMaxReach, itemHitboxMargin, null, true);
219
            return result.isFlag();
220
        } else {
221
            SimpleCollisionBox targetBox = getTargetBox(reachEntity);
222
223
            double maxReach = applyReachModifiers(targetBox, hasAttackRange, itemMaxReach, itemHitboxMargin, !player.packetStateData.didLastMovementIncludePosition);
224
            return ReachUtils.getMinReachToBox(player, targetBox) > maxReach;
225
        }
226
    }
227
228
    private void tickBetterReachCheckWithAngle() {
229
        for (Int2ObjectMap.Entry<InteractionData> attack : playerAttackQueue.int2ObjectEntrySet()) {
230
            PacketEntity reachEntity = player.compensatedEntities.entityMap.get(attack.getIntKey());
231
            if (reachEntity == null) continue;
232
233
            InteractionData interactionData = attack.getValue();
234
            CheckResult result = checkReach(reachEntity, interactionData.x, interactionData.y, interactionData.z, interactionData.hasAttackRange, interactionData.maxReach, interactionData.hitboxMargin, interactionData.attackRangeMovement, false);
235
            switch (result.type()) {
236
                case REACH -> flag(
237
                        V.write(verbose()).f64(result.minDistance()).uint(reachEntity.getType().getId(player.getClientVersion())),
238
                        () -> {
239
                            String added = ", type=" + reachEntity.getType().getName().getKey();
240
                            if (reachEntity instanceof PacketEntitySizeable sizeable) {
241
                                added += ", size=" + sizeable.size;
242
                            }
243
                            return result.verbose() + added;
244
                        });
245
                case HITBOX -> {
246
                    String added = "type=" + reachEntity.getType().getName().getKey();
247
                    if (reachEntity instanceof PacketEntitySizeable sizeable) {
248
                        added += ", size=" + sizeable.size;
249
                    }
250
                    player.checkManager.getCheck(Hitboxes.class).flag(result.verbose() + added);
251
                }
252
            }
253
        }
254
255
        playerAttackQueue.clear();
256
    }
257
258
    @NotNull
259
    private CheckResult checkReach(PacketEntity reachEntity, double x, double y, double z, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin, Vector3dm attackRangeMovement, boolean isPrediction) {
260
        SimpleCollisionBox targetBox = getTargetBox(reachEntity);
261
262
        double movementAllowance = attackRangeMovement == null ? 0 : getAttackRangeMovementAllowance(attackRangeMovement);
263
        double maxReach = applyReachModifiers(targetBox, hasAttackRange, itemMaxReach, itemHitboxMargin, !player.packetStateData.didLastLastMovementIncludePosition) + movementAllowance;
264
        double minDistance = Double.MAX_VALUE;
265
266
        // https://bugs.mojang.com/browse/MC-67665
267
        List<Vector3dm> possibleLookDirs = new ArrayList<>(Collections.singletonList(ReachUtils.getLook(player, player.yaw, player.pitch)));
268
269
        // If we are a tick behind, we don't know their next look so don't bother doing this
270
        if (!isPrediction) {
271
            // 1.7 players do not have any of these issues! They are always on the latest look vector
272
            if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8)) {
273
                possibleLookDirs.add(ReachUtils.getLook(player, player.lastYaw, player.pitch));
274
275
                // 1.9+ players could be a tick behind because we don't get skipped ticks
276
                if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) {
277
                    possibleLookDirs.add(ReachUtils.getLook(player, player.lastYaw, player.lastPitch));
278
                }
279
            }
280
        }
281
282
        // +3 would be 3 + 3 = 6, which is the pre-1.20.5 behaviour, preventing "Missed Hitbox"
283
        final double distance = maxReach + 3;
284
285
        final double[] possibleEyeHeights = player.getPossibleEyeHeights();
286
        for (Vector3dm lookVec : possibleLookDirs) {
287
            lookVec.multiply(distance);
288
289
            for (double eye : possibleEyeHeights) {
290
                final Vector3d eyePos = new Vector3d(x, y + eye, z);
291
                Vector3d endReachPos = eyePos.add(lookVec.getX(), lookVec.getY(), lookVec.getZ());
292
293
                Vector3d intercept = ReachUtils.calculateIntercept(targetBox, eyePos, endReachPos).first();
294
295
                if (ReachUtils.isVecInside(targetBox, eyePos)) {
296
                    minDistance = 0;
297
                    break;
298
                }
299
300
                if (intercept != null) {
301
                    minDistance = Math.min(eyePos.distance(intercept), minDistance);
302
                }
303
            }
304
        }
305
306
        // if the entity is not exempt and the entity is alive
307
        if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity) || reachEntity.getType() == EntityTypes.END_CRYSTAL) {
308
            if (minDistance == Double.MAX_VALUE) {
309
                cancelBuffer = 1;
310
                return new CheckResult(ResultType.HITBOX, 0, 0, false);
311
            } else if (minDistance > maxReach) {
312
                cancelBuffer = 1;
313
                return new CheckResult(ResultType.REACH, minDistance, movementAllowance, attackRangeMovement != null);
314
            } else {
315
                cancelBuffer = Math.max(0, cancelBuffer - 0.25);
316
            }
317
        }
318
319
        return NONE;
320
    }
321
322
    private SimpleCollisionBox getTargetBox(PacketEntity reachEntity) {
323
        if (reachEntity.getType() == EntityTypes.END_CRYSTAL) { // Hardcode end crystal box
324
            return new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
325
        }
326
        return reachEntity.getPossibleCollisionBoxes();
327
    }
328
329
    private double getAttackRangeMovementAllowance(Vector3dm attackRangeMovement) {
330
        if (attackRangeMovement.lengthSquared() == 0) {
331
            return 0;
332
        }
333
334
        return getForwardMovement(attackRangeMovement, player.yaw, player.pitch);
335
    }
336
337
    private double getForwardMovement(Vector3dm movement, float yaw, float pitch) {
338
        return Math.max(0, movement.dot(ReachUtils.getLook(player, yaw, pitch)));
339
    }
340
341
    private static final boolean ATTACK_RANGE_COMPONENT_EXISTS = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21_11);
342
    private static final boolean USE_1_8_HITBOX_MARGIN = PacketEvents.getAPI().getServerManager().getVersion().isOlderThanOrEquals(ServerVersion.V_1_8_8);
343
344
    private double applyReachModifiers(SimpleCollisionBox targetBox, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin, boolean giveMovementThreshold) {
345
        double maxReach;
346
        double hitboxMargin = threshold;
347
348
        if (hasAttackRange) {
349
            maxReach = itemMaxReach;
350
            hitboxMargin += itemHitboxMargin;
351
        } else {
352
            maxReach = player.compensatedEntities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
353
            // 1.7 and 1.8 players get a bit of extra hitbox (this is why you should use 1.8 on cross version servers)
354
            // Yes, this is vanilla and not uncertainty.  All reach checks have this or they are wrong.
355
            if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) {
356
                hitboxMargin += 0.1f;
357
            }
358
        }
359
360
        // This is better than adding to the reach, as 0.03 can cause a player to miss their target
361
        // Adds some more than 0.03 uncertainty in some cases, but a good trade off for simplicity
362
        //
363
        // Just give the uncertainty on 1.9+ clients as we have no way of knowing whether they had 0.03 movement
364
        // However, on 1.21.2+ we do know if they had 0.03 movement
365
        if (giveMovementThreshold || player.canSkipTicks()) {
366
            hitboxMargin += player.getMovementThreshold();
367
        }
368
369
        targetBox.expand(hitboxMargin);
370
371
        return maxReach;
372
    }
373
374
    @Override
375
    public void onReload(@NotNull ConfigManager config) {
376
        this.cancelImpossibleHits = config.getBooleanElse("Reach.block-impossible-hits", true);
377
        this.threshold = config.getDoubleElse("Reach.threshold", 0.0005);
378
    }
379
380
    private enum ResultType {
381
        REACH, HITBOX, NONE
382
    }
383
384
    private record CheckResult(ResultType type, double minDistance, double extraMovement, boolean hasExtraMovement) {
385
        public boolean isFlag() {
386
            return type != ResultType.NONE;
387
        }
388
389
        public String verbose() {
390
            if (type != ResultType.REACH) {
391
                return "";
392
            }
393
394
            String verbose = String.format("%.5f", minDistance) + " blocks";
395
            if (hasExtraMovement) {
396
                verbose += String.format(", extraMovement=%.5f", extraMovement);
397
            }
398
            return verbose;
399
        }
400
    }
401
402
    private record InteractionData(double x, double y, double z, boolean hasAttackRange,
403
                                   float maxReach, float hitboxMargin, Vector3dm attackRangeMovement) {}
404
}

How it counteracts this module

Grim's Reach is a two-phase check. On the ATTACK or INTERACT_ENTITY packet, onInteract() queues the player's position with the entity id into playerAttackQueue (capped at 10 entries per tick, so the 11th attack in a tick is cancelled outright), and on the next look or position update tickBetterReachCheckWithAngle() runs the precise pass: for each possible look direction it builds the ray from the queued position. For 1.8+ clients the possible look directions include both the current yaw/pitch and the last-tick yaw/pitch, because 1.8 clients send the attack a tick before the yaw update; 1.9+ clients get a third combination. Each ray is cast from every possible eye height and intersected against the packet-entity's collision box, and the minimum intercept distance is compared to the reach limit, which for pre-1.9 clients includes the 0.1 hitbox margin plus the movement threshold. No intercept at all returns the HITBOX result routed to the Hitboxes check, and a distance over the limit returns REACH; cancelBuffer then aggressively cancels the next four hits.

KillAura's range setting goes to 6, so every attack beyond the vanilla 3.0-3.1 limit flags the REACH branch the instant the tick-end pass runs. The Multiple mode is hit twice: targets beyond range are removed client-side but each survivor's attack packet is still measured, and attacking more than 10 entities in one tick trips the queue cap and cancels the extras outright. The Legit/Normal smoothing walk cannot help, because Grim tests the actual server-observed look vectors (including the last-tick look the smoothing walk produces) against the server-tracked hitbox, and the module's intermediate rotations are sampled as the look when the attack lands. cancelImpossibleHits also cancels attacks on entities that have not spawned yet, which catches the module attacking through a freshly toggled ESP or a lagged-out player.

What survives is the Legit/Normal rotation mode at default range with rayCast on: the ray-cast predicate keeps every interpolated rotation inside the target hitbox, and at 3.0 blocks the measured distance stays under the 3.1 limit, so the check returns NONE. Anything above the limit, the Autistic AntiCheat spin mode (which points the yaw away from the target most of the time), or a wall-attack through the throughWalls 0.1 box expansion accumulates flags; the HITBOX branch in particular fires when the ray misses the expanded box entirely, which throughWalls attacks regularly do when Grim's possible look directions exclude the module's computed ray.

anticheat fight.Angle (multi-target stream analysis)

Angle.java255 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.fight;
16
17
import java.util.Iterator;
18
import java.util.LinkedList;
19
import java.util.List;
20
import java.util.UUID;
21
22
import org.bukkit.ChatColor;
23
import org.bukkit.Location;
24
import org.bukkit.entity.Entity;
25
import org.bukkit.entity.Player;
26
27
import fr.neatmonster.nocheatplus.actions.ParameterName;
28
import fr.neatmonster.nocheatplus.checks.Check;
29
import fr.neatmonster.nocheatplus.checks.CheckType;
30
import fr.neatmonster.nocheatplus.checks.ViolationData;
31
import fr.neatmonster.nocheatplus.permissions.Permissions;
32
import fr.neatmonster.nocheatplus.players.IPlayerData;
33
import fr.neatmonster.nocheatplus.utilities.StringUtil;
34
import fr.neatmonster.nocheatplus.utilities.TickTask;
35
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
36
37
/**
38
 * A check used to verify if the player isn't using a forcefield in order to attack multiple entities at the same time.
39
 * 
40
 * Thanks @asofold for the original idea!
41
 */
42
public class Angle extends Check {
43
  
44
45
  private final List<String> tags = new LinkedList<String>();
46
47
48
    public static class AttackLocation {
49
        public final double x, y, z;
50
        /** Yaw of the attacker. */
51
        public final float yaw;
52
        public long time;
53
        public final UUID damagedId;
54
        /** Squared distance to the last location (0 if none given). */
55
        public final double distSqLast;
56
        /** Difference in yaw to the last location (0 if none given). */
57
        public final double yawDiffLast;
58
        /** Time difference to the last location (0 if none given). */
59
        public final long timeDiff;
60
        /** If the id differs from the last damaged entity (true if no lastLoc is given). */
61
        public final boolean idDiffLast;
62
        public AttackLocation(final Location loc, final UUID damagedId, final long time, final AttackLocation lastLoc) {
63
            x = loc.getX();
64
            y = loc.getY();
65
            z = loc.getZ();
66
            yaw = loc.getYaw();
67
            this.time = time;
68
            this.damagedId = damagedId;
69
70
            if (lastLoc != null) {
71
                distSqLast = TrigUtil.distanceSquared(x, y, z, lastLoc.x, lastLoc.y, lastLoc.z);
72
                yawDiffLast = TrigUtil.yawDiff(yaw, lastLoc.yaw);
73
                timeDiff = Math.max(0L, time - lastLoc.time);
74
                idDiffLast = !damagedId.equals(lastLoc.damagedId);
75
            } 
76
            else {
77
                distSqLast = 0.0;
78
                yawDiffLast = 0f;
79
                timeDiff = 0L;
80
                idDiffLast = true;
81
            }
82
        }
83
    }
84
    
85
    /** Used to also monitor lag-time */
86
    public static long maxTimeDiff = 1000L;
87
88
89
    /**
90
     * Instantiates a new angle check.
91
     */
92
    public Angle() {
93
        super(CheckType.FIGHT_ANGLE);
94
    }
95
96
97
    /**
98
     * The Angle check.
99
     * @param player
100
     * @param loc Location of the player.
101
     * @param worldChanged
102
     * @param data
103
     * @param cc
104
     * @return
105
     */
106
    public boolean check(final Player player, final Location loc, 
107
                         final Entity damagedEntity, final boolean worldChanged, 
108
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
109
110
        if (worldChanged) {
111
            data.angleHits.clear();
112
        }
113
114
        boolean cancel = false;
115
        tags.clear();
116
117
        // Quick check for expiration of all entries.
118
        final long time = System.currentTimeMillis();
119
        AttackLocation lastLoc = data.angleHits.isEmpty() ? null : data.angleHits.getLast();
120
        if (lastLoc != null && time - lastLoc.time > maxTimeDiff) {
121
            data.angleHits.clear();
122
            lastLoc = null;
123
        }
124
125
        // Add the new location.
126
        data.angleHits.add(new AttackLocation(loc, damagedEntity.getUniqueId(), System.currentTimeMillis(), lastLoc));
127
128
        // Calculate the sums of differences.
129
        double deltaMove = 0D;
130
        long deltaTime = 0L;
131
        float deltaYaw = 0f;
132
        int deltaSwitchTarget = 0;
133
        final Iterator<AttackLocation> it = data.angleHits.iterator();
134
        while (it.hasNext()) {
135
            final AttackLocation refLoc = it.next();
136
            if (time - refLoc.time > maxTimeDiff) {
137
                it.remove();
138
                continue;
139
            }
140
            deltaMove += refLoc.distSqLast;
141
            final double yawDiff = Math.abs(refLoc.yawDiffLast);
142
            deltaYaw += yawDiff;
143
            deltaTime += refLoc.timeDiff;
144
            if (refLoc.idDiffLast && yawDiff > 30.0) {
145
                // TODO: Configurable sensitivity ? Scale with yawDiff?
146
                deltaSwitchTarget += 1;
147
            }
148
        }
149
150
        // Check if there is enough data present.
151
        if (data.angleHits.size() < 2) {
152
            return false;
153
        }
154
155
        final double n = (double) (data.angleHits.size() - 1);
156
157
        // Let's calculate the average move.
158
        double averageMove = deltaMove / n;
159
        // Adjust to server-sided lag
160
        averageMove *= TickTask.getLag(maxTimeDiff, true);
161
162
        // And the average time elapsed.
163
        double averageTime = (double) deltaTime / n;
164
        // Adjust to server-sided lag
165
        averageTime *= TickTask.getLag(maxTimeDiff, true);
166
167
        // And the average yaw delta.
168
        double averageYaw = (double) deltaYaw / n;
169
        // Adjust to server-sided lag
170
        averageYaw /= TickTask.getLag(maxTimeDiff, true);
171
172
        // Average target switching.
173
        double averageSwitching = (double) deltaSwitchTarget / n;
174
        // Adjust to server-sided lag
175
        averageSwitching /= TickTask.getLag(maxTimeDiff, true);
176
177
        // Declare the variables.
178
        double violation = 0.0;
179
        double violationMove = 0.0;
180
        double violationTime = 0.0;
181
        double violationYaw = 0.0;
182
        double violationSwitchSpeed = 0.0;
183
184
        // If the average move is between 0 and 0.2 block(s), add it to the violation.
185
        if (averageMove >= 0.0 && averageMove < 0.2D) {
186
            violationMove += 20.0 * (0.2 - averageMove) / 0.2;
187
            tags.add("avgmove");
188
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
189
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgMove: " + averageMove + " avgMove VL: " + violationMove + "/" + cc.angleMove);
190
            }
191
        }
192
193
        // If the average time elapsed is between 0 and 150 millisecond(s), add it to the violation.
194
        if (averageTime >= 0.0 && averageTime < 150.0) {
195
            violationTime += 30.0 * (150.0 - averageTime) / 150.0;
196
            tags.add("avgtime");
197
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
198
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgTime: " + averageTime + " avgTime VL: " + violationTime + "/" + cc.angleTime);
199
            }
200
        }
201
202
        // If the average difference of yaw is superior to 50 degrees, add it to the violation.
203
        if (averageYaw > 50.0) {
204
            violationYaw += 30.0 * averageYaw / 180.0;
205
            tags.add("avgyaw");
206
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
207
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgYaw: " + averageYaw + " avgYaw VL: " + violationYaw + "/" + cc.angleYaw);
208
            }
209
        }
210
        
211
        // Check for too quick target switch speed
212
        if (averageSwitching > 0.0) {
213
            violationSwitchSpeed += 20.0 * averageSwitching;
214
            tags.add("switchspeed");
215
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
216
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgSwitch: " + averageSwitching + " avgSwitch VL: " + violationSwitchSpeed + "/" + cc.angleSwitch);
217
            }
218
        }
219
220
221
        if (violationMove > cc.angleMove) {
222
            violation = violationMove;
223
            data.angleVL += violation;
224
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
225
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
226
            cancel = executeActions(vd).willCancel();
227
        }
228
        else if (violationTime > cc.angleTime) {
229
            violation = violationTime;
230
            data.angleVL += violation;
231
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
232
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
233
            cancel = executeActions(vd).willCancel();
234
        }
235
        else if (violationYaw > cc.angleYaw) {
236
            violation = violationYaw;
237
            data.angleVL += violation;
238
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
239
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
240
            cancel = executeActions(vd).willCancel();
241
        } 
242
        else if (violationSwitchSpeed > cc.angleSwitch) {
243
            violation = violationSwitchSpeed;
244
            data.angleVL += violation;
245
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
246
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
247
            cancel = executeActions(vd).willCancel();
248
        } 
249
        else {
250
            // Reward the player by lowering their violation level.
251
            data.angleVL *= 0.98D;  
252
        }
253
        return cancel;
254
    }
255
}

How it counteracts this module

NCP's Angle check scores the attack stream for forcefield behavior. Every C02 attack appends an AttackLocation to data.angleHits holding the player position, yaw, victim UUID, squared distance to the previous attack, yaw difference to the previous attack, time difference, and an idDiffLast flag, with entries older than maxTimeDiff (1000ms) pruned. The window then yields four averages: averageMove (squared distance moved between attacks), averageTime (elapsed time between attacks), averageYaw (total yaw change) and averageSwitching (id changes where the yaw diff exceeds 30 degrees), all lag-adjusted by TickTask.getLag. Violations accumulate: avgmove under 0.2 blocks adds up to 20 points, avgtime under 150ms adds up to 30, avgyaw over 50 degrees adds proportional points, and switchspeed adds 20 per switch, and the branch with the largest violation executes the configured actions when it passes its threshold.

KillAura's Multiple mode is the clean hit: it attacks every in-range target from the same position in the same tick, so averageMove is near zero (standing killaura), averageTime is near zero, and each victim id change with a yaw rotation across the target ring increments averageSwitching. The Single mode at the default 10-15 cps bounds multiplied by 1.5 produces 15-22 clicks per second, i.e. roughly 45-66ms between attacks, which is under the 150ms avgtime threshold; the 1.9+ click-delay mode lowers the rate for swords (1/1.6*20-1 = 11.5 ticks between hits), which stays near the boundary. The rotation modes that bypass the smoothing walk are the strongest signal: Snap snaps the full angle to the target each tick and Autistic AntiCheat rotates yaw by rotationSpeed * 10 per tick with pitch locked at 0, both blowing past the 50-degree average-yaw ceiling.

The Legit/Normal smoothing walk at default speed stays under the yaw limit, which is why the check is most effective against the Switch and Multiple modes and the two aggressive rotation modes. The Switch mode compounds the problem: it cycles through pastTargets exclusions (when the eviction list is actually populated) and re-targets, which produces idDiffLast transitions with large yaw deltas, feeding the switchspeed counter. A module that stays on one target, moves between hits and uses the Legit/Normal walk can keep all four averages inside their thresholds, so the check rewards movement-between-attacks and low yaw deltas rather than raw distance.

anticheat fight.Reach (survival distance with precision inset)

Reach.java372 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.fight;
16
17
18
import org.bukkit.GameMode;
19
import org.bukkit.Location;
20
import org.bukkit.entity.EnderDragon;
21
import org.bukkit.entity.Entity;
22
import org.bukkit.entity.Giant;
23
import org.bukkit.entity.LivingEntity;
24
import org.bukkit.entity.Player;
25
import org.bukkit.util.Vector;
26
27
import fr.neatmonster.nocheatplus.actions.ParameterName;
28
import fr.neatmonster.nocheatplus.checks.Check;
29
import fr.neatmonster.nocheatplus.checks.CheckType;
30
import fr.neatmonster.nocheatplus.checks.ViolationData;
31
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
32
import fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace.ITraceEntry;
33
import fr.neatmonster.nocheatplus.permissions.Permissions;
34
import fr.neatmonster.nocheatplus.players.IPlayerData;
35
import fr.neatmonster.nocheatplus.utilities.StringUtil;
36
import fr.neatmonster.nocheatplus.utilities.TickTask;
37
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
38
39
/**
40
 * The Reach check will find out if a player interacts with something that's too far away.
41
 */
42
public class Reach extends Check {
43
44
    /** The maximum distance allowed to interact with an entity in creative mode. */
45
    public static final double CREATIVE_DISTANCE = 6D;
46
47
48
    /** Additum for distance, based on entity. */
49
    private static double getDistMod(final Entity damaged) {
50
        // Handle the EnderDragon differently.
51
        if (damaged instanceof EnderDragon)
52
            return 6.5D;
53
        else if (damaged instanceof Giant){
54
            return 1.5D;
55
        }
56
        else return 0;
57
    }
58
59
60
    /**
61
     * Instantiates a new reach check.
62
     */
63
    public Reach() {
64
        super(CheckType.FIGHT_REACH);
65
    }
66
67
68
    /**
69
     * "Classic" check.
70
     * 
71
     * @param player
72
     *            the player
73
     * @param damaged
74
     *            the damaged
75
     * @return true, if successful
76
     */
77
    public boolean check(final Player player, final Location pLoc, 
78
                         final Entity damaged, final boolean damagedIsFake, final Location dRef, 
79
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
80
81
        boolean cancel = false;
82
        // The maximum distance allowed to interact with an entity in survival mode.
83
        final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance; 
84
        // Amount which can be reduced by reach adaption.
85
        final double DYNAMIC_RANGE = cc.reachReduceDistance; 
86
        // Adaption amount for dynamic range.
87
        final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE; 
88
        final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
89
        final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
90
        final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
91
        final double width = damagedIsFake ? 0.6 : mcAccess.getHandle().getWidth(damaged);
92
        double centertoedge = 0.0;
93
        
94
        if (cc.reachPrecision) {
95
            centertoedge = getinset(pLoc, dRef, width / 2, 0.0);
96
        }
97
98
        // Refine y position.
99
        final double pY = pLoc.getY() + player.getEyeHeight();
100
        final double dY = dRef.getY();
101
        if (pY <= dY) {
102
            // Keep the foot level y.
103
        } 
104
        // Highest ref y
105
        else if (pY >= dY + height) {
106
             dRef.setY(dY + height);
107
        }
108
        // Level with damaged.
109
        else dRef.setY(pY);
110
111
        final Vector pRel = dRef.toVector().subtract(pLoc.toVector().setY(pY)); // TODO: Run calculations on numbers only :p.
112
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
113
        // than allowed, the difference will be assigned to "distance".
114
        final double lenpRel = pRel.length() - centertoedge;
115
        double violation = lenpRel - distanceLimit;
116
        final double reachMod = data.reachMod; 
117
118
119
        if (violation > 0) {
120
            if (TickTask.getLag(1000, true) < 1.5f){ // Do not increase the vl in case of server lag (1.5 is a magic value)
121
                data.reachVL += violation;
122
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
123
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
124
                // Execute whatever actions are associated with this check and the violation level and find out if we should
125
                // cancel the event.
126
                cancel = executeActions(vd).willCancel();
127
            }
128
129
            if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), "fight.reach", pData)){
130
                cancel = true;
131
            }
132
133
            if (cancel && cc.reachPenalty > 0){
134
                // Apply an attack penalty time.
135
                data.attackPenalty.applyPenalty(cc.reachPenalty);
136
            }
137
        }
138
        else if (lenpRel - distanceLimit * reachMod > 0){
139
            // Silent cancel.
140
            if (cc.reachPenalty > 0) {
141
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
142
            }
143
            cancel = true;
144
            Improbable.feed(player, (float) (lenpRel - distanceLimit * reachMod) / 4f, System.currentTimeMillis());
145
        }
146
        else data.reachVL *= 0.8D; // Player passed the check, reward them.
147
            
148
149
        if (!cc.reachReduce){
150
            data.reachMod = 1d;
151
        }
152
        else if (lenpRel > distanceLimit - DYNAMIC_RANGE){
153
            data.reachMod = Math.max(distanceMin, data.reachMod - DYNAMIC_STEP);
154
        }
155
        else data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
156
157
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
158
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod));
159
        }
160
161
        return cancel;
162
    }
163
164
    /**
165
     * Data context for iterating over ITraceEntry instances.
166
     * @param player
167
     * @param pLoc
168
     * @param damaged
169
     * @param damagedLoc
170
     * @param data
171
     * @param cc
172
     * @return
173
     */
174
    public ReachContext getContext(final Player player, final Location pLoc, 
175
                                   final Entity damaged, final Location damagedLoc, 
176
                                   final FightData data, final FightConfig cc) {
177
178
        final ReachContext context = new ReachContext();
179
        context.distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : cc.reachSurvivalDistance + getDistMod(damaged);
180
        context.distanceMin = (context.distanceLimit - cc.reachReduceDistance) / context.distanceLimit;
181
        //context.eyeHeight = player.getEyeHeight();
182
        context.pY = pLoc.getY() + player.getEyeHeight();
183
        return context;
184
    }
185
186
    /**
187
     * Check if the player fails the reach check, no change of FightData.
188
     * @param player
189
     * @param pLoc
190
     * @param damaged
191
     * @param dRef
192
     * @param context
193
     * @param data
194
     * @param cc
195
     * @return
196
     */
197
    public boolean loopCheck(final Player player, final Location pLoc, final Entity damaged, 
198
                             final ITraceEntry dRef, final ReachContext context, 
199
                             final FightData data, final FightConfig cc) {
200
201
        boolean cancel = false;
202
203
        // Refine y position.
204
        final double dY = dRef.getY();
205
        double y = dRef.getY();
206
207
        if (context.pY <= dY) {
208
            // Keep the foot level y.
209
        }
210
        else if (context.pY >= dY + dRef.getBoxMarginVertical()) {
211
            y = dY + dRef.getBoxMarginVertical(); // Highest ref y.
212
        }
213
        else {
214
            y = context.pY; // Level with damaged.
215
        }
216
217
        double centertoedge = 0.0;
218
        if (cc.reachPrecision) centertoedge = getinset(pLoc, new Location(null, dRef.getX(), dRef.getY(), dRef.getZ()), dRef.getBoxMarginHorizontal(), y - context.pY);
219
        
220
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
221
        // than allowed, the difference will be assigned to "distance".
222
        // TODO: Run check on squared distances (quite easy to change to stored boundary-sq values).
223
        final double lenpRel = TrigUtil.distance(dRef.getX(), y, dRef.getZ(), pLoc.getX(), context.pY, pLoc.getZ()) - centertoedge;
224
        double violation = lenpRel - context.distanceLimit;
225
226
        if (violation > 0 || lenpRel - context.distanceLimit * data.reachMod > 0){
227
            // TODO: The silent cancel parts should be sen as "no violation" ?
228
            // Set minimum violation in context
229
            context.minViolation = Math.min(context.minViolation, lenpRel);
230
            cancel = true;
231
        }
232
        context.minResult = Math.min(context.minResult, lenpRel);
233
234
        return cancel;
235
236
    }
237
238
    /**
239
     * Apply changes to FightData according to check results (context), trigger violations.
240
     * @param player
241
     * @param pLoc
242
     * @param damaged
243
     * @param context
244
     * @param forceViolation
245
     * @param data
246
     * @param cc
247
     * @return
248
     */
249
    public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged, 
250
                              final ReachContext context, final ITraceEntry traceEntry, final boolean forceViolation, 
251
                              final FightData data, final FightConfig cc, final IPlayerData pData) {
252
253
        final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
254
255
        if (lenpRel == Double.MAX_VALUE) {
256
            return false;
257
        }
258
259
        double violation = lenpRel - context.distanceLimit;
260
        boolean cancel = false;
261
262
        if (violation > 0) {    
263
            if (TickTask.getLag(1000, true) < 1.5f){
264
                data.reachVL += violation;
265
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
266
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
267
                // Execute whatever actions are associated with this check and the violation level and find out if we should
268
                // cancel the event.
269
                cancel = executeActions(vd).willCancel();
270
            }
271
            
272
            //if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), 
273
            //        "fight.reach", pData)){
274
            //    cancel = true;
275
            //}
276
            // TODO: New improbable weight calculations so that weight is not inverse to config weight
277
            if (cc.reachImprobableWeight > 0.0f) {
278
                if (!cc.reachImprobableFeedOnly && Improbable.check(player, (float) violation / cc.reachImprobableWeight, System.currentTimeMillis(), "fight.reach", pData)) {
279
                    cancel = true;
280
                }
281
            }
282
283
            if (cancel && cc.reachPenalty > 0){
284
                // Apply an attack penalty time.
285
                data.attackPenalty.applyPenalty(cc.reachPenalty);
286
            }
287
        }
288
        else if (lenpRel - context.distanceLimit * data.reachMod > 0){
289
            // Silent cancel.
290
            if (cc.reachPenalty > 0) {
291
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
292
            }
293
294
            cancel = true;
295
296
            if (cc.reachImprobableWeight > 0.0f) {
297
                Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / cc.reachImprobableWeight, System.currentTimeMillis());
298
            }
299
            // Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / 4f, System.currentTimeMillis());
300
        }
301
        else {
302
            // Player passed the check, reward them.
303
            data.reachVL *= 0.8D;
304
305
        }
306
307
        // Adaption amount for dynamic range.
308
        final double DYNAMIC_STEP = cc.reachReduceStep / cc.reachSurvivalDistance;
309
310
        if (!cc.reachReduce){
311
            data.reachMod = 1d;
312
        }
313
        else if (lenpRel > context.distanceLimit - cc.reachReduceDistance){
314
            data.reachMod = Math.max(context.distanceMin, data.reachMod - DYNAMIC_STEP);
315
        }
316
        else {
317
            data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
318
        }
319
320
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
321
            // TODO: Height: remember successful ITraceEntry
322
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ (traceEntry == null ? "" : (" height=" + traceEntry.getBoxMarginVertical())) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(data.reachMod));
323
        }
324
325
        return cancel;
326
    }
327
328
329
    private boolean isSameXZ(final Location loc1, final Location loc2) {
330
        return loc1.getX() == loc2.getX() && loc1.getZ() == loc2.getZ();
331
    }
332
333
334
    /**
335
     *
336
     * @param pLoc
337
     *            the player location
338
     * @param dRef
339
     *            the target location
340
     * @param damagedBoxMarginHorizontal
341
     *            the target Width / 2
342
     * @param diffY the Y different
343
     * @return the double represent for the distance from target location to the edge of target hitbox
344
     */
345
    private double getinset(final Location pLoc, final Location dRef, final double damagedBoxMarginHorizontal, final double diffY) {
346
347
        if (!isSameXZ(pLoc, dRef)) {
348
            final Location dRefc = dRef.clone();
349
            final Vector vec1 = new Vector(pLoc.getX() - dRef.getX(), diffY , pLoc.getZ() - dRef.getZ());
350
            if (vec1.length() < damagedBoxMarginHorizontal * Math.sqrt(2)) return 0.0;
351
            if (vec1.getZ() > 0.0) {
352
                dRefc.setZ(dRefc.getZ() + damagedBoxMarginHorizontal);
353
            } 
354
            else if (vec1.getZ() < 0.0) {
355
                dRefc.setZ(dRefc.getZ() - damagedBoxMarginHorizontal);
356
            } 
357
            else if (vec1.getX() > 0.0) {
358
                dRefc.setX(dRefc.getX() + damagedBoxMarginHorizontal);
359
            } 
360
            else dRefc.setX(dRefc.getX() - damagedBoxMarginHorizontal);
361
362
            final Vector vec2 = new Vector(dRefc.getX() - dRef.getX(), 0.0 , dRefc.getZ() - dRef.getZ());
363
            double angle = TrigUtil.angle(vec1, vec2);
364
            // Require < 45deg, if not 90deg-angel
365
            if (angle > Math.PI / 4) angle = Math.PI / 2 - angle;
366
            if (angle >= 0.0 && angle <= Math.PI / 4) { // TODO: Dose this one necessary?
367
                return damagedBoxMarginHorizontal / Math.cos(angle);
368
            }
369
        }
370
        return 0.0;
371
    }
372
}

How it counteracts this module

NCP's fight.Reach measures the attack from the server-tracked player position to the victim and compares against reachSurvivalDistance (default 3.0). The victim y is refined to the attacker's eye-height band (clamped between the victim's foot level and its height), the precision inset (centertoedge, half the victim width projected along the attack direction when reachPrecision is on) is subtracted, and a per-entity size modifier applies (6.5 for dragons, 1.5 for giants). A positive violation accumulates into reachVL and executes the configured actions; the dynamic reachMod adaption then tightens the limit for repeat offenders: every hit within the reduce band steps reachMod down toward distanceMin, so a KillAura that consistently attacks at 3.1-3.4 gets silently cancelled even though the nominal limit is 3.0 plus inset, and the attackPenalty applies an attack cooldown on cancels.

KillAura's range value of 3-6 maps directly onto this: the default 3.0 setting attacks at the limit, and any higher setting exceeds it outright. The module's own distance gate is client-side getDistanceToEntity <= range with no subtraction for the victim's girth, while NCP's inset grants only the half-width toward the attacker, so the server-side measurement is strictly more demanding than the client's own gate. Unlike the 5.99 branch there is no Extended Range mode that also rewrites the movement stream, so the server-tracked position cannot be shortened to dodge the measurement; the 6.1.30 module only manipulates rotations and attack packets.

The reachMod adaption is what makes the default setting risky too: even at 3.0 range, the small positive violations from the missing inset and from aiming at the eye band while the server clamps the victim y step reachMod down, and once reachMod shrinks the silent-cancel branch (lenpRel - distanceLimit * reachMod > 0) starts cancelling attacks that were previously under the limit. The Universal auto-block cycle adds nothing to the distance but its PingSpoofComponent transaction spoofing inflates the measured lag, and TickTask.getLag(1000, true) only applies when lag is below 1.5, so sustained spoofed pings keep the violation accumulating without the lag dampener.

anticheat combat.KillAura (direction, multi, noswing, reach, speed)

KillAura.java114 lines · Java
1
package me.vrekt.arc.check.combat;
2
3
import me.vrekt.arc.Arc;
4
import me.vrekt.arc.check.Check;
5
import me.vrekt.arc.check.CheckType;
6
import me.vrekt.arc.data.combat.FightData;
7
import me.vrekt.arc.utilties.LocationHelper;
8
import org.bukkit.ChatColor;
9
import org.bukkit.entity.Entity;
10
import org.bukkit.entity.Player;
11
import org.bukkit.util.Vector;
12
13
public class KillAura extends Check {
14
15
    private double maxAngle, maxReach;
16
    private int maxSwingTime, maxAttacks, maxAttackPackets;
17
18
    public KillAura() {
19
        super(CheckType.KILLAURA);
20
21
        maxAngle = Arc.getCheckManager().getValueDouble(CheckType.KILLAURA, "max-direction-angle");
22
        maxSwingTime = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-swing-time");
23
        maxReach = Arc.getCheckManager().getValueDouble(CheckType.KILLAURA, "max-reach");
24
        maxAttacks = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-attacks");
25
        maxAttackPackets = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-attack-packets");
26
27
    }
28
29
    public boolean check(FightData data, Player player) {
30
        result.reset();
31
32
        Entity last = data.getLastAttackedEntity();
33
        Entity entity = data.getAttackedEntity();
34
35
        // Calculate angle stuff.
36
        Vector playerLocation = player.getLocation().toVector();
37
        Vector entityLocation = entity.getLocation().toVector();
38
        double angle = entityLocation.subtract(playerLocation).angle(player.getLocation().getDirection());
39
40
        if (last != null && !entity.equals(last)) {
41
            // check the angle between the two entities
42
            Vector lastLocation = last.getLocation().toVector();
43
            double angleToLast = lastLocation.subtract(playerLocation).angle(player.getLocation().getDirection());
44
            double angleDifference = Math.abs(angleToLast - angle);
45
            double distanceDifference = LocationHelper.distance(last.getLocation(), entity.getLocation());
46
            if (angleDifference > maxAngle && distanceDifference <= maxReach) {
47
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Multi)");
48
                result.set(checkViolation(player, "Angle difference greater than allowed. a=" + angleDifference + " e=" + maxAngle));
49
            }
50
        }
51
52
        // check yaw difference.
53
        if (angle > maxAngle) {
54
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Direction)");
55
            result.set(checkViolation(player, "Angle distance greater than allowed. a=" + angle + " e=" + maxAngle));
56
        }
57
58
        // check swing time.
59
        long time = System.currentTimeMillis() - data.getLastArmSwing();
60
        if (time > maxSwingTime) {
61
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(NoSwing)");
62
            result.set(checkViolation(player, "Player did not swing their arm in time."));
63
        }
64
65
        // distance to entity excluding knockback.
66
        double distance = LocationHelper.distance(player.getLocation(), entity.getLocation().subtract(entity.getVelocity()));
67
        // check for reach
68
        if (distance > maxReach) {
69
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Reach)");
70
            result.set(checkViolation(player, "Entity is out of players range. d=" + distance + " e=" + maxReach));
71
        }
72
73
        // check max attacks
74
        if (data.getLastAttackCheck() == 0) {
75
            data.setLastAttackCheck(System.currentTimeMillis());
76
        }
77
        long lastAttack = System.currentTimeMillis() - data.getLastAttackCheck();
78
        if (lastAttack >= 1000) {
79
            // check if we exceeded the max attacks in the last second.
80
            int totalAttacks = data.getTotalAttacks();
81
            if (totalAttacks > maxAttacks) {
82
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Speed)");
83
                result.set(checkViolation(player, "Attacking too fast. a=" + totalAttacks + " e=" + maxAttacks));
84
            }
85
            // reset data for next check.
86
            data.setTotalAttacks(0);
87
            data.setLastAttackCheck(System.currentTimeMillis());
88
        }
89
90
        getCheck().setCheckName("KillAura");
91
        return result.failed();
92
    }
93
94
    public boolean checkFrequency(FightData data, Player player) {
95
        if (data.getLastAttackCheck() == 0) {
96
            data.setLastAttackCheck(System.currentTimeMillis());
97
            return false;
98
        }
99
100
        long time = System.currentTimeMillis() - data.getLastAttackCheck();
101
        if (time >= 1000) {
102
            data.setLastAttackCheck(System.currentTimeMillis());
103
            int totalPackets = data.getAttackPackets();
104
            if (totalPackets > maxAttackPackets) {
105
                data.setAttackPackets(0);
106
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Speed)");
107
                return checkViolation(player, "Attacking too fast a=" + totalPackets + " e=" + maxAttackPackets);
108
            }
109
        }
110
111
        return false;
112
    }
113
114
}

How it counteracts this module

Arc's KillAura check runs from the FightListener on every C02 attack and combines five detectors. Direction computes the angle between the player's look direction and the vector to the attacked entity and flags over max-direction-angle. Multi compares the angle to the current and previous attacked entity and flags when the angle difference exceeds the limit while both entities are within maxReach of each other. NoSwing flags when more than maxSwingTime passes without an arm swing. Reach measures the distance to the entity minus its current velocity (so knockback does not false-flag) against maxReach. Speed counts attacks per second against maxAttacks, and the separate checkFrequency() counts raw attack packets per second against maxAttackPackets.

KillAura's Multiple mode is the direct target: attacking several entities in one tick means the single look vector can only satisfy the Direction check for one of them, and the angle difference between the attacked entities trips the Multi branch immediately. The module's noSwing option (a BooleanValue under the Advanced section, default false) removes the swing packet entirely when enabled, which trips NoSwing; even with it off, the auto-block modes that force the block animation between hits can exceed maxSwingTime if the swing is delayed past the limit. The cps bounds up to 20 multiplied by 1.5 produce 30 clicks per second, over any default maxAttacks and maxAttackPackets, so the Speed branch flags sustained high-cps use.

The Autistic AntiCheat rotation mode, which rotates yaw by rotationSpeed * 10 per tick while pitching 0, is caught by the Direction angle since the look vector is usually far from the target when the attack fires. The Legit/Normal mode with the smoothing walk survives Direction because the ray-cast predicate keeps the look inside the hitbox, but the Reach detector still measures the true distance and the Speed detector still counts the packet rate, so the module cannot rely on its rotation engine to clear the check entirely; silent rotations neutralize Direction and NoSwing, not Reach and Speed.

anticheat FightHitbox (ray trace to lag-compensated hitbox)

FightHitbox.java232 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.combat;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.Cancelless;
23
import me.islandscout.hawk.check.CustomCheck;
24
import me.islandscout.hawk.event.Event;
25
import me.islandscout.hawk.event.InteractEntityEvent;
26
import me.islandscout.hawk.event.MoveEvent;
27
import me.islandscout.hawk.util.*;
28
import me.islandscout.hawk.wrap.block.WrappedBlock;
29
import me.islandscout.hawk.wrap.entity.WrappedEntity;
30
import org.bukkit.GameMode;
31
import org.bukkit.Location;
32
import org.bukkit.Material;
33
import org.bukkit.block.Block;
34
import org.bukkit.entity.Entity;
35
import org.bukkit.entity.Player;
36
import org.bukkit.util.BlockIterator;
37
import org.bukkit.util.Vector;
38
39
import java.util.HashMap;
40
import java.util.Map;
41
import java.util.UUID;
42
43
/**
44
 * The hit detection in Minecraft is mostly determined by the client,
45
 * thus servers are left to trust the client. (There are a few exceptions
46
 * for the unmodified Notchian server such as preventing hits exceeding 6
47
 * blocks from the target entity). This poses a problem for players and
48
 * server owners since players can modify the client to manipulate hit
49
 * detection and allow for cheating when in combat with other players.
50
 *
51
 * Hawk’s hitbox checking aims to detect cheating during player vs.
52
 * player combat by validating hits on the server. When the server
53
 * receives an interaction packet from the client, Hawk gets the client’s
54
 * last known position and next direction, and uses it to perform a ray
55
 * trace test on the victim’s hitbox. Before the ray-trace test begins,
56
 * though, Hawk must factor in latency by rewinding the victim’s hitbox
57
 * to an appropriate time based on the client’s ping latency. To
58
 * accomplish this, Hawk keeps a history of players’ positions and
59
 * timestamps in a table and it retrieves a position that best
60
 * approximates where it appeared to the client when the client attacked
61
 * it. Hawk then performs the ray-trace test to determine whether the
62
 * client landed the hit or not. Although the system may produce false
63
 * positives with clients on unstable connections, it is a fair tradeoff
64
 * between user experience and cheat prevention.
65
 *
66
 * There are other sources of error which will probably not be accounted
67
 * for in Hawk anytime soon. Other sources of error include:
68
 *   - The client receives entity relative moves in 1/32 block precision.
69
 *   - The client holds off one tick to smoothly animate other players
70
 *     on the screen in the case of slight network jitter. It will
71
 *     linearly interpolate from the last position to the latest
72
 *     position up to 3 ticks if it doesn't receive a relative move
73
 *     packet to update the player's position.
74
 *   - The client will predict the motion of some entities, such as
75
 *     arrows. If there is latency and something unexpected happens
76
 *     to the entity, the client may desynchronize from the server.
77
 *
78
 * In most cases, the client uses the current frame's yaw and pitch to
79
 * compute the direction vector for the attack hit-scan. Fortunately,
80
 * ticking and rendering is done in the same thread. Unfortunately, in
81
 * the tick stack, attacking is done before sending yaw/pitch updates
82
 * to the server, which means that we must wait until the next flying
83
 * packet to get the direction of the hit-scan.
84
 *
85
 * For realtime protection, it's best to use the EntityInteractDirection
86
 * check. It actively enforces directions, but it extrapolates the
87
 * yaw/pitch because of how the client hit-scanning works.
88
 */
89
public class FightHitbox extends CustomCheck implements Cancelless {
90
91
    private final double MAX_REACH;
92
    private final int PING_LIMIT;
93
    private final boolean CHECK_OTHER_ENTITIES;
94
    private final boolean LAG_COMPENSATION;
95
    private final boolean DEBUG_HITBOX;
96
    private final boolean DEBUG_RAY;
97
    private final boolean CHECK_OCCLUSION;
98
    private final boolean CHECK_BOX_INTERSECTION;
99
    private final double BOX_EPSILON = 0.005;
100
101
    private Map<UUID, InteractEntityEvent> lastInteractionMap;
102
103
    public FightHitbox() {
104
        super("fighthitbox", false, 5, 10000, 0.95, 5000, "%player% failed combat hitbox. %type% VL: %vl%", null);
105
        CHECK_BOX_INTERSECTION = (boolean) customSetting("checkBoxIntersection", "", true);
106
        CHECK_OCCLUSION = (boolean) customSetting("checkOccluding", "", false);
107
        MAX_REACH = (double) customSetting("maxReach", "", 3.1);
108
        CHECK_OTHER_ENTITIES = (boolean) customSetting("checkOtherEntities", "", false);
109
        LAG_COMPENSATION = (boolean) customSetting("lagCompensation", "", true);
110
        PING_LIMIT = (int) customSetting("pingLimit", "", -1);
111
        DEBUG_HITBOX = (boolean) customSetting("hitbox", "debug", false);
112
        DEBUG_RAY = (boolean) customSetting("ray", "debug", false);
113
        lastInteractionMap = new HashMap<>();
114
    }
115
116
    @Override
117
    protected void check(Event event) {
118
        if(event instanceof InteractEntityEvent)
119
            processHit((InteractEntityEvent)event);
120
        else if(event instanceof MoveEvent) {
121
            InteractEntityEvent interactEntityEvent = lastInteractionMap.get(event.getHawkPlayer().getUuid());
122
            if(interactEntityEvent != null) {
123
                MoveEvent move = (MoveEvent) event;
124
125
                float yaw;
126
                float pitch;
127
                //In 1.8, the yaw of the cursor is behind by one tick.
128
                if(event.getHawkPlayer().getClientVersion() == 8) {
129
                    yaw = event.getHawkPlayer().getYaw();
130
                } else {
131
                    yaw = move.getTo().getYaw();
132
                }
133
                pitch = move.getTo().getPitch();
134
135
                processDirection(interactEntityEvent, yaw, pitch);
136
            }
137
            lastInteractionMap.put(event.getHawkPlayer().getUuid(), null);
138
        }
139
    }
140
141
    private void processHit(InteractEntityEvent e) {
142
        lastInteractionMap.put(e.getHawkPlayer().getUuid(), e);
143
    }
144
145
    private void processDirection(InteractEntityEvent e, float yaw, float pitch) {
146
        Entity entity = e.getEntity();
147
        if (!(entity instanceof Player) && !CHECK_OTHER_ENTITIES)
148
            return;
149
        Player attacker = e.getPlayer();
150
        int ping = ServerUtils.getPing(attacker);
151
        if (ping > PING_LIMIT && PING_LIMIT != -1)
152
            return;
153
154
        HawkPlayer att = e.getHawkPlayer();
155
        Location attackerEyeLocation = att.getPosition().clone().add(new Vector(0, 1.62, 0)).toLocation(att.getWorld());
156
        Vector attackerDirection = MathPlus.getDirection(yaw, pitch);
157
158
        double maxReach = MAX_REACH;
159
        if (attacker.getGameMode() == GameMode.CREATIVE)
160
            maxReach += 1.9;
161
162
        Vector victimLocation;
163
        if (LAG_COMPENSATION)
164
            //No need to add 50ms; the move and attack are already chronologically so close together
165
            victimLocation = hawk.getLagCompensator().getHistoryLocation(ping, e.getEntity()).toVector();
166
        else
167
            victimLocation = e.getEntity().getLocation().toVector();
168
169
        Vector eyePos;
170
        if(e.getHawkPlayer().isInVehicle()) {
171
            eyePos = hawk.getLagCompensator().getHistoryLocation(ping, e.getPlayer()).toVector();
172
            eyePos.setY(eyePos.getY() + e.getPlayer().getEyeHeight());
173
        }
174
        else {
175
            eyePos = new Vector(attackerEyeLocation.getX(), attacker.isSneaking() ? attackerEyeLocation.getY() - 0.08 : attackerEyeLocation.getY(), attackerEyeLocation.getZ());
176
        }
177
        Vector direction = new Vector(attackerDirection.getX(), attackerDirection.getY(), attackerDirection.getZ());
178
        Ray attackerRay = new Ray(eyePos, direction);
179
180
        AABB victimAABB;
181
        victimAABB = WrappedEntity.getWrappedEntity(entity).getHitbox(victimLocation);
182
        victimAABB.expand(BOX_EPSILON, BOX_EPSILON, BOX_EPSILON);
183
184
        Vector intersectVec3d = victimAABB.intersectsRay(attackerRay, 0, Float.MAX_VALUE);
185
186
        if (DEBUG_HITBOX) {
187
            victimAABB.highlight(hawk, attacker.getWorld(), 0.29);
188
        }
189
190
        if (DEBUG_RAY) {
191
            attackerRay.highlight(hawk, attacker.getWorld(), maxReach, 0.1);
192
        }
193
194
        if (intersectVec3d != null) {
195
            Location intersect = new Location(attacker.getWorld(), intersectVec3d.getX(), intersectVec3d.getY(), intersectVec3d.getZ());
196
            double interDistance = intersect.distance(attackerEyeLocation);
197
            if (interDistance > maxReach) {
198
                punish(att, 1, true, e, new Placeholder("type", "Reach: " + MathPlus.round(interDistance, 2) + "m"));
199
                return;
200
            }
201
            if (CHECK_OCCLUSION && interDistance > 1D) {
202
                BlockIterator iter = new BlockIterator(attacker.getWorld(), eyePos, attackerDirection, 0, (int) interDistance + 1);
203
                while (iter.hasNext()) {
204
                    Block bukkitBlock = iter.next();
205
206
                    if (bukkitBlock.getType() == Material.AIR || bukkitBlock.isLiquid())
207
                        continue;
208
209
                    WrappedBlock b = WrappedBlock.getWrappedBlock(bukkitBlock, att.getClientVersion());
210
                    Vector intersection = b.getHitBox().intersectsRay(new Ray(attackerEyeLocation.toVector(), attackerDirection), 0, Float.MAX_VALUE);
211
                    if (intersection != null) {
212
                        if (intersection.distance(eyePos) < interDistance) {
213
                            punish(att, 1, true, e, new Placeholder("type", "Interacted through " + b.getBukkitBlock().getType()));
214
                            return;
215
                        }
216
                    }
217
                }
218
219
            }
220
        } else if (CHECK_BOX_INTERSECTION) {
221
            punish(att, 1, true, e, new Placeholder("type", "Did not hit hitbox."));
222
            return;
223
        }
224
225
        reward(att); //reward player
226
    }
227
228
    @Override
229
    public void removeData(Player p) {
230
        lastInteractionMap.remove(p.getUniqueId());
231
    }
232
}

How it counteracts this module

Hawk's FightHitbox replays each attack from the packet-observed yaw/pitch. Because 1.8 sends the C02 before the yaw update, Hawk stores the InteractEntityEvent in lastInteractionMap and defers the geometry to the next MoveEvent, then builds the direction from the stored yaw/pitch (the HawkPlayer's tracked yaw for 1.8 clients, the move's own yaw otherwise). The victim is rewound to its ping-ago position via the lag compensator, the victim AABB is expanded by BOX_EPSILON 0.005, and a ray from the attacker eye (with the sneaking -0.08 offset and vehicle eye-height handling) is intersected against the box. No intersection punishes 'Did not hit hitbox.' when CHECK_BOX_INTERSECTION is on; an intersection beyond MAX_REACH (3.1 survival, 5.0 creative) punishes as reach; with CHECK_OCCLUSION a BlockIterator flags hits that travel through blocks as 'Interacted through <block>'.

KillAura's throughWalls mode is the direct target: when throughWalls is on (and rayCast off) the module expands the target's bounding box by 0.1 and attacks on any intercept, which is exactly the geometry Hawk re-derives from the server direction without that expansion. A wall hit either misses the victim box entirely (the HITBOX branch) or the intercept lands beyond MAX_REACH (the reach branch), and the occlusion iterator names the wall it went through. The Multiple mode attacking several entities in one tick fails the direction requirement for all but the one the look vector happens to cross, so each extra victim yields a miss. The rayCast-on mode (RayCastUtil.rayCast with a -0.1f box expansion in the rotation predicate) survives only when the server-observed rotations genuinely cross the rewound victim box within 3.1, which is the Legit/Normal rotation mode at default range.

The lag compensation is the check's weak spot against this module: it rewinds the victim to ping-ago, but the module's attack timing is already driven by its own clickStopWatch and the rotation engine, so a victim moving fast can desync from the rewound box and produce a miss that is punished as a hitbox violation rather than a clean hit; conversely, hits that land exactly inside the rewound box at 3.0-3.1 pass, which is why default-range Legit/Normal play is the only configuration the check consistently clears.

← Back to Analysis Hub