Rise 5.99 NoSlow module 2 files, 203 lines

Rise 5.99 NoSlow: Full Source Analysis

Rise 5.99's NoSlow is a six-mode slowdown bypass dispatched from the PreMotion/PostMotion pair.

dev/rise/module/impl/movement/NoSlow.java · GitHub source ↗

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

Analysis

Overview

Rise 5.99's NoSlow is a six-mode slowdown bypass dispatched from the PreMotion/PostMotion pair. The NCP mode releases the item with C07 RELEASE_USE_ITEM pre-motion and re-arms with a use-item C08 post-motion; Reverse NCP swaps the order (C08 then C07); Hypixel only forces the use-key input state so the server sees continuous use with no release at all; Delay alternates one C08 and one C07 on a 5-tick cadence to stay under release-rate detectors; Intave emits C07 releases on an alternating 200ms/100ms timer. The default 'Vanilla' mode has no branch and does nothing, and the slowdown NumberSetting (0-80) is declared but never read. The actual input-slowing removal happens in the client's runtime movement code, which is not part of this source snapshot; the module file itself manages only the wire state.

Architecture

onPreMotion holds the release side and onPostMotion the re-arm side (or the reverse for Reverse NCP), so each mode emits its packets from a different point in the motion pipeline. All sends go through PacketUtil.sendPacket, which routes into addToSendQueue (PacketUtil line 12) and therefore through Rise's own packet event bus; sendPacketWithoutEvent (line 15) is the alternate path the module does not use. onPacketReceive is an empty stub, onEnable resets ticks and blocking, and there is no onDisable cleanup, so the alternating Delay state survives a toggle-off. The state machines are the aBoolean flag (Delay) and the TimeUtil timer (Intave), both reset in onEnable.

Mode mechanics

NCP mode, per tick while blocking: syncCurrentPlayItem plus C07 RELEASE_USE_ITEM with facing DOWN pre-motion (lines 61-64), then syncCurrentPlayItem plus C08 item-placement post-motion (lines 118-121). Reverse NCP inverts the pair: C08 pre (lines 95-98), C07 post (lines 137-140). Delay gates on ticksExisted % 5: on tick % 5 == 1 with aBoolean false it sends the C08 and sets aBoolean true (lines 85-90); on tick % 5 == 0 with aBoolean true it sends the C07 and clears the flag (lines 78-83), so one release and one re-arm arrive per 5-tick cycle, roughly 200ms between releases. Intave sends C07 in both pre and post handlers when the timer has reached delay, then alternates the next delay between 200ms and 100ms (lines 104-107, 146-156), doubling the release rate inside the 100ms windows.

Timing profile

The per-tick modes (NCP, Reverse NCP) stream releases at 20/s, 50ms apart; the Delay mode spaces releases by 5 ticks (~200ms); Intave by 100-200ms. That spread is the design: fast modes trade release-gap detection against continuous slowdown removal, slow modes keep the slowdown off for most of each cycle while staying under gap thresholds, and Hypixel sends no dig packets at all, so its fingerprint is the held-use-input behavior and the missing release. The unused slowdown slider and the empty packet-receive stub show the module was trimmed: the visible handler surface is entirely packet orchestration, with the speed effect delegated to the runtime movement hook.

source NoSlow.java (module logic)

NoSlow.java160 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.movement;
7
8
import dev.rise.Rise;
9
import dev.rise.event.impl.motion.PostMotionEvent;
10
import dev.rise.event.impl.motion.PreMotionEvent;
11
import dev.rise.event.impl.packet.PacketReceiveEvent;
12
import dev.rise.module.Module;
13
import dev.rise.module.api.ModuleInfo;
14
import dev.rise.module.enums.Category;
15
import dev.rise.module.impl.combat.Aura;
16
import dev.rise.setting.impl.ModeSetting;
17
import dev.rise.setting.impl.NumberSetting;
18
import dev.rise.util.math.TimeUtil;
19
import dev.rise.util.player.PacketUtil;
20
import net.minecraft.network.Packet;
21
import net.minecraft.network.play.client.C03PacketPlayer;
22
import net.minecraft.network.play.client.C07PacketPlayerDigging;
23
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
24
import net.minecraft.util.BlockPos;
25
import net.minecraft.util.EnumFacing;
26
import org.lwjgl.input.Mouse;
27
28
/**
29
 * Makes you automatically sprint without pressing the sprint key.
30
 * <p>
31
 * Wtf is this description
32
 */
33
@ModuleInfo(name = "NoSlow", description = "Prevents you from slowing down when using items", category = Category.MOVEMENT)
34
public final class NoSlow extends Module {
35
36
    private final ModeSetting mode = new ModeSetting("Mode", this, "Vanilla", "Vanilla", "NCP", "Reverse NCP", "Hypixel", "Delay", "Intave");
37
    public final NumberSetting slowdown = new NumberSetting("Slowdown", this, 0, 0, 80, 1);
38
39
    //EntityPlayerSP 783
40
41
    private boolean aBoolean, blocking, intaveFunnyBoolean;
42
    private final TimeUtil timer = new TimeUtil();
43
    private long delay;
44
    private int ticks;
45
46
    @Override
47
    protected void onEnable() {
48
        ticks = 0;
49
        blocking = false;
50
    }
51
52
    @Override
53
    public void onPacketReceive(final PacketReceiveEvent event) {
54
        final Packet<?> p = event.getPacket();
55
    }
56
57
    @Override
58
    public void onPreMotion(final PreMotionEvent event) {
59
        switch (mode.getMode()) {
60
            case "NCP": {
61
                if (mc.thePlayer.isBlocking()) {
62
                    mc.playerController.syncCurrentPlayItem();
63
                    PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
64
                }
65
                break;
66
            }
67
68
            case "Hypixel": {
69
                if (mc.thePlayer.isBlocking()) {
70
                    mc.gameSettings.keyBindUseItem.setKeyPressed(true);
71
                }
72
                break;
73
            }
74
75
            case "Delay": {
76
                if (!mc.thePlayer.isBlocking()) aBoolean = false;
77
78
                if (mc.thePlayer.isBlocking() && mc.thePlayer.ticksExisted % 5 == 0 && aBoolean) {
79
                    mc.playerController.syncCurrentPlayItem();
80
                    PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
81
82
                    aBoolean = false;
83
                }
84
85
                if (mc.thePlayer.isBlocking() && mc.thePlayer.ticksExisted % 5 == 1 && !aBoolean) {
86
                    mc.playerController.syncCurrentPlayItem();
87
                    PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getCurrentEquippedItem()));
88
89
                    aBoolean = true;
90
                }
91
                break;
92
            }
93
94
            case "Reverse NCP": {
95
                if (mc.thePlayer.isBlocking()) {
96
                    mc.playerController.syncCurrentPlayItem();
97
                    PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getCurrentEquippedItem()));
98
                }
99
100
                break;
101
            }
102
103
            case "Intave":
104
                if (mc.thePlayer.isBlocking() && timer.hasReached(delay)) {
105
                    mc.playerController.syncCurrentPlayItem();
106
                    PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
107
                }
108
                break;
109
        }
110
111
    }
112
113
    @Override
114
    public void onPostMotion(final PostMotionEvent event) {
115
116
        switch (mode.getMode()) {
117
            case "NCP": {
118
                if (mc.thePlayer.isBlocking()) {
119
                    mc.playerController.syncCurrentPlayItem();
120
                    PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getCurrentEquippedItem()));
121
                }
122
                break;
123
            }
124
125
//            case "Hypixel": {
126
//                if (mc.thePlayer.isBlocking()) {
127
//                    mc.playerController.syncCurrentPlayItem();
128
//                    PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getCurrentEquippedItem()));
129
//                    PacketUtil.sendPacket(new C03PacketPlayer(mc.thePlayer.onGround));
130
//                    PacketUtil.sendPacket(new C03PacketPlayer(mc.thePlayer.onGround));
131
//                    PacketUtil.sendPacket(new C03PacketPlayer(mc.thePlayer.onGround));
132
//                }
133
//                break;
134
//            }
135
136
            case "Reverse NCP": {
137
                if (mc.thePlayer.isBlocking()) {
138
                    mc.playerController.syncCurrentPlayItem();
139
                    PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
140
                }
141
142
                break;
143
            }
144
145
            case "Intave":
146
                if (mc.thePlayer.isBlocking() && timer.hasReached(delay)) {
147
                    mc.playerController.syncCurrentPlayItem();
148
                    PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
149
                    delay = 200;
150
                    if (intaveFunnyBoolean) {
151
                        delay = 100;
152
                        intaveFunnyBoolean = false;
153
                    } else
154
                        intaveFunnyBoolean = true;
155
                    timer.reset();
156
                }
157
                break;
158
        }
159
    }
160
}

What this file does

All six modes and their packet sequences: the ModeSetting list (line 36), the unused slowdown NumberSetting (line 37), the empty onPacketReceive stub (lines 52-55), the onPreMotion switch (lines 58-109) and the onPostMotion switch (lines 114-158). The Delay mode's aBoolean toggling (lines 76-90) and the Intave mode's TimeUtil with alternating 200/100ms delay (lines 104-107, 145-156) are the only state machines; onEnable (lines 47-50) resets ticks and blocking but there is no onDisable.

source PacketUtil.java (send path)

PacketUtil.java43 lines · JavaOriginal ↗
1
package dev.rise.util.player;
2
3
import lombok.experimental.UtilityClass;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.network.Packet;
6
7
@UtilityClass
8
public final class PacketUtil {
9
    private final Minecraft mc = Minecraft.getMinecraft();
10
11
    public void sendPacket(final Packet<?> packet) {
12
        mc.getNetHandler().addToSendQueue(packet);
13
    }
14
15
    public void sendPacketWithoutEvent(final Packet<?> packet) {
16
        mc.getNetHandler().addToSendQueueWithoutEvent(packet);
17
    }
18
19
    public void receivePacket(final Packet<?> packet) {
20
        mc.getNetHandler().addToReceiveQueue(packet);
21
    }
22
23
    public void receivePacketWithoutEvent(final Packet<?> packet) {
24
        mc.getNetHandler().addToReceiveQueueWithoutEvent(packet);
25
    }
26
    public class TimedPacket {
27
        private final Packet<?> packet;
28
        private final long time;
29
30
        public TimedPacket(final Packet<?> packet, final long time) {
31
            this.packet = packet;
32
            this.time = time;
33
        }
34
35
        public Packet<?> getPacket() {
36
            return packet;
37
        }
38
39
        public long getTime() {
40
            return time;
41
        }
42
    }
43
}

What this file does

sendPacket calls mc.getNetHandler().addToSendQueue(packet) (line 12), which places the C07 or C08 at the tail of the outgoing stream and fires Rise's packet-send events; sendPacketWithoutEvent (line 15) would bypass those events but the module never uses it. The queued order within one motion cycle (release then re-arm for NCP mode, reversed for Reverse NCP) is exactly what the server processes, and it is what the release-gap counters measure.

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 UseItemAdapter release-gap detection

UseItemAdapter.java438 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.net.protocollib;
16
17
import java.util.Arrays;
18
import java.util.LinkedList;
19
import java.util.List;
20
21
import org.bukkit.GameMode;
22
import org.bukkit.Material;
23
import org.bukkit.entity.HumanEntity;
24
import org.bukkit.entity.Player;
25
import org.bukkit.event.Event;
26
import org.bukkit.event.EventHandler;
27
import org.bukkit.event.EventPriority;
28
import org.bukkit.event.block.Action;
29
import org.bukkit.event.entity.PlayerDeathEvent;
30
import org.bukkit.event.inventory.InventoryOpenEvent;
31
import org.bukkit.event.player.PlayerInteractEvent;
32
import org.bukkit.event.player.PlayerItemConsumeEvent;
33
import org.bukkit.event.player.PlayerItemHeldEvent;
34
import org.bukkit.event.player.PlayerRespawnEvent;
35
import org.bukkit.event.player.PlayerRiptideEvent;
36
import org.bukkit.inventory.EquipmentSlot;
37
import org.bukkit.inventory.ItemStack;
38
import org.bukkit.inventory.meta.CrossbowMeta;
39
import org.bukkit.plugin.Plugin;
40
41
import com.comphenix.protocol.PacketType;
42
import com.comphenix.protocol.events.ListenerPriority;
43
import com.comphenix.protocol.events.PacketContainer;
44
import com.comphenix.protocol.events.PacketEvent;
45
import com.comphenix.protocol.reflect.StructureModifier;
46
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
47
48
import fr.neatmonster.nocheatplus.NCPAPIProvider;
49
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
50
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
51
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
52
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
53
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
54
import fr.neatmonster.nocheatplus.compat.bukkit.BridgeEnchant;
55
import fr.neatmonster.nocheatplus.compat.bukkit.BridgeMaterial;
56
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
57
import fr.neatmonster.nocheatplus.compat.versions.ClientVersion;
58
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
59
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
60
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder.RegisterMethodWithOrder;
61
import fr.neatmonster.nocheatplus.event.mini.MiniListener;
62
import fr.neatmonster.nocheatplus.logging.StaticLog;
63
import fr.neatmonster.nocheatplus.players.DataManager;
64
import fr.neatmonster.nocheatplus.players.IPlayerData;
65
import fr.neatmonster.nocheatplus.utilities.entity.InventoryUtil;
66
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
67
import fr.neatmonster.nocheatplus.utilities.map.MaterialUtil;
68
69
/**
70
 * <p>Adapter for listening to packets and Bukkit events relevant to item use.</p>
71
 *
72
 * On versions 1.17 and above, the adapter will only register events related to a specific item-use exploit, 
73
 * as Bukkit provides the {@link HumanEntity#getItemInUse()} method.<br>
74
 *
75
 * <p>On versions 1.12 and above, up to 1.17, all listeners will be registered because Bukkit does not offer a way to 
76
 * determine <em>which</em> item is in use; we can only detect if a player is using an item through {@link HumanEntity#isHandRaised()}.</p>
77
 *
78
 * The {@link PlayerRespawnEvent} is always listened to in order to fix a specific item desynchronization issue.
79
 */
80
public class UseItemAdapter extends BaseAdapter {
81
    
82
    private final static String dftag = "system.nocheatplus.useitemadapter";
83
        
84
    // All relevant Bukkit events for item-use.
85
    private final static MiniListener<?>[] miniListeners = new MiniListener<?>[] {
86
        new MiniListener<PlayerItemConsumeEvent>() {
87
            @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
88
            @RegisterMethodWithOrder(tag = dftag)
89
            @Override
90
            public void onEvent(final PlayerItemConsumeEvent event) {
91
                onItemConsume(event);
92
            }
93
        },
94
        new MiniListener<PlayerInteractEvent>() {
95
            @EventHandler(priority = EventPriority.MONITOR)
96
            @RegisterMethodWithOrder(tag = dftag)
97
            @Override
98
            public void onEvent(final PlayerInteractEvent event) {
99
                onItemInteract(event);
100
            }
101
        },
102
        new MiniListener<InventoryOpenEvent>() {
103
            @EventHandler(priority = EventPriority.LOWEST)
104
            @RegisterMethodWithOrder(tag = dftag)
105
            @Override
106
            public void onEvent(final InventoryOpenEvent event) {
107
                onInventoryOpen(event);
108
            }
109
        },
110
        new MiniListener<PlayerDeathEvent>() {
111
            @EventHandler(priority = EventPriority.MONITOR)
112
            @RegisterMethodWithOrder(tag = dftag)
113
            @Override
114
            public void onEvent(final PlayerDeathEvent event) {
115
                onDeath(event);
116
            }
117
        },
118
        new MiniListener<PlayerItemHeldEvent>() {
119
            @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
120
            @RegisterMethodWithOrder(tag = dftag)
121
            @Override
122
            public void onEvent(final PlayerItemHeldEvent event) {
123
                onChangeSlot(event);
124
            }
125
        },
126
    };
127
128
    private static int timeBetweenRL = 70;
129
130
    private static PacketType[] initPacketTypes() {
131
        // Only interested in these two packets.
132
        final List<PacketType> types = new LinkedList<PacketType>(Arrays.asList(PacketType.Play.Client.BLOCK_DIG, PacketType.Play.Client.BLOCK_PLACE));
133
        return types.toArray(new PacketType[types.size()]);
134
    }
135
136
    public UseItemAdapter(Plugin plugin) {
137
        super(plugin, ListenerPriority.MONITOR, initPacketTypes());
138
        final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
139
        if (!BridgeMisc.hasGetItemInUseMethod()) {
140
            // getItemInUse() isn't there, register all events
141
            if (Bridge1_13.hasPlayerRiptideEvent()) {
142
                // Only register this one if available.
143
                final MiniListener<?> riptideListener = new MiniListener<PlayerRiptideEvent>() {
144
                    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
145
                    @RegisterMethodWithOrder(tag = dftag)
146
                    @Override
147
                    public void onEvent(final PlayerRiptideEvent event) {
148
                        onTridentRelease(event);
149
                   }
150
                };
151
                api.addComponent(riptideListener, false);
152
            }
153
            // ...All the other listeners
154
            for (final MiniListener<?> listener : miniListeners) {
155
                api.addComponent(listener, false);
156
            }
157
        }
158
        // Always register this event, because it is used to fix an MC/Bukkit glitch, not for item-use setting.
159
        final MiniListener<?> respawningListener = new MiniListener<PlayerRespawnEvent>() {
160
            @EventHandler(priority = EventPriority.MONITOR)
161
            @RegisterMethodWithOrder(tag = dftag)
162
            @Override
163
            public void onEvent(final PlayerRespawnEvent event) {
164
                onRespawning(event);
165
            }
166
        };
167
        api.addComponent(respawningListener, false);
168
    }
169
170
    @Override
171
    public void onPacketReceiving(final PacketEvent event) {
172
        // Fast return tests first.
173
        try {
174
            if (event.isPlayerTemporary()) return;
175
        } 
176
        catch (NoSuchMethodError e) {
177
            if (event.getPlayer() == null) {
178
                counters.add(ProtocolLibComponent.idNullPlayer, 1);
179
                return;
180
            }
181
            if (DataManager.getPlayerDataSafe(event.getPlayer()) == null) {
182
                StaticLog.logWarning("Failed to fetch player data with " + event.getPacketType() + " for: " + event.getPlayer().toString());
183
                return;
184
            }
185
        }
186
        if (BridgeMisc.hasGetItemInUseMethod()) {
187
            // getItemInUse() is already there. Only check the digging packet for exploitation prevention purposes.
188
            if (event.getPacketType().equals(PacketType.Play.Client.BLOCK_DIG)) {
189
                handleDiggingPacket(event);
190
            }
191
            // Don't need to do anything else.
192
            return;
193
        }
194
        
195
        // getItemInUse() ins't there: do the ordinary stuff.
196
        if (event.getPacketType().equals(PacketType.Play.Client.BLOCK_DIG)) {
197
            handleDiggingPacket(event);
198
        }
199
        else handleBlockPlacePacket(event);
200
    }
201
    
202
    /** Attempt to fix server-side-only blocking after respawn. */
203
    private static void onRespawning(final PlayerRespawnEvent e) {
204
        final IPlayerData pData = DataManager.getPlayerData(e.getPlayer());
205
        // Patch up issues on Bukkit's (Minecraft's ?) side (item has been reset already on death).
206
        if (Bridge1_9.hasGetItemInOffHand() && e.getPlayer().isBlocking()) {
207
            pData.requestItemUseResync();
208
        }
209
    }
210
211
    private static void onTridentRelease(final PlayerRiptideEvent e) {
212
        final IPlayerData pData = DataManager.getPlayerData(e.getPlayer());
213
        // This event is called on releasing the trident (See ItemTrident.java), so the item is not in use anymore.
214
        pData.setItemInUse(null);
215
    }
216
217
    private static void onItemConsume(final PlayerItemConsumeEvent e) {
218
        final Player p = e.getPlayer();
219
        final IPlayerData pData = DataManager.getPlayerData(p);
220
        // Consume(d) (!!), so the player isn't using the item anymore
221
        pData.setItemInUse(null);   
222
    }
223
224
    private static void onInventoryOpen(final InventoryOpenEvent e) {
225
        if (e.isCancelled()) return;
226
        final Player p = (Player) e.getPlayer();
227
        final IPlayerData pData = DataManager.getPlayerData(p);
228
        // Can't use item with an inventory open.
229
        pData.setItemInUse(null);
230
    }
231
232
    private static void onDeath(final PlayerDeathEvent e) {
233
        final IPlayerData pData = DataManager.getPlayerData((Player) e.getEntity());
234
        // Can't use item if dead
235
        pData.setItemInUse(null);  
236
    }
237
238
    @SuppressWarnings("deprecation")
239
	private static void onItemInteract(final PlayerInteractEvent e) {
240
        if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) {
241
            return;
242
        }
243
        final Player p = e.getPlayer();
244
        final IPlayerData pData = DataManager.getPlayerData(p);
245
        final MovingConfig mCC = pData.getGenericInstance(MovingConfig.class);
246
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
247
        data.offHandUse = false;
248
        if (!data.mightUseItem) {
249
            // Player did not send the block-placement packet, so they are for sure not using anything, return.
250
            return;
251
        }
252
        // Do reset the flag at the start (!)
253
        data.mightUseItem = false;
254
255
        if (e.useItemInHand().equals(Event.Result.DENY)) {
256
            // A plugin denied the item-use.
257
            return;
258
        }
259
260
        if (p.getGameMode() == GameMode.CREATIVE) {
261
            // TODO: If merging SurvivalFly and CreativeFly, creative mode needs to be taken into consideration as well.
262
            pData.setItemInUse(null);
263
            return;
264
        }
265
        
266
        // Proceed to check...
267
        if (e.hasItem()) {
268
            final ItemStack item = e.getItem();
269
            final Material m = item.getType();
270
            if (Bridge1_9.hasElytra() && p.hasCooldown(m)) {
271
                // Item is in cooldown so it cannot be used.
272
                return;
273
            }
274
            
275
            // Edible / consumable items...
276
            if (InventoryUtil.isConsumable(item)) {
277
                if (!Bridge1_9.hasElytra() && item.getDurability() > 16384) {
278
                    // pre1.9 splash potion edge case.
279
                    return;
280
                }
281
                if (m == Material.POTION || m == Material.MILK_BUCKET || m.toString().endsWith("_APPLE") || m.name().startsWith("HONEY_BOTTLE")) {
282
                    // Can be consumed regardless of hunger level
283
                    pData.setItemInUse(m);
284
                    data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
285
                    return;
286
                }
287
                if (item.getType().isEdible() && p.getFoodLevel() < 20) {
288
                    // Hunger level dependant consumables.
289
                    pData.setItemInUse(m); 
290
                    data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
291
                    return;
292
                }
293
            }
294
            // Bows...
295
            if (m == Material.BOW && InventoryUtil.hasArrow(p.getInventory(), false)) {
296
                pData.setItemInUse(m);
297
                data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
298
                return;
299
            }
300
            // Shields and swords (legacy)... Bukkit takes care here, but set anyway.
301
            if (ServerVersion.isAtLeast("1.9") && pData.getClientVersion().isAtLeast(ClientVersion.V_1_9)) {
302
                // Both server and client are on a version that support shield (thus, sword-blocking is not possible)
303
            	if (m == Material.SHIELD) {
304
            	    pData.setItemInUse(m);
305
                    data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
306
                    return;
307
            	}
308
            }
309
            else if (MaterialUtil.isSword(m) && (ServerVersion.isLowerThan("1.9") || pData.getClientVersion().isAtMost(ClientVersion.V_1_8))) {
310
            	// Legacy server. Or legacy client on a modern server. Blocking is done with swords in both cases.
311
            	pData.setItemInUse(m);
312
            	// (Off hand doesn't exist)
313
            	return;
314
            }
315
            
316
            // Crosswbows...
317
            if (m.toString().equals("CROSSBOW")) {
318
                if (!((CrossbowMeta) item.getItemMeta()).hasChargedProjectiles() && InventoryUtil.hasArrow(p.getInventory(), true)) {
319
                    pData.setItemInUse(m);
320
                    data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
321
                }
322
            }
323
            // Tridents (1.13)... 
324
            if (m == BridgeMaterial.TRIDENT && item.getDurability() < m.getMaxDurability() - 1 && pData.getClientVersion().isAtLeast(ClientVersion.V_1_13)
325
            	&& (
326
                    // 1: If the trident has riptide enchant, it can only be used in rain or water 
327
            		BridgeEnchant.getRiptideLevel(p) > 0.0
328
                    && (
329
                        // 2: In water
330
                        BlockProperties.isInWater(p, p.getLocation(), mCC.yOnGround)
331
                        // 2: Always check raining first, since canSeeSky is a much more expensive call. Needs optimization.
332
                        || p.getLocation().getWorld().hasStorm() && BlockProperties.canSeeSky(p, p.getLocation(), mCC.yOnGround) 
333
                    ) 
334
                    // 1: Otherwise, the trident can be used and thrown anywhere
335
                    || BridgeEnchant.getRiptideLevel(p) <= 0.0
336
                )) {
337
                pData.setItemInUse(m);
338
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
339
                return;
340
            }
341
            // Spyglass (1.17)...
342
            if (BridgeMisc.hasIsFrozen() && m == Material.SPYGLASS) {
343
                pData.setItemInUse(m);
344
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
345
                return;
346
            }
347
            // Lastly, goat horns (1.19)...
348
            if (m.toString().equals("GOAT_HORN")) {
349
                pData.setItemInUse(m);
350
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
351
                return;
352
            }
353
            // 1.21.11: Spears...
354
            if (MaterialUtil.isSpear(m)) {
355
                pData.setItemInUse(m);
356
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
357
            }
358
        } 
359
        else {
360
            // No item in hands, no deal.
361
            pData.setItemInUse(null);  
362
        }
363
    }
364
    
365
    // NOTE: Bukkit takes care of invalid slot values (< 0 or > 8. PlayerConnection.java), so we don't need to check for this as well.
366
    private static void onChangeSlot(final PlayerItemHeldEvent e) {
367
        final Player p = e.getPlayer();
368
        final IPlayerData pData = DataManager.getPlayerData(p);
369
        // Switching a slot, so the item use status is reset.
370
        final MovingData mData = pData.getGenericInstance(MovingData.class);
371
        final CombinedData cData = pData.getGenericInstance(CombinedData.class);
372
        if (e.getPreviousSlot() != e.getNewSlot()) {
373
            /*if ((pData.getItemInUse() != null || p.isBlocking()) && mData.playerMoves.getCurrentMove() != null) {
374
                p.getInventory().setHeldItemSlot(e.getPreviousSlot());
375
                cData.invalidItemUse = true;
376
            }*/
377
            // To avoid any more potential bypasses, let Minecraft forcibly release the item.
378
            pData.requestItemUseResync();
379
        }
380
    }
381
382
    private void handleBlockPlacePacket(PacketEvent event) {
383
        final Player p = event.getPlayer();
384
        final IPlayerData pData = DataManager.getPlayerData(p);
385
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
386
        final PacketContainer packet = event.getPacket();
387
        final StructureModifier<Integer> ints = packet.getIntegers();
388
        // Legacy: pre 1.9
389
        if (ints.size() > 0 && !ServerVersion.isAtLeast("1.9")) {
390
            final int faceIndex = ints.read(0); // arg 3 if 1.7.10 below
391
            if (faceIndex <= 5) {
392
                data.mightUseItem = false;
393
                return;
394
            }
395
        }
396
        // Player sends a block-placement item when right-clicking, so they might be actually using an item. Set the flag.
397
        if (!event.isCancelled()) data.mightUseItem = true;
398
    }
399
400
    private void handleDiggingPacket(PacketEvent event) {
401
        Player p = event.getPlayer();       
402
        final IPlayerData pData = DataManager.getPlayerDataSafe(p);
403
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
404
        PlayerDigType digtype = event.getPacket().getPlayerDigTypes().read(0);
405
        if (!BridgeMisc.hasGetItemInUseMethod()) {
406
            // DROP_ALL_ITEMS when dead?
407
            if (digtype == PlayerDigType.DROP_ALL_ITEMS || digtype == PlayerDigType.DROP_ITEM) {
408
                pData.setItemInUse(null);
409
            }
410
        }
411
        
412
        if (digtype == PlayerDigType.RELEASE_USE_ITEM) {
413
            pData.setItemInUse(null);
414
            long now = System.currentTimeMillis();
415
            if (data.releaseItemTime != 0) {
416
                if (now < data.releaseItemTime) {
417
                    data.releaseItemTime = now;
418
                    return;
419
                }
420
                if (data.releaseItemTime + timeBetweenRL > now) {
421
                    data.isHackingRI = true;
422
                }
423
            }
424
            data.releaseItemTime = now;
425
        }
426
    }
427
428
    /**
429
     * Set Minimum time between RELEASE_USE_ITEM packet is sent.
430
     * If time lower this value, A check will flag
431
     * Should be set from 51-100. Larger number, more protection more false-positive
432
     * 
433
     * @param time milliseconds
434
     */ 
435
    public static void setuseRLThreshold(int time) {
436
        timeBetweenRL = time;
437
    }   
438
}

How it counteracts this module

NCP's UseItemAdapter timestamps every C07 RELEASE_USE_ITEM and sets CombinedData.isHackingRI when a release arrives less than timeBetweenRL (default 70ms, line 128) after the previous one (lines 412-425); SurvivalFly then tags the move 'noslowpacket' and runs Improbable.check on the horizontal distance (lines 877-883). The per-tick NCP and Reverse NCP modes emit releases 50ms apart and trip the gap on every release after the first, so the full-speed blocking sprint is scored against NCP's statistical model. The Delay mode (releases ~200ms apart) and Intave (100-200ms) stay above the 70ms threshold and evade the gap detector; their slower cycles are exactly the design trade that keeps them under this check, at the cost of the slowdown returning between re-arms.

anticheat NoSlow (blocking while sprinting)

NoSlowCheck.java51 lines · Java
1
package better.anticheat.core.check.broken;
2
3
import better.anticheat.core.BetterAnticheat;
4
import better.anticheat.core.check.Check;
5
import better.anticheat.core.check.CheckInfo;
6
import better.anticheat.core.player.Player;
7
import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent;
8
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
9
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;
10
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
11
12
@CheckInfo(name = "NoSlow", category = "combat")
13
public class NoSlowCheck extends Check {
14
    private boolean blocking = false, sprinting = false;
15
16
    public NoSlowCheck(BetterAnticheat plugin, Player player) {
17
        super(plugin, player);
18
    }
19
20
    @Override
21
    public void handleReceivePlayPacket(PacketPlayReceiveEvent event) {
22
23
        /*
24
         * This check is intended to detect starting sprinting while using an item (like blocking a shield, shooting a
25
         * bow, or eating food). However, this check has unexplainable falses.
26
         */
27
28
        switch (event.getPacketType()) {
29
            case USE_ITEM:
30
                blocking = true;
31
                sprinting = false;
32
                break;
33
            case ENTITY_ACTION:
34
                WrapperPlayClientEntityAction actionWrapper = new WrapperPlayClientEntityAction(event);
35
                if (actionWrapper.getAction().equals(WrapperPlayClientEntityAction.Action.START_SPRINTING)) {
36
                    sprinting = true;
37
                }
38
                break;
39
            case PLAYER_DIGGING:
40
                WrapperPlayClientPlayerDigging diggingWrapper = new WrapperPlayClientPlayerDigging(event);
41
                if (diggingWrapper.getAction() != DiggingAction.RELEASE_USE_ITEM) return;
42
43
                // Only flag on use item release as previously we don't know if the player is actually blocking.
44
45
                if (blocking && sprinting) fail();
46
                blocking = false;
47
48
                break;
49
        }
50
    }
51
}

How it counteracts this module

BetterAnticheat's NoSlowCheck fails when a RELEASE_USE_ITEM arrives while both blocking (USE_ITEM seen) and sprinting (START_SPRINTING seen) are recorded (lines 39-47), resetting blocking after each release. Every mode that keeps sprint active while the block is armed and then releases (NCP, Reverse NCP, Delay, Intave) matches that state at the moment of the release; the Hypixel mode, which never releases, is the one pattern it cannot see. The check is marked broken in the shipped tree with documented false positives, so its enforcement depends on the server, but when enabled the module's own release stream is the trigger.

anticheat Speed (release-item-over-VL force release)

Speed.java280 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.Hawk;
22
import me.islandscout.hawk.HawkPlayer;
23
import me.islandscout.hawk.check.MovementCheck;
24
import me.islandscout.hawk.event.Event;
25
import me.islandscout.hawk.event.HawkEventListener;
26
import me.islandscout.hawk.event.ItemSwitchEvent;
27
import me.islandscout.hawk.event.MoveEvent;
28
import me.islandscout.hawk.util.*;
29
import me.islandscout.hawk.wrap.entity.WrappedEntity;
30
import org.bukkit.ChatColor;
31
import org.bukkit.Material;
32
import org.bukkit.enchantments.Enchantment;
33
import org.bukkit.entity.Player;
34
import org.bukkit.event.Listener;
35
import org.bukkit.util.Vector;
36
37
import java.util.*;
38
39
public class Speed extends MovementCheck implements Listener {
40
41
    //I legit hate this game's movement.
42
    //Do you realize how much easier it would be if
43
    //the server handled movement?
44
45
    //TODO False flag with pistons
46
47
    //Basically, this check is doing, "if your previous speed was X then your current speed must not exceed f(X)"
48
49
    private static final double EPSILON = 0.000001;
50
    //Now what we can do is predict how far a player could have travelled
51
    //if the move doesn't have a deltaPos due to insignificance.
52
    private static final double MAX_NO_MOVE_DISTANCE = 0.03;
53
    private final double DISCREPANCY_THRESHOLD;
54
    private final double VL_FAIL_DISCREPANCY_FACTOR;
55
    private final boolean RESET_DISCREPANCY_ON_FAIL;
56
    private final int RELEASE_ITEM_OVER_VL;
57
    private final boolean CHECK_FLYING;
58
    private final boolean DEBUG;
59
60
    private final Map<UUID, Double> prevSpeed;
61
    private final Map<UUID, Double> discrepancies;
62
    private final Map<UUID, Integer> noMovesMap;
63
    private final Map<UUID, Double> lastNegativeDiscrepancies;
64
    private final Map<UUID, Double> negativeDiscrepanciesCumulative;
65
    private final Map<UUID, Integer> slotSwitchQuirkTicksMap; //I hate this game.
66
    private final Map<UUID, Long> lastSlotSwitchTickMap;
67
68
    public Speed() {
69
        super("speed", true, 0, 5, 0.99, 5000, "%player% failed movement speed, VL: %vl%", null);
70
        prevSpeed = new HashMap<>();
71
        discrepancies = new HashMap<>();
72
        noMovesMap = new HashMap<>();
73
        lastNegativeDiscrepancies = new HashMap<>();
74
        negativeDiscrepanciesCumulative = new HashMap<>();
75
        slotSwitchQuirkTicksMap = new HashMap<>();
76
        lastSlotSwitchTickMap = new HashMap<>();
77
        DISCREPANCY_THRESHOLD = (double) customSetting("discrepancyThreshold", "", 0.1D);
78
        VL_FAIL_DISCREPANCY_FACTOR = (double) customSetting("vlFailDiscrepancyFactor", "", 10D);
79
        RESET_DISCREPANCY_ON_FAIL = (boolean) customSetting("resetDiscrepancyOnFail", "", true);
80
        RELEASE_ITEM_OVER_VL = (int) customSetting("releaseItemOverVl", "", 4);
81
        CHECK_FLYING = (boolean) customSetting("checkFlying", "", true);
82
        DEBUG = (boolean) customSetting("debug", "", false);
83
    }
84
85
    @Override
86
    protected void check(MoveEvent event) {
87
        Player p = event.getPlayer();
88
        HawkPlayer pp = event.getHawkPlayer();
89
90
        int noMoves = noMovesMap.getOrDefault(p.getUniqueId(), 0);
91
        double lastSpeed;
92
        double speed;
93
        if(event.isUpdatePos()) {
94
            lastSpeed = prevSpeed.getOrDefault(p.getUniqueId(), 0D);
95
            if(noMoves > 0) {
96
                //Players don't update position unless they've moved at least 0.03 blocks (or if 20 ticks passed)
97
                lastSpeed = Math.min(lastSpeed, MAX_NO_MOVE_DISTANCE);
98
            }
99
            speed = MathPlus.distance2d(event.getTo().getX() - event.getFrom().getX(), event.getTo().getZ() - event.getFrom().getZ());
100
        }
101
        else {
102
            speed = prevSpeed.getOrDefault(p.getUniqueId(), 0D) - (lastNegativeDiscrepancies.getOrDefault(p.getUniqueId(), 0D) + EPSILON);
103
            lastSpeed = speed;
104
        }
105
106
        if(event.isUpdatePos())
107
            noMoves = 0;
108
        else
109
            noMoves++;
110
111
        boolean flying = pp.isFlying();
112
        boolean swimming = pp.isInWater(); //this needs improvement
113
        //it is possible that the player has pressed the jump key even if this move is "stepped" (only while sprinting)
114
        boolean jump = event.isJump() || (event.isStep() && pp.isOnGround() && pp.isSprinting());
115
116
        float friction = event.getFriction();
117
        float maxForce = event.getMaxExpectedInputForce();
118
        float maxForceNoItemUse = event.getMaxExpectedInputForceNoItemUse();
119
120
        //It represents the previous location. Block collision is done after moving the entity.
121
        Set<Material> touchedBlocks = WrappedEntity.getWrappedEntity(p).getCollisionBox(event.getFrom().toVector()).getMaterials(pp.getWorld());
122
123
        //handle any pending knockbacks
124
        if(event.hasAcceptedKnockback() || (flying && !CHECK_FLYING)) {
125
            prepareNextMove(pp, noMoves, speed, touchedBlocks);
126
            return;
127
        }
128
129
        double lastSpeedCompare = lastSpeed;
130
        //Handle other things in the game that multiply velocity.
131
        //These affect velocity first (coincidentally, these are all multiplication operations)
132
        double handleMultipliers = 1;
133
        if(event.hasHitSlowdown())
134
            handleMultipliers *= 0.6;
135
        if(touchedBlocks.contains(Material.SOUL_SAND) && !flying)
136
            handleMultipliers *= 0.4;
137
        if(touchedBlocks.contains(Material.WEB) && !flying)
138
            handleMultipliers *= 0.25;
139
        if(Hawk.getServerVersion() > 7 && touchedBlocks.contains(Material.SLIME_BLOCK)) {
140
            //TODO I believe webs affect this mot Y too.
141
            if (Math.abs(pp.getVelocity().getY()) < 0.1 && !pp.isSneaking()) {
142
                handleMultipliers *= 0.4 + Math.abs(pp.getVelocity().getY()) * 0.2;
143
            }
144
        }
145
        //Handle other things in the game that add to velocity.
146
        //These affect velocity later (coincidentally, these are all addition operations)
147
        double handleAdders = 0;
148
        if(pp.isSprinting() && jump) {
149
            handleAdders += 0.2;
150
        }
151
        if(swimming && !flying) { //This is actually a terrible way of handling horizontal water flow.
152
            Vector move = new Vector(event.getTo().getX() - event.getFrom().getX(), 0, event.getTo().getZ() - event.getFrom().getZ());
153
            Vector waterForce = event.getWaterFlowForce().clone().setY(0);
154
            double waterForceLength = waterForce.length() + 0.003; //add epsilon to allow room for error
155
            double moveLength = move.length();
156
            double computedForce = moveLength == 0 ? waterForceLength : (move.dot(waterForce) / moveLength);
157
158
            handleAdders += computedForce;
159
        }
160
161
        //Finally, the expected speed calculation. There's another "expected" because of a dumb quirk when switching slots while using an item.
162
        //Optimize later.
163
        double expected = friction * lastSpeedCompare * handleMultipliers + (maxForce + handleAdders + EPSILON);
164
        double expectedNoItemUse = friction * lastSpeedCompare * handleMultipliers + (maxForceNoItemUse + handleAdders + EPSILON);
165
166
        //I hate this game. Handle slot switching quirk. The slot switch packet is delayed by a tick.
167
        //This sort of "event listening" must be done because Hawk's MoveEvents can be skipped under certain conditions.
168
        long slotSwitchTick = pp.getLastSlotSwitchTick();
169
        boolean switchedSlot = slotSwitchTick != lastSlotSwitchTickMap.getOrDefault(p.getUniqueId(), slotSwitchTick);
170
        int slotSwitchQuirkTicks = slotSwitchQuirkTicksMap.getOrDefault(p.getUniqueId(), 0);
171
        if(switchedSlot) {
172
            slotSwitchQuirkTicks = 0;
173
        }
174
        lastSlotSwitchTickMap.put(p.getUniqueId(), slotSwitchTick);
175
176
        //Calculate discrepancy.
177
        Discrepancy discrepancy; //This is the one that will be used for final comparison. It is the value of either discrepancyBase or discrepancyNoItemUse.
178
        Discrepancy discrepancyBase; //Used for pretty much 99.99% of moves.
179
        Discrepancy discrepancyNoItemUse; //Similar to discrepancyBase, but doesn't consider item-use slowdown.
180
181
        discrepancyBase = new Discrepancy(expected, speed);
182
        discrepancyNoItemUse = new Discrepancy(expectedNoItemUse, speed);
183
        if((pp.isBlocking() || pp.isConsumingItem() || pp.isPullingBow()) && Math.abs(discrepancyNoItemUse.value) < Math.abs(discrepancyBase.value)) {
184
            //This means that they're using an item, but they're moving at normal speed. This COULD be due to that
185
            //dumb item switch quirk, so we'll grant them only one extra tick. It resets when they switch their slot.
186
            if(slotSwitchQuirkTicks < 1) {
187
                //Allow them to move at normal speed for 1 tick.
188
                discrepancy = discrepancyNoItemUse;
189
                slotSwitchQuirkTicks++;
190
            } else {
191
                discrepancy = discrepancyBase;
192
            }
193
        } else {
194
            discrepancy = discrepancyBase;
195
        }
196
197
        //Client told server that it updated its position. Checking time.
198
        if (event.isUpdatePos()) {
199
            double haltDistanceExpected = negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D);
200
            lastNegativeDiscrepancies.put(p.getUniqueId(), 0D);
201
            if(discrepancy.value < 0 || speed > haltDistanceExpected)
202
                discrepancies.put(p.getUniqueId(), Math.max(discrepancies.getOrDefault(p.getUniqueId(), 0D) + discrepancy.value, 0));
203
            double totalDiscrepancy = discrepancies.getOrDefault(p.getUniqueId(), 0D);
204
205
            if(DEBUG) {
206
                p.sendMessage((totalDiscrepancy > DISCREPANCY_THRESHOLD ? ChatColor.RED : ChatColor.GREEN) + "" + totalDiscrepancy);
207
            }
208
209
            if(discrepancy.value > 0 && totalDiscrepancy > DISCREPANCY_THRESHOLD && !event.isPossiblePistonPush()) {
210
                punishAndTryRubberband(pp, discrepancy.value * VL_FAIL_DISCREPANCY_FACTOR, event);
211
                if(RESET_DISCREPANCY_ON_FAIL)
212
                    discrepancies.put(p.getUniqueId(), 0D);
213
                if(RELEASE_ITEM_OVER_VL > -1 && (pp.isPullingBow() || pp.isConsumingItem() || pp.isBlocking()) && pp.getVL(this) > RELEASE_ITEM_OVER_VL)
214
                    pp.releaseItem();
215
            }
216
            else {
217
                reward(pp);
218
            }
219
220
            lastNegativeDiscrepancies.put(p.getUniqueId(), 0D);
221
            negativeDiscrepanciesCumulative.put(p.getUniqueId(), 0D);
222
        }
223
        //Client sent a flying packet, but didn't update position.
224
        //The move might have not been significant enough, so we need
225
        //to prepare for when the client decides it's time to update
226
        //position.
227
        else {
228
            lastNegativeDiscrepancies.put(p.getUniqueId(), discrepancy.value);
229
230
            //TODO improve these two lines...
231
            double val = negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D);
232
            negativeDiscrepanciesCumulative.put(p.getUniqueId(), Math.min(val + speed, MAX_NO_MOVE_DISTANCE + speed));
233
            //negativeDiscrepanciesCumulative.put(p.getUniqueId(), negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D) + speed);
234
        }
235
236
        slotSwitchQuirkTicksMap.put(p.getUniqueId(), slotSwitchQuirkTicks);
237
        prepareNextMove(pp, noMoves, speed, touchedBlocks);
238
    }
239
240
    private void prepareNextMove(HawkPlayer pp, int noMoves, double currentSpeed, Set<Material> touchedBlocks) {
241
        if(touchedBlocks.contains(Material.WEB) && !pp.isFlying()) {
242
            currentSpeed = 0;
243
        }
244
        UUID uuid = pp.getUuid();
245
        prevSpeed.put(uuid, currentSpeed);
246
        noMovesMap.put(uuid, noMoves);
247
    }
248
249
    public void removeData(Player p) {
250
        UUID uuid = p.getUniqueId();
251
        prevSpeed.remove(uuid);
252
        discrepancies.remove(uuid);
253
        noMovesMap.remove(uuid);
254
        lastNegativeDiscrepancies.remove(uuid);
255
        negativeDiscrepanciesCumulative.remove(uuid);
256
        slotSwitchQuirkTicksMap.remove(uuid);
257
        lastSlotSwitchTickMap.remove(uuid);
258
    }
259
260
    //speed potions do not affect swimming
261
    private Discrepancy waterMapping(double lastSpeed, double currentSpeed, double waterFlowForce) {
262
        double expected = 0.800001 * lastSpeed + 0.020001 + waterFlowForce;
263
        return new Discrepancy(expected, currentSpeed);
264
    }
265
266
    private Discrepancy lavaMapping(double lastSpeed, double currentSpeed) {
267
        double expected = 0.500001 * lastSpeed + 0.020001;
268
        return new Discrepancy(expected, currentSpeed);
269
    }
270
271
    private class Discrepancy {
272
273
        double value;
274
275
        Discrepancy(double expectedSpeed, double currentSpeed) {
276
            value = currentSpeed - expectedSpeed;
277
        }
278
279
    }
280
}

How it counteracts this module

Hawk's Speed check compares predicted against actual horizontal position each update, punishes past its discrepancy threshold, and with releaseItemOverVl (default 4, line 80) forces the item to release (lines 213-214) when a flagged player is pulling a bow, consuming or blocking. The module's effect in every mode is sprint-speed movement while blocking, so the blocked sprint accumulates speed VL; once the VL passes 4, Hawk emits a genuine release, tearing down the module's re-arm loop and leaving the server-side use state desynced. The forced release is independent of the release-gap counters because it keys on movement speed rather than dig-packet timing.

anticheat RepeatedRelease (release without a use)

RepeatedReleaseCheck.java57 lines · Java
1
package better.anticheat.core.check.broken;
2
3
import better.anticheat.core.BetterAnticheat;
4
import better.anticheat.core.check.Check;
5
import better.anticheat.core.check.CheckInfo;
6
import better.anticheat.core.player.Player;
7
import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent;
8
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
9
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
10
11
/*
12
 * NOTE: This check is currenlty not enabled due to false flag issues.
13
 * Use Item mechanics may have changed since this was originally designed?
14
 */
15
@CheckInfo(name = "RepeatedRelease", category = "dig")
16
public class RepeatedReleaseCheck extends Check {
17
    private boolean useItem = true;
18
19
    public RepeatedReleaseCheck(BetterAnticheat plugin, Player player) {
20
        super(plugin, player);
21
    }
22
23
    @Override
24
    public void handleReceivePlayPacket(PacketPlayReceiveEvent event) {
25
26
        /*
27
         * For some reason you can send multiple releases? Needs debugging.
28
         */
29
30
        switch (event.getPacketType()) {
31
            //Keep track of whether the player sent an initial use item packet.
32
            case USE_ITEM:
33
                useItem = true;
34
35
                break;
36
            case PLAYER_DIGGING:
37
                WrapperPlayClientPlayerDigging wrapper = new WrapperPlayClientPlayerDigging(event);
38
39
                /*
40
                 * In 1.9 and above using an item works as the following:
41
                 * First, the client initiates it by sending a use item packet.
42
                 * Second, the client releases it by sending a block dig packet.
43
                 *
44
                 * This means that between all release use item digs there must be a use item.
45
                 * From my testing, it does not appear like there must be a release between uses as there are edge
46
                 * cases that make UseItem seem to de-sync.
47
                 */
48
                if (wrapper.getAction() == DiggingAction.RELEASE_USE_ITEM) {
49
                    if (!useItem) fail();
50
51
                    useItem = false;
52
                }
53
54
                break;
55
        }
56
    }
57
}

How it counteracts this module

RepeatedReleaseCheck flags any RELEASE_USE_ITEM without an intervening USE_ITEM (lines 48-52). It is disabled in the shipped tree due to false flags (lines 12-14), and every mode here re-arms with a use-item C08 after its release (or before, in Reverse NCP), so the predicate never fires even when enabled. It is included as the boundary case: the check targets the per-tick release signature that NoSlow modules produce, but this client's re-arm packets satisfy its precondition, and its 1.9-oriented item model does not match 1.8 semantics.

← Back to Analysis Hub