Rise 5.99 Velocity module 2 files, 732 lines

Rise 5.99 Velocity: Full Source Analysis

Rise 5.99's Velocity module intercepts S12PacketEntityVelocity and S27PacketExplosion in onPacketReceive and reshapes or removes the knockback vector before the vanilla handler applies it.

dev/rise/module/impl/combat/Velocity.java · GitHub source ↗

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

Analysis

Overview

Rise 5.99's Velocity module intercepts S12PacketEntityVelocity and S27PacketExplosion in onPacketReceive and reshapes or removes the knockback vector before the vanilla handler applies it. Nine modes are selectable: Custom scales the vector by separate horizontal and vertical percentages and cancels the packet when both are zero; Reverse negates the horizontal axes; Vulcan cancels the packet outright and additionally cancels C0F confirmations while hurtTime is positive; Tick Cancel lets the knockback through and then zeroes the client's motion with setVelocity once the Ticks window elapses; Minemenclub cancels the first two knockbacks and zeroes the motion after the third; Stack drops every knockback while stationary and two of every three while moving; Follow First Tick cancels the S12 and re-adds its motion to the next position packet; Ground forces the client-side onGround flag on the tick after a hit; and Redesky combines scaling with a C0B sneak injection and a timer-speed window. An Explosion toggle extends the Custom scaling to S27 explosion knockback, and a More Options group adds delayed horizontal/vertical damping, attack-time damping and a temporary timer boost.

Architecture

All interception funnels through onPacketReceive, which checks the packet type, verifies the entity id against the player, and dispatches on the mode string. The receive handler only touches S12 and S27; everything else is timed in onPreMotion (tick counting, timer-speed windows, delayed damping at hurtTime 8, the Ground onGround fake, the Follow First Tick position offset and the Redesky sneak flush), in onStrafe (the setVelocity(0, 0, 0) zeroing for Tick Cancel and Minemenclub), in onPacketSend (Vulcan's C0F cancellation) and in onAttackEvent (attack-time damping).

State is a handful of fields: ticks, cancelTicks, row, the stored motionX/motionY/motionZ, and the receivingVelocity, countingTicks and lastTick booleans, all reset in onEnable. onUpdateAlwaysInGui hides every mode-specific setting except the active mode's, so the GUI only exposes the sliders that apply. The onlyInAir gate skips the receive handler whenever the player is on the ground and the toggle is on, and the same condition guards the pre-motion logic.

Key techniques

Custom and Redesky scale the packet in place: motionX and motionZ are multiplied by horizontal over 100, motionY by vertical over 100, and the scaled packet replaces the original through event.setPacket, so the vanilla handler applies a reduced vector. When both sliders are zero the packet is cancelled instead, which is the full anti-knockback case. Reverse multiplies only the horizontal axes by -1, turning the push backwards. Follow First Tick cancels the S12, stores the vector divided by 8000, sets motionY to 0.03 and on the next PreMotionEvent adds the stored values to the event's x, y and z, so the knockback is converted into a position delta instead of a velocity. Ground sets thePlayer.onGround to true on the tick after a hit, making movement checks treat the player as grounded when the knockback should have lifted them.

Tick Cancel and Minemenclub defer the zeroing: they count cancelTicks in onPreMotion and, once the threshold (the Ticks setting, default 3) is reached, call setVelocity(0, 0, 0) in onStrafe, but only when Speed, LongJump and Fly are all disabled so the module never fights its own movement modules. Stack uses a row counter: while moving it cancels the first two knockbacks and lets the third through, and while stationary it cancels everything; Minemenclub forces row to 3 when Fly or Speed is active so the zeroing never runs against them.

Mode-specific streams

Redesky is the AAC5-targeted mode: on the S12 it sends a C0BPacketEntityAction START_SNEAKING through addToSendQueueWithoutEvent, cancels the packet and arms receivingVelocity; the next onPreMotion sends STOP_SNEAKING. The sneak pair rides alongside the cancelled knockback so the server sees a sneaking state change around the hit. The same mode, and Custom with More Options, run a timer window: hurtTime == 9 resets ticks, a timerSpeed between 0.1 and 2.0 is applied while ticks stays below timerTicks (0-9), and the speed is restored to 1.0 once the window closes. hurtTime == 8 applies the delayed horizontal/vertical damping to the stored motion, and onAttackEvent applies horizontalAttack and verticalAttack to the live motion while hurtTime is positive.

Vulcan adds its own C0F cancellation while hurtTime is positive, desyncing the transaction stream around the hit, and the Explosion toggle scales or cancels S27 the same way as S12: Custom applies the horizontal/vertical percentages to the explosion offsets, every other mode cancels the packet outright when the toggle is on. The S27 branch only fires when the explosion toggle is enabled, so explosion knockback is untouched by default.

source Velocity.java (module)

Velocity.java380 lines · JavaOriginal ↗
1
/*
2
 Copyright Alan Wood 2021
3
 None of this code to be reused without my written permission
4
 Intellectual Rights owned by Alan Wood
5
 */
6
package dev.rise.module.impl.combat;
7
8
import dev.rise.Rise;
9
import dev.rise.event.impl.motion.PreMotionEvent;
10
import dev.rise.event.impl.other.AttackEvent;
11
import dev.rise.event.impl.other.StrafeEvent;
12
import dev.rise.event.impl.packet.PacketReceiveEvent;
13
import dev.rise.event.impl.packet.PacketSendEvent;
14
import dev.rise.module.Module;
15
import dev.rise.module.api.ModuleInfo;
16
import dev.rise.module.enums.Category;
17
import dev.rise.module.impl.movement.Fly;
18
import dev.rise.module.impl.movement.LongJump;
19
import dev.rise.module.impl.movement.Speed;
20
import dev.rise.module.manager.ModuleManager;
21
import dev.rise.setting.impl.BooleanSetting;
22
import dev.rise.setting.impl.ModeSetting;
23
import dev.rise.setting.impl.NumberSetting;
24
import dev.rise.util.player.MoveUtil;
25
import net.minecraft.network.Packet;
26
import net.minecraft.network.play.client.C0BPacketEntityAction;
27
import net.minecraft.network.play.client.C0FPacketConfirmTransaction;
28
import net.minecraft.network.play.server.S12PacketEntityVelocity;
29
import net.minecraft.network.play.server.S27PacketExplosion;
30
31
import java.util.Objects;
32
33
@ModuleInfo(name = "Velocity", description = "Changes how and how much velocity you take", category = Category.COMBAT)
34
public final class Velocity extends Module {
35
    private final ModeSetting mode = new ModeSetting("Mode", this, "Custom", "Custom", "Redesky", "Minemenclub", "Vulcan", "Stack", "Follow First Tick", "Tick Cancel", "Ground", "Reverse");
36
37
    private final BooleanSetting explosion = new BooleanSetting("Explosion", this, true);
38
39
    private final BooleanSetting onlyInAir = new BooleanSetting("Only In Air", this, false);
40
    private final NumberSetting horizontal = new NumberSetting("Horizontal", this, 100.0, 0.0, 100.0, 0.1);
41
    private final NumberSetting vertical = new NumberSetting("Vertical", this, 100.0, 0.0, 100.0, 0.1);
42
    private final BooleanSetting moreOptions = new BooleanSetting("More Options", this, false);
43
    private final NumberSetting delayHorizontal = new NumberSetting("Delayed Horizontal", this, 100.0, 0.0, 100.0, 0.1);
44
    private final NumberSetting delayVertical = new NumberSetting("Delayed Vertical", this, 100.0, 0.0, 100.0, 0.1);
45
    private final NumberSetting horizontalAttack = new NumberSetting("Horizontal Attack", this, 100.0, 0.0, 100.0, 0.1);
46
    private final NumberSetting verticalAttack = new NumberSetting("Vertical Attack", this, 100.0, 0.0, 100.0, 0.1);
47
    private final NumberSetting timer = new NumberSetting("Timer", this, 1, 0.1, 2, 0.1);
48
    private final NumberSetting timerTicks = new NumberSetting("Timer Ticks", this, 0, 0, 9, 0.1);
49
50
    private final NumberSetting ticksOption = new NumberSetting("Ticks", this, 3, 1, 20, 1);
51
52
    private int ticks, cancelTicks, row;
53
    private double motionY, motionX, motionZ;
54
    private boolean receivingVelocity, lastTick, countingTicks;
55
    private final ModuleManager moduleManager = Rise.INSTANCE.getModuleManager();
56
57
    @Override
58
    protected void onEnable() {
59
        receivingVelocity = false;
60
        countingTicks = false;
61
        lastTick = false;
62
        cancelTicks = 0;
63
        ticks = 0;
64
    }
65
66
    @Override
67
    public void onUpdateAlwaysInGui() {
68
        switch (mode.getMode()) {
69
            case "Custom":
70
            case "Redesky":
71
                horizontal.hidden = vertical.hidden = false;
72
73
                moreOptions.hidden = false;
74
75
                horizontalAttack.hidden = verticalAttack.hidden = timer.hidden = timerTicks.hidden
76
                        = delayHorizontal.hidden = delayVertical.hidden = !moreOptions.isEnabled();
77
                break;
78
79
            default:
80
                horizontal.hidden = vertical.hidden = horizontalAttack.hidden = verticalAttack.hidden = timer.hidden = timerTicks.hidden = delayHorizontal.hidden = delayVertical.hidden = true;
81
                moreOptions.hidden = true;
82
                break;
83
        }
84
85
        ticksOption.hidden = !mode.is("Tick Cancel");
86
    }
87
88
    @Override
89
    public void onStrafe(final StrafeEvent event) {
90
        switch (mode.getMode()) {
91
            case "Tick Cancel":
92
                if (cancelTicks >= ticksOption.getValue() && countingTicks) {
93
                    if (!(this.getModule(Speed.class).isEnabled() || this.getModule(LongJump.class).isEnabled() || this.getModule(Fly.class).isEnabled()))
94
                        mc.thePlayer.setVelocity(0, 0, 0);
95
                    countingTicks = false;
96
                }
97
                break;
98
99
            case "Minemenclub":
100
                if (cancelTicks >= 3 && countingTicks) {
101
                    if (!(this.getModule(Speed.class).isEnabled() || this.getModule(LongJump.class).isEnabled() || this.getModule(Fly.class).isEnabled()))
102
                        mc.thePlayer.setVelocity(0, 0, 0);
103
                    countingTicks = false;
104
                }
105
                break;
106
        }
107
    }
108
109
    @Override
110
    public void onPacketReceive(final PacketReceiveEvent event) {
111
        if (mc.thePlayer.onGround && onlyInAir.isEnabled()) return;
112
113
        final Packet<?> p = event.getPacket();
114
115
        if (p instanceof S12PacketEntityVelocity) {
116
            final S12PacketEntityVelocity packet = (S12PacketEntityVelocity) p;
117
118
            if (packet.getEntityID() == mc.thePlayer.getEntityId()) {
119
                switch (mode.getMode()) {
120
                    case "Custom": {
121
                        final double horizontal = this.horizontal.getValue();
122
                        final double vertical = this.vertical.getValue();
123
124
                        if (horizontal == 0.0 && vertical == 0.0) {
125
                            event.setCancelled(true);
126
                            return;
127
                        }
128
129
                        packet.motionX *= horizontal / 100.0;
130
                        packet.motionY *= vertical / 100.0;
131
                        packet.motionZ *= horizontal / 100.0;
132
133
                        event.setPacket(packet);
134
                        break;
135
                    }
136
137
                    case "Reverse": {
138
                        packet.motionX *= -1;
139
                        packet.motionZ *= -1;
140
                        event.setPacket(packet);
141
142
                        break;
143
                    }
144
145
                    case "Vulcan": {
146
                        final double horizontal = this.horizontal.getValue();
147
                        final double vertical = this.vertical.getValue();
148
149
                        if (horizontal == 0.0 && vertical == 0.0) {
150
                            event.setCancelled(true);
151
                            return;
152
                        }
153
                        break;
154
                    }
155
156
                    case "Tick Cancel": {
157
                        countingTicks = true;
158
                        cancelTicks = 0;
159
                        break;
160
                    }
161
162
                    case "Ground": {
163
                        receivingVelocity = true;
164
                        break;
165
                    }
166
167
                    case "Redesky": {
168
                        final double horizontal = this.horizontal.getValue();
169
                        final double vertical = this.vertical.getValue();
170
171
                        if (horizontal == 0.0 && vertical == 0.0) {
172
                            event.setCancelled(true);
173
                            return;
174
                        }
175
176
                        packet.motionX *= horizontal / 100.0;
177
                        packet.motionY *= vertical / 100.0;
178
                        packet.motionZ *= horizontal / 100.0;
179
180
                        //Epic halal aac5 velocity bypass
181
                        mc.getNetHandler().addToSendQueueWithoutEvent(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.START_SNEAKING));
182
                        receivingVelocity = true;
183
184
                        event.setCancelled(true);
185
                        break;
186
                    }
187
188
                    case "Stack": {
189
                        row++;
190
                        if (MoveUtil.isMoving()) {
191
                            if (row <= 2)
192
                                event.setCancelled(true);
193
                            else
194
                                row = 0;
195
                        } else
196
                            event.setCancelled(true);
197
                        break;
198
                    }
199
                    case "Minemenclub": {
200
                        if (this.getModule(Fly.class).isEnabled() || this.getModule(Speed.class).isEnabled()) {
201
                            row = 3;
202
                        }
203
204
                        row++;
205
                        if (MoveUtil.isMoving()) {
206
                            if (row <= 2)
207
                                event.setCancelled(true);
208
                            else {
209
                                countingTicks = !this.getModule(Speed.class).isEnabled();
210
                                cancelTicks = 0;
211
                                row = 0;
212
                            }
213
                        } else
214
                            event.setCancelled(true);
215
                        break;
216
                    }
217
218
                    case "Follow First Tick": {
219
                        event.setCancelled(true);
220
                        motionY = packet.getMotionY() / 8000f;
221
                        motionX = packet.getMotionX() / 8000f;
222
                        motionZ = packet.getMotionZ() / 8000f;
223
                        mc.thePlayer.motionY = 0.03;
224
                        //mc.thePlayer.motionZ = motionZ * 0.5;
225
                        //mc.thePlayer.motionX = motionX * 0.5;
226
                        lastTick = true;
227
                        break;
228
                    }
229
                }
230
            }
231
        }
232
233
        if (p instanceof S27PacketExplosion) {
234
            if (explosion.isEnabled()) {
235
236
                final S27PacketExplosion explosion = (S27PacketExplosion) p;
237
238
                switch (mode.getMode()) {
239
                    case "Custom":
240
                        final double horizontal = this.horizontal.getValue();
241
                        final double vertical = this.vertical.getValue();
242
243
                        if (horizontal == 0.0 && vertical == 0.0) {
244
                            event.setCancelled(true);
245
                            return;
246
                        }
247
248
                        explosion.posX *= horizontal / 100.0;
249
                        explosion.posY *= vertical / 100.0;
250
                        explosion.posZ *= horizontal / 100.0;
251
252
                        event.setPacket(explosion);
253
                        break;
254
                    default:
255
                        event.setCancelled(true);
256
                        break;
257
                }
258
            }
259
        }
260
    }
261
262
    @Override
263
    public void onPreMotion(final PreMotionEvent event) {
264
        if (countingTicks)
265
            cancelTicks++;
266
267
        ticks++;
268
269
        if (!moreOptions.isEnabled() || mc.thePlayer.onGround && onlyInAir.isEnabled()) return;
270
271
        switch (mode.getMode()) {
272
            case "Custom": {
273
                if (mc.thePlayer.hurtTime == 9) {
274
                    ticks = 0;
275
                }
276
277
                if (ticks < timerTicks.getValue()) {
278
                    mc.timer.timerSpeed = (float) timer.getValue();
279
                }
280
281
                if (ticks == (int) timerTicks.getValue() || mc.thePlayer == null || mc.thePlayer.ticksExisted < 3) {
282
                    mc.timer.timerSpeed = 1;
283
                }
284
285
                assert mc.thePlayer != null;
286
                if (mc.thePlayer.hurtTime == 9) {
287
                    motionX = mc.thePlayer.motionX;
288
                    motionY = mc.thePlayer.motionY;
289
                    motionZ = mc.thePlayer.motionZ;
290
                }
291
292
                if (mc.thePlayer.hurtTime == 8 && !Objects.requireNonNull(moduleManager.getModule("Fly")).isEnabled() && moreOptions.isEnabled()) {
293
                    mc.thePlayer.motionX *= delayHorizontal.getValue() / 100;
294
                    mc.thePlayer.motionY *= delayVertical.getValue() / 100;
295
                    mc.thePlayer.motionZ *= delayHorizontal.getValue() / 100;
296
                }
297
            }
298
            break;
299
300
            case "Ground": {
301
                if (receivingVelocity) {
302
                    mc.thePlayer.onGround = true;
303
                    receivingVelocity = false;
304
                }
305
                break;
306
            }
307
308
            case "Follow First Tick": {
309
                if (lastTick) {
310
                    event.setY(event.getY() + motionY);
311
                    event.setZ(event.getZ() + motionZ);
312
                    event.setX(event.getX() + motionX);
313
                    lastTick = false;
314
                }
315
            }
316
            break;
317
318
            case "Redesky": {
319
                if (mc.thePlayer.hurtTime == 9) {
320
                    ticks = 0;
321
                }
322
323
                if (ticks < timerTicks.getValue()) {
324
                    mc.timer.timerSpeed = (float) timer.getValue();
325
                }
326
327
                if (ticks == (int) timerTicks.getValue() || mc.thePlayer == null || mc.thePlayer.ticksExisted < 3) {
328
                    mc.timer.timerSpeed = 1;
329
                }
330
331
                assert mc.thePlayer != null;
332
                if (mc.thePlayer.hurtTime == 9) {
333
                    motionX = mc.thePlayer.motionX;
334
                    motionY = mc.thePlayer.motionY;
335
                    motionZ = mc.thePlayer.motionZ;
336
                }
337
338
                if (mc.thePlayer.hurtTime == 8 && !Objects.requireNonNull(moduleManager.getModule("Fly")).isEnabled() && moreOptions.isEnabled()) {
339
                    mc.thePlayer.motionX = motionX * (delayHorizontal.getValue() / 100);
340
                    mc.thePlayer.motionY = motionY * (delayVertical.getValue() / 100);
341
                    mc.thePlayer.motionZ = motionZ * (delayHorizontal.getValue() / 100);
342
                }
343
344
                if (receivingVelocity) {
345
                    mc.getNetHandler().addToSendQueueWithoutEvent(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING));
346
                    receivingVelocity = false;
347
                }
348
            }
349
            break;
350
        }
351
    }
352
353
    @Override
354
    public void onPacketSend(PacketSendEvent event) {
355
        Packet p = event.getPacket();
356
        switch (mode.getMode()) {
357
            case "Vulcan":
358
                if (mc.thePlayer.hurtTime > 0 && p instanceof C0FPacketConfirmTransaction) {
359
                    event.setCancelled(true);
360
                }
361
                break;
362
        }
363
    }
364
365
    @Override
366
    public void onAttackEvent(final AttackEvent event) {
367
        if (!moreOptions.isEnabled() || mc.thePlayer.onGround && onlyInAir.isEnabled()) return;
368
369
        if (mode.is("Custom") || mode.is("Redesky")) {
370
            if (mc.thePlayer.hurtTime > 0) {
371
                final double horiz = horizontalAttack.getValue() / 100;
372
                final double vert = verticalAttack.getValue() / 100;
373
374
                mc.thePlayer.motionZ *= horiz;
375
                mc.thePlayer.motionX *= horiz;
376
                mc.thePlayer.motionY *= vert;
377
            }
378
        }
379
    }
380
}

What this file does

The entire module lives in this one file. onPacketReceive holds the S12 branch with the entity-id check and the mode dispatch, and the S27 explosion branch gated by the explosion toggle; onPreMotion carries the tick counting, the timer window, the delayed damping at hurtTime 8, the Ground onGround fake, the Follow First Tick position offset and the Redesky sneak flush; onStrafe runs the setVelocity(0, 0, 0) zeroing for Tick Cancel and Minemenclub; onPacketSend cancels C0F confirmations in Vulcan mode; and onAttackEvent applies the attack-time damping. The mode setting is a plain string ModeSetting, so every mode shares the same class and the same state fields.

The modes that convert knockback into something else are the notable ones. Follow First Tick cancels the S12 and stores the fixed-point vector divided by 8000 into motionX/motionY/motionZ, then adds those values to the next PreMotionEvent position, so the server sees the movement as a position delta rather than a velocity response. Ground arms receivingVelocity and fakes onGround on the next tick. Tick Cancel and Minemenclub arm countingTicks and zero the motion with setVelocity once cancelTicks reaches the threshold, gated so Speed, LongJump and Fly are never fought. Stack and Minemenclub use the row counter plus MoveUtil.isMoving() to decide which knockbacks are dropped.

The timer window in Custom and Redesky is worth calling out: hurtTime == 9 resets ticks and snapshots the live motion, the timerSpeed setting (0.1 to 2.0) applies while ticks is below timerTicks, and the speed is restored to 1.0 the moment the window closes or the player is younger than 3 ticks. Because timerSpeed multiplies the client's tick rate, a value above 1.0 briefly accelerates the game loop after a hit, which the delayed-damping sliders are meant to compensate for.

source MoveUtil.java (movement helper)

MoveUtil.java352 lines · JavaOriginal ↗
1
/*
2
 * LiquidBounce Hacked Client
3
 * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4
 * https://github.com/CCBlueX/LiquidBounce/
5
 * Ty for borrow lol
6
 */
7
package dev.rise.util.player;
8
9
import dev.rise.Rise;
10
import dev.rise.event.impl.other.MoveEvent;
11
import dev.rise.event.impl.other.StrafeEvent;
12
import dev.rise.module.impl.player.Scaffold;
13
import lombok.experimental.UtilityClass;
14
import net.minecraft.block.Block;
15
import net.minecraft.block.BlockWeb;
16
import net.minecraft.client.Minecraft;
17
import net.minecraft.entity.player.EntityPlayer;
18
import net.minecraft.init.Blocks;
19
import net.minecraft.network.play.client.C03PacketPlayer;
20
import net.minecraft.potion.Potion;
21
import net.minecraft.util.MathHelper;
22
import net.minecraft.util.MovementInput;
23
24
import javax.vecmath.Vector2d;
25
26
/**
27
 * MoveUtils, used to move in modules
28
 *
29
 * @author Liquidbounce
30
 * @since 13/02/2021
31
 */
32
33
@UtilityClass
34
public final class MoveUtil {
35
36
    private final Minecraft mc = Minecraft.getMinecraft();
37
38
    /**
39
     * Used to get the players speed
40
     */
41
    public double getSpeed() {
42
        // nigga hypot heavy
43
        return Math.hypot(mc.thePlayer.motionX, mc.thePlayer.motionZ);
44
    }
45
46
    /**
47
     * Sets current speed to itself make strafe
48
     */
49
    public void strafe() {
50
        strafe(getSpeed());
51
    }
52
53
    /**
54
     * Checks if the player is moving
55
     */
56
    public boolean isMoving() {
57
        return mc.thePlayer != null && (mc.thePlayer.movementInput.moveForward != 0F || mc.thePlayer.movementInput.moveStrafe != 0F);
58
    }
59
60
    public void stop() {
61
        mc.thePlayer.motionX = mc.thePlayer.motionZ = 0;
62
    }
63
64
    /**
65
     * Sets players speed, with floats
66
     */
67
    public void strafe(final float speed) {
68
        if (!isMoving()) return;
69
70
        final double yaw = getDirection();
71
72
        mc.thePlayer.motionX = -MathHelper.sin((float) yaw) * speed;
73
        mc.thePlayer.motionZ = MathHelper.cos((float) yaw) * speed;
74
    }
75
76
    /**
77
     * Used to get the players speed, with doubles
78
     */
79
    public void strafe(final double speed) {
80
        if (!isMoving()) return;
81
82
        final double yaw = getDirection();
83
        mc.thePlayer.motionX = -MathHelper.sin((float) yaw) * speed;
84
        mc.thePlayer.motionZ = MathHelper.cos((float) yaw) * speed;
85
    }
86
87
    public void forward(final double speed) {
88
        final double yaw = getDirection();
89
90
        mc.thePlayer.motionX = -Math.sin(yaw) * speed;
91
        mc.thePlayer.motionZ = Math.cos(yaw) * speed;
92
    }
93
94
    /**
95
     * Basically calculates allowed horizontal distance just like NCP does
96
     *
97
     * @return allowed horizontal distance in one tick
98
     */
99
    public double getAllowedHorizontalDistance() {
100
        double horizontalDistance;
101
        boolean useBaseModifiers = false;
102
103
        if (PlayerUtil.getBlockRelativeToPlayer(0, 0, 0) instanceof BlockWeb) {
104
            horizontalDistance = 0.105;
105
        } else if (mc.thePlayer.isInLiquid()) {
106
            horizontalDistance = 0.115F;
107
        } else if (mc.thePlayer.isSneaking()) {
108
            horizontalDistance = 0.3F * 0.221;
109
        } else {
110
            horizontalDistance = 0.221;
111
            useBaseModifiers = true;
112
        }
113
114
        if (useBaseModifiers) {
115
            if (Math.abs(mc.thePlayer.moveForward) >= 0.8F || Math.abs(mc.thePlayer.moveStrafing) >= 0.8F) {
116
                horizontalDistance *= 1.3F;
117
            }
118
119
            final Scaffold scaffold = (Scaffold) Rise.INSTANCE.getModuleManager().getModule("Scaffold");
120
121
            if (mc.thePlayer.isPotionActive(Potion.moveSpeed) && mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getDuration() > 0) {
122
                horizontalDistance *= 1 + (0.2 * (mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1));
123
            }
124
125
            if (mc.thePlayer.isPotionActive(Potion.moveSlowdown)) {
126
                horizontalDistance = 0.29;
127
            }
128
        }
129
130
        final Block below = PlayerUtil.getBlockRelativeToPlayer(0, -1, 0);
131
        if (below == Blocks.ice || below == Blocks.packed_ice) {
132
            horizontalDistance *= 2.5F;
133
        }
134
135
        return horizontalDistance;
136
    }
137
138
139
    public double moveSpeed() {
140
        if (mc.gameSettings.keyBindSprint.isKeyDown()) {
141
            if (mc.thePlayer.isPotionActive(Potion.moveSpeed)) {
142
                if (mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1 == 1) {
143
                    return 0.18386012061481244;
144
                } else {
145
                    return 0.21450346015841276;
146
                }
147
            } else {
148
                return 0.15321676228437875;
149
            }
150
        } else {
151
            if (mc.thePlayer.isPotionActive(Potion.moveSpeed)) {
152
                if (mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1 == 1) {
153
                    return 0.14143085686761;
154
                } else {
155
                    return 0.16500264553372018;
156
                }
157
            } else {
158
                return 0.11785905094607611;
159
            }
160
        }
161
    }
162
163
    /**
164
     * Used to get the players speed with a custom yaw
165
     */
166
    public void strafe(final double speed, double yaw) {
167
        if (!isMoving()) return;
168
169
        if (EntityPlayer.movementYaw != null) {
170
            yaw = EntityPlayer.movementYaw;
171
        }
172
173
        mc.thePlayer.motionX = -MathHelper.sin((float) yaw) * speed;
174
        mc.thePlayer.motionZ = MathHelper.cos((float) yaw) * speed;
175
    }
176
177
    /**
178
     * Gets the direction of were the player is looking
179
     */
180
    public double getDirection() {
181
        float rotationYaw = mc.thePlayer.rotationYaw;
182
183
        if (mc.thePlayer.moveForward < 0F) rotationYaw += 180F;
184
185
        float forward = 1F;
186
187
        if (mc.thePlayer.moveForward < 0F) forward = -0.5F;
188
        else if (mc.thePlayer.moveForward > 0F) forward = 0.5F;
189
190
        if (mc.thePlayer.moveStrafing > 0F) rotationYaw -= 90F * forward;
191
        if (mc.thePlayer.moveStrafing < 0F) rotationYaw += 90F * forward;
192
193
        return Math.toRadians(rotationYaw);
194
    }
195
196
    public double getDirectionWrappedTo90() {
197
        float rotationYaw = mc.thePlayer.rotationYaw;
198
199
        if (mc.thePlayer.moveForward < 0F && mc.thePlayer.moveStrafing == 0F) rotationYaw += 180F;
200
201
        final float forward = 1F;
202
203
        if (mc.thePlayer.moveStrafing > 0F) rotationYaw -= 90F * forward;
204
        if (mc.thePlayer.moveStrafing < 0F) rotationYaw += 90F * forward;
205
206
        return Math.toRadians(rotationYaw);
207
    }
208
209
    public double getDirection(final float yaw) {
210
        float rotationYaw = yaw;
211
212
        if (EntityPlayer.movementYaw != null) {
213
            rotationYaw = EntityPlayer.movementYaw;
214
        }
215
216
        if (mc.thePlayer.moveForward < 0F) rotationYaw += 180F;
217
218
        float forward = 1F;
219
220
        if (mc.thePlayer.moveForward < 0F) forward = -0.5F;
221
        else if (mc.thePlayer.moveForward > 0F) forward = 0.5F;
222
223
        if (mc.thePlayer.moveStrafing > 0F) rotationYaw -= 90F * forward;
224
        if (mc.thePlayer.moveStrafing < 0F) rotationYaw += 90F * forward;
225
226
        return Math.toRadians(rotationYaw);
227
    }
228
229
    /**
230
     * Used to get base movement speed
231
     */
232
    public double getBaseMoveSpeed() {
233
        double baseSpeed = 0.2873D;
234
235
        if (mc.thePlayer.isPotionActive(Potion.moveSpeed))
236
            baseSpeed *= 1.0D + 0.2D * (mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1);
237
238
        return baseSpeed;
239
    }
240
241
    public double getBaseMoveSpeedOther() {
242
        double baseSpeed = 0.2875D;
243
244
        if (mc.thePlayer.isPotionActive(Potion.moveSpeed))
245
            baseSpeed *= 1.0D + 0.2D * (mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1);
246
247
        return baseSpeed;
248
    }
249
250
    public double getJumpMotion(float motionY) {
251
        final Potion potion = Potion.jump;
252
253
        if (mc.thePlayer.isPotionActive(potion)) {
254
            final int amplifier = mc.thePlayer.getActivePotionEffect(potion).getAmplifier();
255
            motionY += (amplifier + 1) * 0.1F;
256
        }
257
258
        return motionY;
259
    }
260
261
    public double getPredictedMotionY(final double motionY) {
262
        return (motionY - 0.08) * 0.98F;
263
    }
264
265
    public void setMoveEventSpeed(final MoveEvent moveEvent, final double moveSpeed) {
266
        setMoveEvent(moveEvent, moveSpeed, mc.thePlayer.rotationYaw, mc.thePlayer.movementInput.moveStrafe, mc.thePlayer.movementInput.moveForward);
267
    }
268
269
    // jumps without setting motionY to 0.42F
270
    // in other words, increases motionX/Z and everything else that the jump method does, allowing a custom motionY
271
    public void jumpNoMotionY() {
272
        double motionY = mc.thePlayer.motionY;
273
        mc.thePlayer.jump();
274
        mc.thePlayer.motionY = motionY;
275
    }
276
277
    public void sendMotion(final double speed, final double dist) {
278
        final Vector2d motion = getMotion(dist);
279
        double d = dist;
280
        while (d < speed) {
281
            mc.thePlayer.moveEntityNoEvent(motion.x, 0, motion.y);
282
            PacketUtil.sendPacket(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, true));
283
            d += dist;
284
        }
285
    }
286
287
    public Vector2d getMotion(final double moveSpeed) {
288
        final MovementInput movementInput = mc.thePlayer.movementInput;
289
290
        double moveForward = movementInput.moveForward;
291
        double moveStrafe = movementInput.moveStrafe;
292
293
        double rotationYaw = mc.thePlayer.rotationYaw;
294
        if (moveForward != 0.0D || moveStrafe != 0.0D) {
295
            if (moveStrafe > 0) {
296
                moveStrafe = 1;
297
            } else if (moveStrafe < 0) {
298
                moveStrafe = -1;
299
            }
300
            if (moveForward != 0.0D) {
301
                if (moveStrafe > 0.0D) {
302
                    rotationYaw += moveForward > 0.0D ? -45 : 45;
303
                } else if (moveStrafe < 0.0D) {
304
                    rotationYaw += moveForward > 0.0D ? 45 : -45;
305
                }
306
                moveStrafe = 0.0D;
307
                if (moveForward > 0.0D) {
308
                    moveForward = 1.0D;
309
                } else if (moveForward < 0.0D) {
310
                    moveForward = -1.0D;
311
                }
312
            }
313
            rotationYaw *= 0.995;
314
            final double cos = Math.cos(Math.toRadians(rotationYaw + 90.0F));
315
            final double sin = Math.sin(Math.toRadians(rotationYaw + 90.0F));
316
            return new Vector2d(moveForward * moveSpeed * cos
317
                    + moveStrafe * moveSpeed * sin, moveForward * moveSpeed * sin
318
                    - moveStrafe * moveSpeed * cos);
319
        }
320
        return new Vector2d(0, 0);
321
    }
322
323
    public void setMoveEvent(final MoveEvent moveEvent, final double moveSpeed, final float pseudoYaw, final double pseudoStrafe, final double pseudoForward) {
324
        double forward = pseudoForward;
325
        double strafe = pseudoStrafe;
326
        float yaw = pseudoYaw;
327
328
        if (forward != 0.0D) {
329
            if (strafe > 0.0D) {
330
                yaw += ((forward > 0.0D) ? -45 : 45);
331
            } else if (strafe < 0.0D) {
332
                yaw += ((forward > 0.0D) ? 45 : -45);
333
            }
334
            strafe = 0.0D;
335
            if (forward > 0.0D) {
336
                forward = 1.0D;
337
            } else if (forward < 0.0D) {
338
                forward = -1.0D;
339
            }
340
        }
341
        if (strafe > 0.0D) {
342
            strafe = 1.0D;
343
        } else if (strafe < 0.0D) {
344
            strafe = -1.0D;
345
        }
346
        final double mx = Math.cos(Math.toRadians((yaw + 90.0F)));
347
        final double mz = Math.sin(Math.toRadians((yaw + 90.0F)));
348
        moveEvent.setX(forward * moveSpeed * mx + strafe * moveSpeed * mz);
349
        moveEvent.setZ(forward * moveSpeed * mz - strafe * moveSpeed * mx);
350
    }
351
352
}

What this file does

MoveUtil.isMoving() is the only helper the Velocity module reads. It returns true when the player's movementInput has a nonzero moveForward or moveStrafe, i.e. a key is currently held, and it is what distinguishes a stationary player from a moving one in the Stack and Minemenclub modes: Stack cancels every knockback while stationary and only the first two of three while moving, and Minemenclub applies the same row logic with a shortcut that forces row to 3 when Fly or Speed is enabled. The Tick Cancel zeroing in onStrafe does not consult isMoving directly, but it is gated on Speed, LongJump and Fly being disabled, so the helper is the module's only external dependency.

The rest of the file is the client's general movement toolbox: strafe() variants that rewrite motionX/motionZ from the facing yaw at a target speed, forward(), stop() and getSpeed() helpers, and prediction utilities used by other combat and movement modules. Only isMoving is relevant to the Velocity module, which is why the box is included: it shows the exact input state the row-counting logic reads.

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 KnockbackHandler (AntiKB, prediction offset)

KnockbackHandler.java262 lines · Java
1
package ac.grim.grimac.checks.impl.velocity;
2
3
import ac.grim.grimac.api.config.ConfigManager;
4
import ac.grim.grimac.api.storage.verbose.Verbose;
5
import ac.grim.grimac.checks.Check;
6
import ac.grim.grimac.checks.CheckData;
7
import ac.grim.grimac.checks.type.PacketSendListener;
8
import ac.grim.grimac.checks.type.PostPredictionListener;
9
import ac.grim.grimac.player.GrimPlayer;
10
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
11
import ac.grim.grimac.utils.data.Pair;
12
import ac.grim.grimac.utils.data.VectorData;
13
import ac.grim.grimac.utils.data.VelocityData;
14
import ac.grim.grimac.utils.math.Vector3dm;
15
import com.github.retrooper.packetevents.event.PacketSendEvent;
16
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
17
import com.github.retrooper.packetevents.util.Vector3d;
18
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityVelocity;
19
import lombok.Getter;
20
import org.jetbrains.annotations.NotNull;
21
22
import java.util.Deque;
23
import java.util.LinkedList;
24
25
// We are making a velocity sandwich between two pieces of transaction packets (bread)
26
@CheckData(name = "AntiKB", stableKey = "grim.velocity.anti_knockback", alternativeName = "AntiKnockback", configName = "Knockback", description = "Did not take the expected entity knockback", setback = 10, decay = 0.025)
27
public class KnockbackHandler extends Check implements PacketSendListener, PostPredictionListener {
28
    private static final Verbose V = Verbose.of("[ignored knockback|o: {offset}]");
29
30
    private final Deque<VelocityData> firstBreadMap = new LinkedList<>();
31
32
    private final Deque<VelocityData> lastKnockbackKnownTaken = new LinkedList<>();
33
    private VelocityData firstBreadOnlyKnockback = null;
34
    @Getter
35
    private boolean knockbackPointThree = false;
36
37
    private double offsetToFlag;
38
    private double maxAdv, immediate, ceiling, multiplier;
39
40
    private double threshold;
41
42
    public KnockbackHandler(GrimPlayer player) {
43
        super(player);
44
    }
45
46
    @Override
47
    public void onPacketSend(final PacketSendEvent event) {
48
        if (event.getPacketType() == PacketType.Play.Server.ENTITY_VELOCITY) {
49
            WrapperPlayServerEntityVelocity velocity = new WrapperPlayServerEntityVelocity(event);
50
            int entityId = velocity.getEntityId();
51
52
            // Detect whether this knockback packet affects the player or if it is useless
53
            // Mojang sends extra useless knockback packets for no apparent reason
54
            if (player.compensatedEntities.serverPlayerVehicle != null && entityId != player.compensatedEntities.serverPlayerVehicle) {
55
                return;
56
            }
57
            if (player.compensatedEntities.serverPlayerVehicle == null && entityId != player.entityID) {
58
                return;
59
            }
60
61
            // If the player isn't in a vehicle and the ID is for the player, the player will take kb
62
            // If the player is in a vehicle and the ID is for the player's vehicle, the player will take kb
63
            Vector3d playerVelocity = velocity.getVelocity();
64
65
            // Blacklist problemated vector until mojang fixes a client-sided bug
66
            if (playerVelocity.getY() == -0.04) {
67
                velocity.setVelocity(playerVelocity.add(new Vector3d(0, 1 / 8000D, 0)));
68
                playerVelocity = velocity.getVelocity();
69
                event.markForReEncode(true);
70
            }
71
72
            playerVelocity = VectorPrecisionConverter.convert(player.getClientVersion(), playerVelocity);
73
74
            // Wrap velocity between two transactions
75
            player.sendTransaction();
76
            addPlayerKnockback(entityId, player.lastTransactionSent.get(), new Vector3dm(playerVelocity.getX(), playerVelocity.getY(), playerVelocity.getZ()));
77
            event.getTasksAfterSend().add(player::sendTransaction);
78
        }
79
    }
80
81
    @NotNull
82
    public Pair<VelocityData, Vector3dm> getFutureKnockback() {
83
        // Chronologically in the future
84
        if (!firstBreadMap.isEmpty()) {
85
            VelocityData data = firstBreadMap.peek();
86
            return new Pair<>(data, data != null ? data.vector : null);
87
        }
88
89
        // Less in the future
90
        if (!lastKnockbackKnownTaken.isEmpty()) {
91
            VelocityData data = lastKnockbackKnownTaken.peek();
92
            return new Pair<>(data, data != null ? data.vector : null);
93
        }
94
95
        // Uncertain, might be in the future
96
        if (player.firstBreadKB != null && player.likelyKB == null) {
97
            VelocityData data = player.firstBreadKB;
98
            return new Pair<>(data, data.vector.clone());
99
        } else if (player.likelyKB != null) { // Known to be in the present
100
            VelocityData data = player.likelyKB;
101
            return new Pair<>(data, data.vector.clone());
102
        }
103
        return new Pair<>(null, null);
104
    }
105
106
    private void addPlayerKnockback(int entityID, int breadOne, @NotNull Vector3dm knockback) {
107
        firstBreadMap.add(new VelocityData(entityID, breadOne, player.getSetbackTeleportUtil().isSendingSetback, knockback));
108
    }
109
110
    public VelocityData calculateRequiredKB(int entityID, int transaction, boolean isJustTesting) {
111
        tickKnockback(transaction);
112
113
        VelocityData returnLastKB = null;
114
        for (VelocityData data : lastKnockbackKnownTaken) {
115
            if (data.entityID == entityID)
116
                returnLastKB = data;
117
        }
118
119
        if (!isJustTesting) {
120
            lastKnockbackKnownTaken.clear();
121
        }
122
        return returnLastKB;
123
    }
124
125
    private void tickKnockback(int transactionID) {
126
        firstBreadOnlyKnockback = null;
127
        if (firstBreadMap.isEmpty()) return;
128
        VelocityData data = firstBreadMap.peek();
129
        while (data != null) {
130
            if (data.transaction == transactionID) { // First bread knockback
131
                firstBreadOnlyKnockback = new VelocityData(data.entityID, data.transaction, data.isSetback, data.vector);
132
                //firstBreadMap.poll();
133
                break; // All knockback after this will have not been applied
134
            } else if (data.transaction < transactionID) { // This kb has 100% arrived to the player
135
                VelocityData velocityData = new VelocityData(data.entityID, data.transaction, data.isSetback, data.vector);
136
137
                if (firstBreadOnlyKnockback != null) { // Don't require kb twice
138
                    velocityData.offset = data.offset;
139
                }
140
141
                lastKnockbackKnownTaken.add(velocityData);
142
143
                // Knockback has been applied and is now required, remove it from first bread
144
                firstBreadOnlyKnockback = null;
145
                firstBreadMap.poll();
146
                data = firstBreadMap.peek();
147
            } else { // We are too far ahead in the future
148
                break;
149
            }
150
        }
151
    }
152
153
    public void forceExempt() {
154
        // Unsure knockback was taken
155
        if (player.firstBreadKB != null) {
156
            player.firstBreadKB.offset = 0;
157
        }
158
159
        if (player.likelyKB != null) {
160
            player.likelyKB.offset = 0;
161
        }
162
    }
163
164
    public void setPointThree(boolean isPointThree) {
165
        knockbackPointThree = knockbackPointThree || isPointThree;
166
    }
167
168
    public void handlePredictionAnalysis(double offset) {
169
        if (player.firstBreadKB != null) {
170
            player.firstBreadKB.offset = Math.min(player.firstBreadKB.offset, offset);
171
        }
172
173
        if (player.likelyKB != null) {
174
            player.likelyKB.offset = Math.min(player.likelyKB.offset, offset);
175
        }
176
    }
177
178
    @Override
179
    public void onPredictionComplete(final PredictionComplete predictionComplete) {
180
        double offset = predictionComplete.getOffset();
181
        if (!predictionComplete.isChecked() || predictionComplete.getData().isTeleport()) {
182
            forceExempt();
183
            return;
184
        }
185
186
        boolean wasZero = knockbackPointThree;
187
        knockbackPointThree = false;
188
189
        if (player.likelyKB == null && player.firstBreadKB == null) {
190
            return;
191
        }
192
193
        if (player.predictedVelocity.isFirstBreadKb()) {
194
            firstBreadOnlyKnockback = null;
195
            firstBreadMap.poll(); // Remove from map so we don't pull it again
196
        }
197
198
        if (wasZero || player.predictedVelocity.isKnockback()) {
199
            // Unsure knockback was taken
200
            if (player.firstBreadKB != null) {
201
                player.firstBreadKB.offset = Math.min(player.firstBreadKB.offset, offset);
202
            }
203
204
            // 100% known kb was taken
205
            if (player.likelyKB != null) {
206
                player.likelyKB.offset = Math.min(player.likelyKB.offset, offset);
207
            }
208
        }
209
210
        if (player.likelyKB != null) {
211
            if (player.likelyKB.offset > offsetToFlag) {
212
                threshold = Math.min(threshold + player.likelyKB.offset, ceiling);
213
                if (player.likelyKB.isSetback) { // Don't increase violations if this velocity was setback, just teleport and resend them velocity.
214
                    if (!isNoSetbackPermission()) {
215
                        player.getSetbackTeleportUtil().executeViolationSetback();
216
                    }
217
                } else {
218
                    boolean ignored = player.likelyKB.offset == Integer.MAX_VALUE;
219
                    if (flag(V.write(verbose()).bool(ignored).f64(player.likelyKB.offset))) { // This velocity was sent by the server.
220
                        if (player.likelyKB.offset >= immediate || threshold >= maxAdv) {
221
                            setbackIfAboveSetbackVL();
222
                        }
223
                    } else {
224
                        reward();
225
                    }
226
                }
227
            } else if (threshold > 0.05) {
228
                threshold *= multiplier;
229
            }
230
        }
231
    }
232
233
    public boolean shouldIgnoreForPrediction(VectorData data) {
234
        if (data.isKnockback() && data.isFirstBreadKb()) {
235
            return player.firstBreadKB.offset > offsetToFlag;
236
        }
237
        return false;
238
    }
239
240
    public boolean wouldFlag() {
241
        return (player.likelyKB != null && player.likelyKB.offset > offsetToFlag) || (player.firstBreadKB != null && player.firstBreadKB.offset > offsetToFlag);
242
    }
243
244
    public VelocityData calculateFirstBreadKnockback(int entityID, int transaction) {
245
        tickKnockback(transaction);
246
        if (firstBreadOnlyKnockback != null && firstBreadOnlyKnockback.entityID == entityID)
247
            return firstBreadOnlyKnockback;
248
        return null;
249
    }
250
251
    @Override
252
    public void onReload(@NotNull ConfigManager config) {
253
        offsetToFlag = config.getDoubleElse("Knockback.threshold", 0.001);
254
        maxAdv = config.getDoubleElse("Knockback.max-advantage", 1);
255
        immediate = config.getDoubleElse("Knockback.immediate-setback-threshold", 0.1);
256
        multiplier = config.getDoubleElse("Knockback.setback-decay-multiplier", 0.999);
257
        ceiling = config.getDoubleElse("Knockback.max-ceiling", 4);
258
        if (maxAdv < 0) maxAdv = Double.MAX_VALUE;
259
        if (immediate < 0) immediate = Double.MAX_VALUE;
260
    }
261
262
}

How it counteracts this module

Grim's KnockbackHandler is a PacketSendListener on ENTITY_VELOCITY that sandwiches the packet between two server transactions: sendTransaction() before the velocity and a second transaction through tasksAfterSend after it. The velocity is recorded into firstBreadMap keyed by the first transaction id, and tickKnockback promotes an entry into lastKnockbackKnownTaken once a transaction with a larger id arrives, which proves the packet reached the client. From that moment the knockback vector is required movement: the prediction engine must see it in the player's motion.

onPredictionComplete compares the prediction offset against offsetToFlag (config Knockback.threshold, default 0.001). A player whose movement lacks the required vector accumulates the offset into a threshold (decay 0.999, ceiling 4) and is set back when the offset is at least 0.1 (immediate-setback-threshold) or the threshold reaches maxAdvantage 1. Among Rise 5.99's modes, Custom at 0/0, Vulcan, Stack while stationary and Minemenclub's zeroed window are direct hits: the required vector never appears and the offset is the full knockback. Tick Cancel's late zeroing also loses because the vector was required from the moment the sandwich confirmed, before the Ticks window elapses. Follow First Tick re-adds the motion as a position delta on the next C03, but Grim predicts velocity, so the instant position jump of the knockback magnitude still diverges from the predicted profile.

The mode this check does not catch is one that also swallows the sandwich. Redesky's sneak pair does not help, since Grim's transaction clock is independent of sneak state. The honest bypass surface is transaction eating: if the client cancels the second transaction receipt and its echo, the velocity is never promoted out of the uncertain firstBreadMap bucket and is never required, so no offset accrues. November's GRIM mode is built exactly this way; the cost is a transaction ledger that diverges from the server's, which Grim's transaction-order accounting and the vanilla inventory/UI confirmations notice over time.

anticheat AntiVelocityBasic (pending knockback matching)

AntiVelocityBasic.java46 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.movement.position;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.MovementCheck;
23
import me.islandscout.hawk.check.Cancelless;
24
import me.islandscout.hawk.event.MoveEvent;
25
26
/**
27
 * The AntiVelocityBasic check verifies that players accept knockback.
28
 * It relies on MoveEvent's knockback acceptance detection.
29
 * The AntiVelocityBasic check has been tested to detect as low as a
30
 * 10% difference in horizontal and/or vertical knockback.
31
 */
32
public class AntiVelocityBasic extends MovementCheck implements Cancelless {
33
34
    public AntiVelocityBasic() {
35
        super("antivelocitybasic", true, -1, 5, 0.999, 5000, "%player% may be using anti-velocity (basic), VL: %vl%", null);
36
    }
37
38
    @Override
39
    protected void check(MoveEvent event) {
40
        HawkPlayer pp = event.getHawkPlayer();
41
        if(event.hasFailedKnockback())
42
            punish(pp, false, event);
43
        else
44
            reward(pp);
45
    }
46
}

How it counteracts this module

Hawk's MoveEvent matches every move's current velocity against the list of pending knockbacks. Each pending entry is a vector plus the time the server sent it, and it stays eligible while the elapsed time is within the player's ping plus 200ms. A match requires the move's Y to be within 0.01 of the knockback's Y (unless the player collides with a block above or below, jumps, swims or steps), and X and Z to fall inside maxDiscrepancy, computed as weirdConstant times baseMultiplier times sprintMultiplier plus an 0.003 epsilon, where the constants come from walk speed, speed potions and the sprint multiplier. When a knockback entry becomes older than ping plus 200ms without any move matching it, failedKnockback is set (outside vehicles), and AntiVelocityBasic.check punishes with the flag message 'may be using anti-velocity (basic)' at 5 VL.

The class comment claims detection down to a 10% difference, which is the size of the maxDiscrepancy window relative to a typical knockback vector. A full cancellation (Custom at 0/0, Vulcan, Stack while stationary, Minemenclub's zeroed window) leaves the entry with no matching move, so it expires and flags. A partial reduction (Custom 50/50, REDUCE style scaling) stays under the tolerance only when the scaled-down remainder still sits inside maxDiscrepancy; the stronger the original hit, the larger the absolute gap a fixed percentage leaves, so moderate to heavy reductions flag. Follow First Tick is also caught: its position-delta re-add produces a large instantaneous Y change that fails the 0.01 Y match.

The check is content-blind and cheap: it needs only the pending list and the move deltas, with no velocity prediction. Its bypass surface is the tolerance itself: small reductions that keep the movement within maxDiscrepancy pass, and the ping-plus-200ms window forgives a knockback the player simply has not moved into yet. Among Rise 5.99's modes, only tiny percentage reductions in Custom mode sit inside that tolerance; every cancel-based mode is caught.

anticheat VelocityA (sent vector vs reported rise)

VelocityA.java70 lines · Java
1
package us.skidrevenant.azure.check.checks.combat.velocity;
2
3
import net.minecraft.server.v1_8_R3.Packet;
4
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
5
import org.bukkit.Location;
6
import org.bukkit.event.player.PlayerMoveEvent;
7
import us.skidrevenant.azure.check.Check;
8
import us.skidrevenant.azure.stats.PlayerStats;
9
import us.skidrevenant.azure.util.reflection.ReflectionUtil;
10
11
/**
12
 * @author SkidRevenant
13
 * at 30/05/2018
14
 */
15
public class VelocityA extends Check {
16
17
    private double verticalVelocity;
18
19
    public VelocityA(PlayerStats player) {
20
        super(player);
21
    }
22
23
    @Override
24
    public void onMove(Location from, Location to, PlayerMoveEvent event) {
25
        if (from.getY() >= to.getY()) {
26
            return;
27
        }
28
29
        double deltaY = to.getY() - from.getY();
30
31
        if (deltaY > 0 && deltaY < 0.42 && deltaY < verticalVelocity * 0.77) {
32
            long velocity = Math.round(100.0 * deltaY / verticalVelocity);
33
            verticalVelocity = 0;
34
35
            onViolation(String.format("Velocity Type A (%d%%)", velocity), 10000L, 4);
36
        }
37
    }
38
39
    @Override
40
    public void onPacketSend(Class<? extends Packet> type, Packet packet) {
41
        if (type == PacketPlayOutEntityVelocity.class) {
42
            PacketPlayOutEntityVelocity entityVelocity = (PacketPlayOutEntityVelocity) packet;
43
44
            int entityId = ReflectionUtil.getFieldValue(ReflectionUtil.getField(PacketPlayOutEntityVelocity.class, "a", int.class), entityVelocity);
45
46
            if (entityId == player.getBukkitPlayer().getEntityId()) {
47
48
                if (player.getBukkitPlayer().getLastDamageCause() != null) {
49
                    switch (player.getBukkitPlayer().getLastDamageCause().getCause()) {
50
                        case STARVATION:
51
                        case FIRE_TICK:
52
                        case DROWNING:
53
                        case POISON:
54
                        case WITHER:
55
                        case THORNS:
56
                        case FALL:
57
                        case LAVA:
58
                        case FIRE:
59
60
                            verticalVelocity = 0;
61
                            return;
62
                    }
63
                }
64
65
                verticalVelocity = (int) ReflectionUtil.getFieldValue(ReflectionUtil.getField(PacketPlayOutEntityVelocity.class, "c", int.class), entityVelocity) / 8000.0;
66
            }
67
68
        }
69
    }
70
}

How it counteracts this module

Azure's VelocityA compares the vertical component of the knockback the server sent against the rise the player actually reports. On the send side, onPacketSend records verticalVelocity from the S12's fixed-point Y field divided by 8000.0 whenever the entity id matches the player, skipping damage causes that produce no knockback (starvation, fire tick, drowning, poison, wither, thorns, fall, lava, fire). On the move side, onMove only proceeds when the player rose (to.getY() greater than from.getY()), computes deltaY, and flags when deltaY is positive, below the 0.42 jump height, and below 77% of the recorded verticalVelocity. The violation message prints the percentage as round(100 times deltaY over verticalVelocity) and applies a 10000ms cooldown with 4 VL.

Because verticalVelocity is read from the packet the server itself sent, client-side scaling cannot change the denominator. Rise 5.99's Custom mode at 50% vertical produces a rise around half the sent vector, ratio 0.5, which is well under the 0.77 threshold and flags as Velocity Type A (50%). Any vertical percentage from 1 through 76 flags; 80% and above stays under the threshold. The check's blind spot is full cancellation: a cancelled knockback means the player never rises, so the from.getY() >= to.getY() early return fires and nothing is flagged. Horizontal-only changes (Custom horizontal 0 with vertical 100, Reverse, and the delayed horizontal sliders) are also invisible to it, since it only inspects the vertical axis.

Among Rise 5.99's modes, Custom at partial vertical, Redesky at partial vertical, and the delayed vertical damping in the More Options group all produce reduced rises that flag. Tick Cancel, Minemenclub, Stack, Vulcan and Follow First Tick cancel or zero the movement entirely, which the check does not see at all: it needs a rise, any rise, to have something to compare. The 0.42 cap also means a normal jump, which is exactly 0.42, is never mistaken for knockback.

anticheat UnusedVelocity (unused knockback ledger)

UnusedVelocity.java87 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.moving.player;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.checks.CheckType;
20
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
21
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
22
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleAxisVelocity;
23
import fr.neatmonster.nocheatplus.checks.moving.velocity.UnusedTracker;
24
import fr.neatmonster.nocheatplus.logging.debug.DebugUtil;
25
import fr.neatmonster.nocheatplus.players.IPlayerData;
26
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
27
28
public class UnusedVelocity {
29
    
30
    // TODO: Currently is debug only (!). Only call if some debug flag is set. Needs checks.moving.debug to work at all.
31
32
    /**
33
     * Test if any unused velocity has been tracked and what that means. (Convenience.)
34
     * 
35
     * @param player
36
     * @return If the player has failed the check, whatever that means.
37
     */
38
    public static boolean checkUnusedVelocity(final Player player, 
39
            final CheckType checkType, final IPlayerData pData) {
40
        return checkUnusedVelocity(
41
                player, checkType, 
42
                pData.getGenericInstance(MovingData.class), 
43
                pData.getGenericInstance(MovingConfig.class)
44
                );
45
    }
46
47
48
    /**
49
     * Test if any unused velocity has been tracked and what that means.
50
     * 
51
     * @param player
52
     * @param data
53
     * @param cc
54
     * @return If the player has failed the check, whatever that means.
55
     */
56
    public static boolean checkUnusedVelocity(final Player player, 
57
            final CheckType checkType, final MovingData data, final MovingConfig cc) {
58
        boolean violation = false;
59
        final SimpleAxisVelocity verVel = data.getVerticalVelocityTracker();
60
        violation |= quickCheckDirection(player, verVel.unusedTrackerPos, checkType, "vert/pos", data, cc);
61
        violation |= quickCheckDirection(player, verVel.unusedTrackerNeg, checkType, "vert/neg", data, cc);
62
        return violation;
63
    }
64
65
    /**
66
     * Quick check tracker for one direction.
67
     * @param player
68
     * @param checkType 
69
     * @param unusedTrackerPos
70
     * @param string
71
     * @param data
72
     * @param cc
73
     */
74
    private static boolean quickCheckDirection(final Player player, 
75
            final UnusedTracker tracker, final CheckType checkType, final String trackerId ,
76
            MovingData data, MovingConfig cc) {
77
        final int countV = tracker.getResultViolationCount();
78
        if (countV > 0) {
79
            String msg = "Unused velocity " + trackerId + ": c_v: " + countV + " , a_v: " + tracker.getResultViolationAmount() + " , c_u: " + tracker.getResultUpdateCount();
80
            DebugUtil.debug(CheckUtils.getLogMessagePrefix(player, checkType) + msg);
81
        }
82
        tracker.resetResults(); // Reset for now.
83
        // TODO: A real check, e.g. track frequency and/or average amount of violation per so and so time.
84
        return false; // Player can't possibly fail this yet.
85
    }
86
87
}

How it counteracts this module

NCP's movement model queues the vertical velocity the server applies and later consumes it to explain the player's actual movement. SurvivalFly calls UnusedVelocity.checkUnusedVelocity on every move after the vertical velocity tracker's updateBlockedState, and the method reads the pos and neg UnusedTracker instances of the SimpleAxisVelocity tracker. UnusedTracker.addValue records a violation amount only when the direction has been blocked since the entry was added, meaning the server pushed velocity in a direction the player never moved. quickCheckDirection reports the violation count, the accumulated amount and the update count, then resets the results.

In this build the check is a debug ledger: quickCheckDirection logs through DebugUtil and returns false with a TODO for a real frequency or amount check, so the player cannot fail it yet. The mechanism it would enforce is the queue model: getOrUseVerticalVelocity consumes queued velocity to explain a vertical move, and a cancelled knockback leaves the queued velocity unused, which is exactly the violation the tracker accumulates. Every Rise 5.99 cancel mode (Custom at 0/0, Vulcan, Stack stationary, Minemenclub zeroing, Tick Cancel, Follow First Tick) would trip that ledger once it is enabled, because the vertical push is never consumed.

The honest statement is the debug-only status itself: a velocity module today faces NCP's SurvivalFly envelope, not this check, and unused velocity only appears in debug output until the TODO is implemented. Partial reductions leave a partial unused remainder, so the ledger would catch them too; the check as shipped cannot flag anything, which is why this entry documents the direction NCP is heading rather than an active counter.

anticheat VelocityListener (claimed velocity feed)

VelocityListener.java63 lines · Java
1
package ai.idealistic.spartan.listeners.protocol;
2
3
import ai.idealistic.spartan.Register;
4
import ai.idealistic.spartan.abstraction.event.CPlayerVelocityEvent;
5
import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6
import ai.idealistic.spartan.compatibility.necessary.protocollib.BackPlib;
7
import ai.idealistic.spartan.functionality.concurrent.CheckThread;
8
import ai.idealistic.spartan.functionality.server.Config;
9
import ai.idealistic.spartan.functionality.server.PluginBase;
10
import ai.idealistic.spartan.listeners.bukkit.VelocityEvent;
11
import com.comphenix.protocol.PacketType;
12
import com.comphenix.protocol.events.ListenerPriority;
13
import com.comphenix.protocol.events.PacketAdapter;
14
import com.comphenix.protocol.events.PacketContainer;
15
import com.comphenix.protocol.events.PacketEvent;
16
import org.bukkit.entity.Player;
17
import org.bukkit.util.Vector;
18
19
public class VelocityListener extends PacketAdapter {
20
21
22
    public VelocityListener() {
23
        super(
24
                Register.plugin,
25
                ListenerPriority.MONITOR,
26
                PacketType.Play.Server.ENTITY_VELOCITY
27
        );
28
    }
29
30
    @Override
31
    public void onPacketSending(PacketEvent event) {
32
        Player player = event.getPlayer();
33
        PlayerProtocol protocol = PluginBase.getProtocol(player);
34
35
        if (!Config.settings.getBoolean("Important.bedrock_on_protocollib")
36
                && protocol.isBedrockPlayer()) {
37
            return;
38
        }
39
        PacketContainer packet = event.getPacket();
40
41
        if (!packet.getType().equals(PacketType.Play.Server.ENTITY_VELOCITY)) {
42
            return;
43
        }
44
        if (packet.getIntegers().size() >= 4) {
45
            int id = BackPlib.getSafeInt(packet, 0);
46
47
            if (protocol.getEntityId() == id) {
48
                final double x = ((double) BackPlib.getSafeInt(packet, 1)) / 8000.0D;
49
                final double y = ((double) BackPlib.getSafeInt(packet, 2)) / 8000.0D;
50
                final double z = ((double) BackPlib.getSafeInt(packet, 3)) / 8000.0D;
51
                final boolean isCancelled = event.isCancelled();
52
53
                CheckThread.run(protocol, () -> {
54
                    // Now it's safe to use these variables asynchronously
55
                    CPlayerVelocityEvent velocityEvent = new CPlayerVelocityEvent(player, new Vector(x, y, z));
56
                    velocityEvent.setCancelled(isCancelled);
57
                    VelocityEvent.event(velocityEvent, true);
58
                });
59
            }
60
        }
61
    }
62
63
}

How it counteracts this module

Spartan's VelocityListener is a MONITOR-priority ProtocolLib adapter on ENTITY_VELOCITY. For the self entity it reads x, y and z through BackPlib.getSafeInt divided by 8000.0, builds a CPlayerVelocityEvent carrying the claimed vector, forwards the cancellation state of the original packet, and runs VelocityEvent.event on the CheckThread. VelocityEvent stores the event as claimedVelocity, pushes it onto the claimedVeloGravity and claimedVeloSpeed queues (each capped at two entries), and calls executeRunners, which dispatches the claimed velocity to Spartan's checks.

The claimed-velocity queues are the compensation layer Spartan's movement checks read: they compare the player's reported movement against the server's velocity vector, with gravity applied for the gravity queue, so a client that cancels the S12 receive-side is still measured against the vector the server sent. The listener itself does not flag; the flagging lives in the movement checks that consume claimedVelocity, which is why this file is the feed rather than the verdict. Because Spartan records the original packet contents, client-side scaling of the S12 fields (Custom and Redesky percentages) does not change what Spartan expects, so partial reduction still shows as a movement deficit.

Among Rise 5.99's modes, every mode that removes or reduces the movement the server's vector predicts (Custom, Vulcan, Tick Cancel, Minemenclub, Stack, Follow First Tick) is measured against the claimed vector. The bypass surface is the queues' size and the ground profile: the last two claims only, and modes that keep the vertical component while removing horizontal movement (Reverse) present movement closer to the claimed gravity profile and stay under the checks' tolerances. WATCHDOG_SAFE style ground-only vertical applies are the same shape on other clients.

← Back to Analysis Hub