November Recode 2.0 Velocity module 1 files, 156 lines

November Recode 2.0 Velocity: Full Source Analysis

November Recode 2.0's Velocity module is a single class with eight modes.

feature/module/impl/combat/VelocityModule.java · GitHub source ↗

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

Analysis

Overview

November Recode 2.0's Velocity module is a single class with eight modes. REDUCE and REVERSE scale the S12 vector in place with separate horizontal and vertical percentages; CANCEL drops the packet entirely; GRIM cancels the S12 and then eats the S32 confirmations and their C0F echoes so the transaction clock never confirms the knockback arrived; VULCAN cancels the S12 and the one C0F that follows; WATCHDOG_SAFE cancels the S12 but re-applies the vertical component to the player's motion while on the ground; and INTAVE and WATCHDOG are stubs that do nothing in this build. The GRIM mode is the most elaborate: it keeps a queue of cancelled transaction action numbers and matches outgoing C0F uids against it, cancelling the echoes of exactly the transactions it swallowed.

Architecture

The module registers three listeners. EventUpdate runs every tick and clears the funny flag once the transaction queue drains; EventPacket.In handles S12 and S32; EventPacket.Out handles C0F. The settings are a Mode enum plus Horizontal and Vertical floats (0.01 to 200.0, default 50.0) whose visibility lambda only shows them in REDUCE and REVERSE. State is the ConcurrentLinkedQueue of Short action numbers and the funny boolean; disable() clears both, and the null checks at the top of the receive listener reset the state whenever the world or player changes.

The enum drives the dispatch with switch expressions over the packet branches. The module is registered with the name Velocity, the description 'Reduces or cancels out taken velocity', and category Category.COMBAT through the @Register declaration. The transaction queue is a ConcurrentLinkedQueue because the receive listener and the send listener can run on different threads.

Key techniques

REDUCE and REVERSE scale in place: each motion component is multiplied by the percentage over 100.0, truncated back to int, and written with setMotionX/Y/Z, and REVERSE then negates all three. Because the packet fields are ints on the 8000 fixed-point scale, the cast truncates the fractional part of each scaled value. CANCEL, GRIM and VULCAN call setCanceled(true) on the receive event so the vanilla handler never applies the vector. WATCHDOG_SAFE cancels the S12 but, when the player is on the ground, adds motionY over 8000.0 to the player's live motionY, keeping the vertical launch while discarding the horizontal push.

GRIM sets funny on the cancelled S12; every S32 that arrives while funny is cancelled and its action number queued, and every outgoing C0F whose uid matches a queued number is cancelled, so the server's transaction accounting for that window is silently dropped. VULCAN is the simpler variant: one cancelled S12 arms funny and the very next C0F is cancelled. INTAVE and WATCHDOG carry TODO comments and no code, and the horizontal and vertical settings do not affect CANCEL, GRIM, VULCAN or WATCHDOG_SAFE.

Transaction-level bypass

The GRIM mode is aimed at anticheats that bracket velocity with transactions, notably Grim's KnockbackHandler, which sandwiches the S12 between two server transactions and treats the echo of the second as proof the knockback arrived. By cancelling the S32 receipts and the matching C0F echoes, the module prevents that promotion: the velocity stays in the uncertain, not-yet-arrived bucket and is never required by the prediction engine, so the missing knockback never produces an offset. The funny flag is cleared only when the queue drains, so the eating continues until every swallowed transaction has been accounted for.

The cost is a desynced transaction stream: every cancelled receipt and echo moves the client's transaction ledger away from the server's, which transaction-order checks and inventory and UI confirmations notice over time. The queue is deliberately cleared on disable and on world null so the desync cannot persist across sessions, and the update listener clears funny once the queue is empty. VULCAN leaves the transaction stream mostly intact, which is why it is labeled as working on older Vulcan versions only.

source VelocityModule.java (module)

VelocityModule.java156 lines · JavaOriginal ↗
1
/* November.lol © 2023 */
2
package lol.november.feature.module.impl.combat;
3
4
import java.util.Queue;
5
import java.util.concurrent.ConcurrentLinkedQueue;
6
import lol.november.feature.module.Category;
7
import lol.november.feature.module.Module;
8
import lol.november.feature.module.Register;
9
import lol.november.feature.setting.Setting;
10
import lol.november.listener.bus.Listener;
11
import lol.november.listener.bus.Subscribe;
12
import lol.november.listener.event.net.EventPacket;
13
import lol.november.listener.event.player.EventUpdate;
14
import net.minecraft.network.play.client.C0FPacketConfirmTransaction;
15
import net.minecraft.network.play.server.S12PacketEntityVelocity;
16
import net.minecraft.network.play.server.S32PacketConfirmTransaction;
17
18
/**
19
 * @author Gavin
20
 * @since 2.0.0
21
 */
22
@Register(
23
  name = "Velocity",
24
  description = "Reduces or cancels out taken velocity",
25
  category = Category.COMBAT
26
)
27
public class VelocityModule extends Module {
28
29
  private final Setting<Mode> mode = new Setting<>("Mode", Mode.CANCEL);
30
31
  private final Setting<Float> horizontal = new Setting<>(
32
    () -> mode.getValue() == Mode.REDUCE || mode.getValue() == Mode.REVERSE,
33
    "Horizontal",
34
    50.0f,
35
    0.01f,
36
    0.0f,
37
    200.0f
38
  );
39
  private final Setting<Float> vertical = new Setting<>(
40
    () -> mode.getValue() == Mode.REDUCE || mode.getValue() == Mode.REVERSE,
41
    "Vertical",
42
    50.0f,
43
    0.01f,
44
    0.0f,
45
    200.0f
46
  );
47
48
  private final Queue<Short> transactionQueue = new ConcurrentLinkedQueue<>();
49
  private boolean funny;
50
51
  @Override
52
  public void disable() {
53
    super.disable();
54
55
    funny = false;
56
    transactionQueue.clear();
57
  }
58
59
  @Subscribe
60
  private final Listener<EventUpdate> update = event -> {
61
    if (mode.getValue() == Mode.GRIM) {
62
      // finish trolling
63
      if (transactionQueue.isEmpty() && funny) funny = false;
64
    }
65
  };
66
67
  @Subscribe
68
  private final Listener<EventPacket.In> packetIn = event -> {
69
    if (mc.thePlayer == null || mc.theWorld == null) {
70
      // basic resets
71
      funny = false;
72
      if (!transactionQueue.isEmpty()) transactionQueue.clear();
73
74
      return;
75
    }
76
77
    if (event.get() instanceof S12PacketEntityVelocity packet) {
78
      if (packet.getEntityID() != mc.thePlayer.getEntityId()) return;
79
80
      switch (mode.getValue()) {
81
        case REDUCE, REVERSE -> {
82
          packet.setMotionX(
83
            (int) (packet.getMotionX() * (horizontal.getValue() / 100.0f))
84
          );
85
          packet.setMotionY(
86
            (int) (packet.getMotionY() * (vertical.getValue() / 100.0f))
87
          );
88
          packet.setMotionZ(
89
            (int) (packet.getMotionZ() * (horizontal.getValue() / 100.0f))
90
          );
91
92
          if (mode.getValue() == Mode.REVERSE) {
93
            packet.setMotionX(-packet.getMotionX());
94
            packet.setMotionY(-packet.getMotionY());
95
            packet.setMotionZ(-packet.getMotionZ());
96
          }
97
        }
98
        case CANCEL, GRIM, VULCAN -> {
99
          event.setCanceled(true);
100
          if (
101
            mode.getValue() == Mode.GRIM || mode.getValue() == Mode.VULCAN
102
          ) funny = true;
103
        }
104
        case INTAVE -> {
105
          // TODO: i have no clue
106
        }
107
        case WATCHDOG -> {
108
          // TODO: frappy or plus add this i dont have alts
109
        }
110
        case WATCHDOG_SAFE -> {
111
          event.setCanceled(true);
112
113
          if (mc.thePlayer.onGround) {
114
            // as far as im aware, this should work
115
            mc.thePlayer.motionY += (double) packet.getMotionY() / 8000.0;
116
          }
117
        }
118
      }
119
    } else if (event.get() instanceof S32PacketConfirmTransaction packet) {
120
      if (mode.getValue() == Mode.GRIM) {
121
        if (!funny) return;
122
        event.setCanceled(true);
123
        transactionQueue.add(packet.getActionNumber());
124
      }
125
    }
126
  };
127
128
  @Subscribe
129
  private final Listener<EventPacket.Out> packetOut = event -> {
130
    if (event.get() instanceof C0FPacketConfirmTransaction packet) {
131
      if (mode.getValue() == Mode.GRIM) {
132
        if (!funny || transactionQueue.isEmpty()) return;
133
134
        // if the queue contains our transaction UID, cancel
135
        if (transactionQueue.remove(packet.getUid())) event.setCanceled(true);
136
      } else if (mode.getValue() == Mode.VULCAN) {
137
        // this works on older versions of vulcan
138
        if (funny) {
139
          event.setCanceled(true);
140
          funny = false;
141
        }
142
      }
143
    }
144
  };
145
146
  private enum Mode {
147
    REDUCE,
148
    REVERSE,
149
    CANCEL,
150
    GRIM,
151
    INTAVE,
152
    VULCAN,
153
    WATCHDOG,
154
    WATCHDOG_SAFE,
155
  }
156
}

What this file does

The whole module is this one file. The receive listener branches on the packet type: S12 carries the mode dispatch (REDUCE and REVERSE scale the vector, CANCEL and GRIM and VULCAN cancel it, WATCHDOG_SAFE applies the vertical component on the ground), and S32 carries the GRIM transaction eating, which cancels the receipt and queues the action number when funny is set. The send listener matches outgoing C0F uids against the queue and cancels the echoes, and the update listener clears funny when the queue drains.

The REDUCE and REVERSE scaling is worth noting for its precision: the packet fields are ints on the 8000 fixed-point scale, so multiplying by a percentage and casting back to int truncates the fractional part of every component, which means the scaled vector can differ from the exact percentage by up to one fixed-point unit per axis. REVERSE negates all three axes after the percentage scaling, producing a full redirection of the knockback.

The mode enum, the settings, the queue and the funny flag are the entire state surface. The visibility lambda on the horizontal and vertical settings hides them in every mode except REDUCE and REVERSE, so the GUI only exposes the sliders where they matter. The INTAVE and WATCHDOG modes are honest stubs with TODO comments ('i have no clue' and 'frappy or plus add this i dont have alts'), and the module's disable() hook clears the queue and flag so the transaction eating cannot leak into the next session.

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 the exact mechanism November's GRIM mode was written against. The check sandwiches every ENTITY_VELOCITY between two server transactions: sendTransaction() before the packet and a second transaction queued through tasksAfterSend. The velocity is recorded in firstBreadMap keyed by the first transaction id, and tickKnockback promotes it into lastKnockbackKnownTaken only when a transaction with a larger id arrives, which is how Grim proves the packet reached the client. From that promotion onward the vector is required movement, and onPredictionComplete flags when the prediction offset exceeds offsetToFlag (default 0.001), with a setback once the offset reaches 0.1 or the accumulated threshold (decay 0.999, ceiling 4) hits maxAdvantage 1.

November's GRIM mode attacks the promotion itself. It cancels the S32 receipts while funny and queues their action numbers, then cancels the matching C0F echoes on the send side, so the second transaction of the sandwich never confirms and the velocity stays in the uncertain firstBreadMap bucket, never required and never flagged. The same pattern applies to the first bread: calculateFirstBreadKnockback only returns a velocity whose transaction has been confirmed, and an eaten echo leaves it unknown. This is the check's genuine blind spot, and the mode's entire design exists to exploit it.

The cost is the transaction ledger. Every cancelled receipt and echo moves the client's accounting away from the server's, and Grim's transaction tracking validates its own negative ids, so a confirmation that matches nothing or a missing echo is a stream anomaly that other checks notice. The queue is cleared on disable and on world null, which bounds the desync to the active session, and the update listener clears funny once the queue drains. A player who eats transactions forever will eventually trip the transaction-order surface even if the velocity offset never accrues.

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 pending knockback list. Each entry is a vector plus the server send time and 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, jumps, swims or steps) and X and Z to fall inside maxDiscrepancy, computed from walk speed, speed potions and the sprint multiplier plus an 0.003 epsilon. When an entry ages past ping plus 200ms without a match, failedKnockback is set outside vehicles, and AntiVelocityBasic.check punishes at 5 VL with the 'may be using anti-velocity (basic)' flag.

November's CANCEL, GRIM and VULCAN modes all leave the pending entry unmatched, so it expires and flags. REDUCE and REVERSE scale the vector client-side, but the check compares against the original entry from the server's own pending list, so a 50% reduction produces a move that fails the X and Z match whenever the gap exceeds maxDiscrepancy, and the stronger the original hit the larger the absolute gap. WATCHDOG_SAFE is the partial exception: it applies the full vertical component on the ground, so the Y match can succeed and only the horizontal plane diverges.

The class comment claims detection down to a 10% difference, which is the size of the tolerance window relative to a typical knockback. Small REDUCE percentages that keep the movement inside maxDiscrepancy pass, and the ping-plus-200ms window forgives knockback the player simply has not moved into yet. The check is content-blind and needs no prediction, only the pending list and the move deltas, which is why every cancel 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 S12 the server sent (field c divided by 8000.0, with damage-cause exclusions for starvation, fire tick, drowning, poison, wither, thorns, fall, lava and fire) against the rise the player reports. onMove only proceeds when the player rose, and flags when deltaY is positive, below the 0.42 jump height and below 77% of the recorded vertical velocity, printing the percentage and applying a 10000ms cooldown with 4 VL. The denominator comes from the server's own packet, so client-side scaling cannot change it.

REDUCE at the default 50% produces a rise around half the sent vector, ratio 0.5, which flags as Velocity Type A (50%); any vertical percentage from 1 through 76 flags, while 80% and above passes. REVERSE presents a negative rise, so the player appears to drop and the check's rise gate skips it entirely. WATCHDOG_SAFE keeps the full vertical component on the ground, so its rise matches the sent vector and passes, which is the mode's design intent: keep the vertical launch, drop only the horizontal push.

CANCEL, GRIM and VULCAN never rise, so the from.getY() >= to.getY() early return fires and nothing is flagged. The 0.42 cap is the safeguard against jumping, and the exclusions prevent false flags on fall, fire and drowning damage. Among November's modes, REDUCE at partial vertical is the only one this check reliably catches; the cancel family is its documented blind spot.

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 claims every ENTITY_VELOCITY for the self entity at MONITOR priority: it reads the three fixed-point components divided by 8000.0 through BackPlib.getSafeInt, builds a CPlayerVelocityEvent, forwards the packet's cancellation state, and dispatches it on the CheckThread through VelocityEvent.event. VelocityEvent stores the claim in claimedVelocity, pushes it onto the claimedVeloGravity and claimedVeloSpeed queues (each capped at two entries) and calls executeRunners, which feeds Spartan's movement checks.

The movement checks compare the reported movement against the claimed vector, with gravity applied on the gravity queue, so a client that cancels the S12 receive-side is still measured against the vector the server sent. The listener records the original packet contents, so REDUCE's client-side scaling does not change what Spartan expects; a 50% vertical reduction shows up as a movement deficit against the full claim. CANCEL, GRIM and VULCAN produce the same deficit from a complete absence of movement.

WATCHDOG_SAFE is the closest to a pass: it preserves the vertical component on the ground, so the gravity-profile match succeeds for the rise and only the horizontal plane diverges, which lands under the checks' tolerances for weak hits. The queues hold only the last two claims, so a long gap between hits gives the checks no baseline, and the bukkit-side twin listener keeps the two feeds consistent through the packetsEnabled flag in PlayerProtocol. The listener itself is a feed, not a verdict; the flagging lives in the movement checks that consume the claim.

← Back to Analysis Hub