Sigma 4.11 NoSlowdown module 2 files, 317 lines

Sigma 4.11 NoSlowdown: Full Source Analysis

Sigma 4.11's NoSlowdown keeps the player at full sprint speed while blocking with a sword, using the classic use-item release cycle: every tick, while the player is blocking, moving and grounded…

info/sigmaclient/module/impl/movement/NoSlowdown.java · GitHub source ↗

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

Analysis

Overview

Sigma 4.11's NoSlowdown keeps the player at full sprint speed while blocking with a sword, using the classic use-item release cycle: every tick, while the player is blocking, moving and grounded, the pre-phase of EventUpdate sends C07PacketPlayerDigging with RELEASE_USE_ITEM (at BlockPos.ORIGIN facing DOWN) and the post-phase immediately sends C08PacketPlayerBlockPlacement with the held item, re-arming the use state before the server can apply the slowdown. Four modes are selectable - NCP, Hypixel, AAC and Vanilla (a no-op). The NCP and Hypixel modes send the pair every tick while MoveUtils.isOnGround(0.42) and no Killaura target is present; the Hypixel variant differs by spoofing the placement position with PlayerUtil.getHypixelBlockpos(username) plus a 255 y-coordinate so the server cannot register a real block interaction; the AAC mode only releases on solid ground and throttles the re-place to every 65ms with a Timer so the burst rate stays low. The module never touches the movement packets themselves - it only manipulates the item-use state machine.

Architecture

onEvent registers EventUpdate only. The mode string is read from the MODE Options every event and mirrored into the module suffix. All three active modes share the same gate: mc.thePlayer.isBlocking(), PlayerUtil.isMoving(), and - for NCP and Hypixel - MoveUtils.isOnGround(0.42) and Killaura.blockTarget == null. The pre-phase sends the release, the post-phase sends the re-place; the two halves of the tick are used so the client's own item-use timer sees a complete release/place cycle inside one tick. The AAC mode drops the isOnGround(0.42) requirement in favor of mc.thePlayer.onGround || MoveUtils.isOnGround(0.5), and its post-phase re-place is guarded by a 65ms Timer so at most ~15 placements per second reach the server.

The use-item release cycle

Vanilla applies a 0.6x movement slowdown while a player is actively using an item (blocking, eating, drawing a bow). The release cycle avoids the state: C07 with RELEASE_USE_ITEM tells the server the use ended, and the immediate C08 placement restarts it. Because the restart lands in the same tick, the server-side use state never settles into the 'using' state that would justify the slowdown, while the client never applies the 0.6 factor to its own motion - the movement packets are unchanged and full sprint speed persists. The block position of the release is irrelevant (BlockPos.ORIGIN, DOWN) because no block is actually dug; the placement matters more, and the Hypixel mode deliberately aims it at a garbage position: getHypixelBlockpos hashes the username into a deterministic pseudo-random BlockPos (y = -val % 255, an always-invalid coordinate) and the packet constructor receives 255 as the y offset, so the server discards the placement as out of range instead of validating a block interaction.

source NoSlowdown.java (module)

NoSlowdown.java90 lines · JavaOriginal ↗
1
package info.sigmaclient.module.impl.movement;
2
3
import info.sigmaclient.event.Event;
4
import info.sigmaclient.event.impl.EventUpdate;
5
import info.sigmaclient.management.MoveUtils;
6
import info.sigmaclient.module.data.ModuleData;
7
import info.sigmaclient.module.data.Options;
8
import info.sigmaclient.module.data.Setting;
9
import info.sigmaclient.module.impl.combat.Killaura;
10
import info.sigmaclient.event.RegisterEvent;
11
import info.sigmaclient.module.Module;
12
import info.sigmaclient.util.PlayerUtil;
13
import info.sigmaclient.util.Timer;
14
import info.sigmaclient.util.misc.ChatUtil;
15
import net.minecraft.network.play.client.C03PacketPlayer;
16
import net.minecraft.network.play.client.C07PacketPlayerDigging;
17
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
18
import net.minecraft.util.BlockPos;
19
import net.minecraft.util.EnumFacing;
20
21
public class NoSlowdown extends Module {
22
23
    private String V = "VANILLA";
24
    public static String MODE = "MODE";
25
    Timer timer = new Timer();
26
    public NoSlowdown(ModuleData data) {
27
        super(data);
28
		settings.put(MODE,
29
				new Setting<>(MODE,
30
						new Options("Mode", "NCP", new String[] { "NCP", "Vanilla", "AAC", "Hypixel"}),
31
						"NoSlow method."));
32
    }
33
34
    @Override
35
    @RegisterEvent(events = {EventUpdate.class})
36
    public void onEvent(Event event) {
37
        EventUpdate em = (EventUpdate) event;
38
        this.setSuffix((((Options) settings.get(MODE).getValue()).getSelected()));
39
		switch (((Options) settings.get(MODE).getValue()).getSelected()) {
40
41
		case "NCP": {
42
			if(mc.thePlayer.isBlocking() && PlayerUtil.isMoving() && MoveUtils.isOnGround(0.42) && Killaura.blockTarget == null){
43
				double x = mc.thePlayer.posX; double y = mc.thePlayer.posY; double z = mc.thePlayer.posZ;
44
				if (em.isPre()) {					
45
					mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
46
				} else if (em.isPost()) {
47
					mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
48
					
49
				}
50
			}
51
           
52
		}
53
		break;
54
		case "Hypixel": {
55
			if(mc.thePlayer.isBlocking() && PlayerUtil.isMoving() && MoveUtils.isOnGround(0.42) && Killaura.blockTarget == null){
56
				double x = mc.thePlayer.posX; double y = mc.thePlayer.posY; double z = mc.thePlayer.posZ;
57
				if (em.isPre()) {					
58
					mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
59
				} else if (em.isPost()) {
60
					mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(PlayerUtil.getHypixelBlockpos(mc.getSession().getUsername()), 255, mc.thePlayer.inventory.getCurrentItem(), 0,0,0));
61
					
62
				}
63
			}
64
           
65
		}
66
		break;
67
		
68
		case "AAC":{
69
			if(mc.thePlayer.isBlocking() && PlayerUtil.isMoving()){
70
				if (em.isPre()) {
71
					if(mc.thePlayer.onGround || MoveUtils.isOnGround(0.5))
72
					mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
73
				} else if (em.isPost()) {
74
					if(timer.delay(65)){	
75
						mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
76
						timer.reset();
77
					}
78
				}
79
			}
80
		}
81
		break;
82
		
83
		case "Vanilla":{
84
			
85
		}
86
		break;
87
		}
88
    }
89
90
}

What this file does

The entire module is the EventUpdate handler. The gate line (isBlocking, isMoving, isOnGround(0.42), no killaura target) decides whether the cycle runs; the switch on the mode string picks the packet pair. NCP and Hypixel send C07 RELEASE_USE_ITEM in pre and C08 placement in post every tick; Hypixel swaps the placement for PlayerUtil.getHypixelBlockpos(getSession().getUsername()) with a 255 y-value; AAC gates the release on ground state and the placement on a 65ms Timer; Vanilla is an empty case. There is no onEnable/onDisable state and no timer thread - the module is stateless apart from the shared Timer used by the AAC mode.

source PlayerUtil.java (position spoof helper)

PlayerUtil.java227 lines · JavaOriginal ↗
1
package info.sigmaclient.util;
2
3
import info.sigmaclient.management.MoveUtils;
4
import info.sigmaclient.util.misc.ChatUtil;
5
import net.minecraft.block.Block;
6
import net.minecraft.block.BlockAir;
7
import net.minecraft.block.BlockLiquid;
8
import net.minecraft.client.Minecraft;
9
import net.minecraft.init.Blocks;
10
import net.minecraft.network.play.client.C03PacketPlayer;
11
import net.minecraft.util.AxisAlignedBB;
12
import net.minecraft.util.BlockPos;
13
import net.minecraft.util.MathHelper;
14
15
public class PlayerUtil implements MinecraftUtil {
16
17
    public static boolean isInLiquid() {
18
        if (mc.thePlayer == null) {
19
            return false;
20
        }
21
        for (int x = MathHelper.floor_double(mc.thePlayer.boundingBox.minX); x < MathHelper.floor_double(mc.thePlayer.boundingBox.maxX) + 1; x++) {
22
            for (int z = MathHelper.floor_double(mc.thePlayer.boundingBox.minZ); z < MathHelper.floor_double(mc.thePlayer.boundingBox.maxZ) + 1; z++) {
23
                BlockPos pos = new BlockPos(x, (int) mc.thePlayer.boundingBox.minY, z);
24
                Block block = mc.theWorld.getBlockState(pos).getBlock();
25
                if ((block != null) && (!(block instanceof BlockAir))) {
26
                    return block instanceof BlockLiquid;
27
                }
28
            }
29
        }
30
        return false;
31
    }
32
33
    public static BlockPos getHypixelBlockpos(String str){
34
    	int val = 89;
35
    	if(str != null && str.length() > 1){
36
    		char[] chs = str.toCharArray();
37
        	
38
        	int lenght = chs.length;
39
        	for(int i = 0; i < lenght; i++)
40
        		val += (int)chs[i] * str.length()* str.length() + (int)str.charAt(0) + (int)str.charAt(1);
41
        	val/=str.length();
42
    	}
43
    	return new BlockPos(val, -val%255, val);
44
    }
45
    public static boolean isOnLiquid() {
46
        AxisAlignedBB boundingBox = mc.thePlayer.getEntityBoundingBox();
47
        if (boundingBox == null) {
48
            return false;
49
        }
50
        boundingBox = boundingBox.contract(0.01D, 0.0D, 0.01D).offset(0.0D, -0.01D, 0.0D);
51
        boolean onLiquid = false;
52
        int y = (int) boundingBox.minY;
53
        for (int x = MathHelper.floor_double(boundingBox.minX); x < MathHelper
54
                .floor_double(boundingBox.maxX + 1.0D); x++) {
55
            for (int z = MathHelper.floor_double(boundingBox.minZ); z < MathHelper
56
                    .floor_double(boundingBox.maxZ + 1.0D); z++) {
57
                Block block = mc.theWorld.getBlockState((new BlockPos(x, y, z))).getBlock();
58
                if (block != Blocks.air) {
59
                    if (!(block instanceof BlockLiquid)) {
60
                        return false;
61
                    }
62
                    onLiquid = true;
63
                }
64
            }
65
        }
66
        return onLiquid;
67
    }
68
69
    public static void blinkToPos(final double[] startPos, final BlockPos endPos, final double slack, final double[] pOffset) {
70
        double curX = startPos[0];
71
        double curY = startPos[1];
72
        double curZ = startPos[2];
73
        try {
74
            final double endX = endPos.getX() + 0.5;
75
            final double endY = endPos.getY() + 1.0;
76
            final double endZ = endPos.getZ() + 0.5;
77
78
            double distance = Math.abs(curX - endX) + Math.abs(curY - endY) + Math.abs(curZ - endZ);
79
            int count = 0;
80
            while (distance > slack) {
81
                distance = Math.abs(curX - endX) + Math.abs(curY - endY) + Math.abs(curZ - endZ);
82
                if (count > 120) {
83
                    break;
84
                }
85
                final boolean next = false;
86
                final double diffX = curX - endX;
87
                final double diffY = curY - endY;
88
                final double diffZ = curZ - endZ;
89
                final double offset = ((count & 0x1) == 0x0) ? pOffset[0] : pOffset[1];
90
                if (diffX < 0.0) {
91
                    if (Math.abs(diffX) > offset) {
92
                        curX += offset;
93
                    } else {
94
                        curX += Math.abs(diffX);
95
                    }
96
                }
97
                if (diffX > 0.0) {
98
                    if (Math.abs(diffX) > offset) {
99
                        curX -= offset;
100
                    } else {
101
                        curX -= Math.abs(diffX);
102
                    }
103
                }
104
                if (diffY < 0.0) {
105
                    if (Math.abs(diffY) > 0.25) {
106
                        curY += 0.25;
107
                    } else {
108
                        curY += Math.abs(diffY);
109
                    }
110
                }
111
                if (diffY > 0.0) {
112
                    if (Math.abs(diffY) > 0.25) {
113
                        curY -= 0.25;
114
                    } else {
115
                        curY -= Math.abs(diffY);
116
                    }
117
                }
118
                if (diffZ < 0.0) {
119
                    if (Math.abs(diffZ) > offset) {
120
                        curZ += offset;
121
                    } else {
122
                        curZ += Math.abs(diffZ);
123
                    }
124
                }
125
                if (diffZ > 0.0) {
126
                    if (Math.abs(diffZ) > offset) {
127
                        curZ -= offset;
128
                    } else {
129
                        curZ -= Math.abs(diffZ);
130
                    }
131
                }
132
                Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(curX, curY, curZ, true));
133
                ++count;
134
            }
135
        } catch (Exception e) {
136
137
        }
138
    }
139
    public static void hypixelTeleport(final double[] startPos, final BlockPos endPos){
140
141
    	double distx = startPos[0] - endPos.getX()+ 0.5;
142
    	double disty = startPos[1] - endPos.getY();
143
    	double distz = startPos[2] - endPos.getZ()+ 0.5;
144
    	double dist = Math.sqrt(mc.thePlayer.getDistanceSq(endPos));
145
    	double distanceEntreLesPackets = 0.31 + MoveUtils.getSpeedEffect()/20;
146
    	double xtp, ytp, ztp = 0;
147
    	if(dist> distanceEntreLesPackets){
148
    		
149
    		double nbPackets = Math.round(dist / distanceEntreLesPackets + 0.49999999999) - 1;
150
    	
151
    		xtp = mc.thePlayer.posX;
152
    		ytp = mc.thePlayer.posY;
153
    		ztp = mc.thePlayer.posZ;		
154
    		double count = 0;
155
    		for (int i = 1; i < nbPackets;i++){		
156
    			double xdi = (endPos.getX() - mc.thePlayer.posX)/( nbPackets);	
157
    			 xtp += xdi;
158
    			 
159
    			double zdi = (endPos.getZ() - mc.thePlayer.posZ)/( nbPackets);	
160
    			 ztp += zdi;
161
    			 
162
    			double ydi = (endPos.getY() - mc.thePlayer.posY)/( nbPackets);	
163
    			ytp += ydi;
164
    			   count ++;
165
    			   
166
    			   if(!mc.theWorld.getBlockState(new BlockPos(xtp, ytp-1, ztp)).getBlock().isSolidFullCube()){  
167
    			   if (count <= 2) {
168
                      ytp += 2E-8;
169
                   } else if (count >= 4) {
170
                       count = 0;
171
                   }
172
    			   }
173
    				C03PacketPlayer.C04PacketPlayerPosition Packet= new C03PacketPlayer.C04PacketPlayerPosition(xtp, ytp, ztp, false);
174
    				mc.thePlayer.sendQueue.addToSendQueue(Packet);
175
    		}
176
    	
177
    			mc.thePlayer.setPosition(endPos.getX() + 0.5, endPos.getY(), endPos.getZ() + 0.5);
178
    		
179
    	}else{
180
    			mc.thePlayer.setPosition(endPos.getX(), endPos.getY(), endPos.getZ());
181
    		
182
    		}
183
    }
184
    public static void teleport(final double[] startPos, final BlockPos endPos){
185
    	double distx = startPos[0] - endPos.getX()+ 0.5;
186
    	double disty = startPos[1] - endPos.getY();
187
    	double distz = startPos[2] - endPos.getZ()+ 0.5;
188
    	double dist = Math.sqrt(mc.thePlayer.getDistanceSq(endPos));
189
    	double distanceEntreLesPackets = 5;
190
    	double xtp, ytp, ztp = 0;
191
    	
192
    	if(dist> distanceEntreLesPackets){
193
    		double nbPackets = Math.round(dist / distanceEntreLesPackets + 0.49999999999) - 1;
194
    		xtp = mc.thePlayer.posX;
195
    		ytp = mc.thePlayer.posY;
196
    		ztp = mc.thePlayer.posZ;		
197
    		double count = 0;
198
    		for (int i = 1; i < nbPackets;i++){		
199
    			double xdi = (endPos.getX() - mc.thePlayer.posX)/( nbPackets);	
200
    			xtp += xdi;
201
    			 
202
    			double zdi = (endPos.getZ() - mc.thePlayer.posZ)/( nbPackets);	
203
    			ztp += zdi;
204
    			 
205
    			double ydi = (endPos.getY() - mc.thePlayer.posY)/( nbPackets);	
206
    			ytp += ydi;
207
    			count ++;
208
    			C03PacketPlayer.C04PacketPlayerPosition Packet= new C03PacketPlayer.C04PacketPlayerPosition(xtp, ytp, ztp, true);
209
    			
210
    			mc.thePlayer.sendQueue.addToSendQueue(Packet);
211
    		}
212
    		
213
    		mc.thePlayer.setPosition(endPos.getX() + 0.5, endPos.getY(), endPos.getZ() + 0.5);
214
    	}else{
215
    		mc.thePlayer.setPosition(endPos.getX(), endPos.getY(), endPos.getZ());
216
    	}
217
    }
218
    public static boolean isMoving() {
219
        if ((!mc.thePlayer.isCollidedHorizontally) && (!mc.thePlayer.isSneaking())) {
220
            return ((mc.thePlayer.movementInput.moveForward != 0.0F || mc.thePlayer.movementInput.moveStrafe != 0.0F));
221
        }
222
        return false;
223
    }
224
    public static boolean isMoving2() {
225
    	 return ((mc.thePlayer.moveForward != 0.0F || mc.thePlayer.moveStrafing != 0.0F));
226
    }
227
}

What this file does

PlayerUtil supplies the two helpers the module reads. isMoving() returns whether any movement key is pressed, the gate that keeps the cycle from firing while standing still. getHypixelBlockpos(String) hashes the username: it sums the character values, folds in the string length, the first two characters, and divides by the length, then builds a BlockPos(val, -val % 255, val) - a position that for any real username lands outside the loaded world, and the negative y-offset modulo 255 makes the height invalid too. Combined with the literal 255 passed as the placement y, the Hypixel mode's C08 can never be validated as a real block placement, which is what keeps the release/place cycle from leaving block-place side effects on the server.

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 NoSlow (required item-slow in prediction)

NoSlow.java58 lines · Java
1
package ac.grim.grimac.checks.impl.movement;
2
3
import ac.grim.grimac.api.config.ConfigManager;
4
import ac.grim.grimac.checks.Check;
5
import ac.grim.grimac.checks.CheckData;
6
import ac.grim.grimac.checks.type.PostPredictionListener;
7
import ac.grim.grimac.player.GrimPlayer;
8
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
9
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
10
import org.jetbrains.annotations.NotNull;
11
12
@CheckData(name = "NoSlow", stableKey = "grim.movement.noslow", description = "Was not slowed while using an item", setback = 5)
13
public class NoSlow extends Check implements PostPredictionListener {
14
    // The player sends that they switched items the next tick if they switch from an item that can be used
15
    // to another item that can be used.  What the fuck Mojang.  Affects 1.8 (and most likely 1.7) clients.
16
    public boolean didSlotChangeLastTick = false;
17
    public boolean flaggedLastTick = false;
18
    private double offsetToFlag;
19
    private double bestOffset = 1;
20
21
    public NoSlow(GrimPlayer player) {
22
        super(player);
23
    }
24
25
    @Override
26
    public void onPredictionComplete(final PredictionComplete predictionComplete) {
27
        if (!predictionComplete.isChecked()) return;
28
29
        // If the player was using an item for certain, and their predicted velocity had a flipped item
30
        if (player.packetStateData.isSlowedByUsingItem()) {
31
            // 1.8 users are not slowed the first tick they use an item, strangely
32
            if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8) && didSlotChangeLastTick) {
33
                didSlotChangeLastTick = false;
34
                flaggedLastTick = false;
35
            }
36
37
            if (bestOffset > offsetToFlag) {
38
                if (flaggedLastTick) {
39
                    flagWithSetback();
40
                }
41
                flaggedLastTick = true;
42
            } else {
43
                reward();
44
                flaggedLastTick = false;
45
            }
46
        }
47
        bestOffset = 1;
48
    }
49
50
    public void handlePredictionAnalysis(double offset) {
51
        bestOffset = Math.min(bestOffset, offset);
52
    }
53
54
    @Override
55
    public void onReload(@NotNull ConfigManager config) {
56
        offsetToFlag = config.getDoubleElse(getConfigName() + ".threshold", 0.001);
57
    }
58
}

How it counteracts this module

Grim's NoSlow is a PostPredictionListener: when packetStateData.isSlowedByUsingItem() is true, the prediction engine must have included the item-use slowdown in the player's possible trajectories. The check takes the best prediction offset (the smallest difference between predicted and actual move, fed in via handlePredictionAnalysis) and, once bestOffset exceeds offsetToFlag (threshold config, default 0.001), flags with a set-back after a one-tick confirmation to cut false positives. A 1.8-specific exemption skips the first tick after a slot change, because 1.8 clients are not slowed on the tick they start using an item.

The module is a direct hit: it sends the release/place pair every tick, so Grim's packet state marks the player as slowed by using an item, but the client's actual moves are at full sprint speed - the prediction set contains only slowed trajectories, the actual move matches none of them, and the offset exceeds 0.001 for as long as the cycle runs. The slot-change exemption does not apply (no slot change), and the one-tick confirmation delay only delays the flag. The release-item half of the cycle is exactly what keeps isSlowedByUsingItem true, so Grim sees a player who is simultaneously 'using an item' and moving at un-slowed speed - the contradiction the check exists for.

anticheat FastPlace (placement rate)

FastPlace.java103 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.blockplace;
16
17
import org.bukkit.block.Block;
18
import org.bukkit.entity.Player;
19
20
import fr.neatmonster.nocheatplus.checks.Check;
21
import fr.neatmonster.nocheatplus.checks.CheckType;
22
import fr.neatmonster.nocheatplus.players.IPlayerData;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * A check used to verify if the player isn't placing blocks too quickly.
27
 */
28
public class FastPlace extends Check {
29
30
    /**
31
     * Instantiates a new fast place check.
32
     */
33
    public FastPlace() {
34
        super(CheckType.BLOCKPLACE_FASTPLACE);
35
    }
36
37
    /**
38
     * Checks a player.
39
     * 
40
     * @param player
41
     *            the player
42
     * @param block
43
     *            the block
44
     * @param tick
45
     * @param data
46
     * @param cc
47
     * @param pData
48
     * @return true, if successful
49
     */
50
    public boolean check(final Player player, final Block block, final int tick, final BlockPlaceData data, 
51
                         final BlockPlaceConfig cc, final IPlayerData pData) {
52
53
        data.fastPlaceBuckets.add(System.currentTimeMillis(), 1f);
54
        final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
55
        // Full period frequency.
56
        final float fullScore = data.fastPlaceBuckets.score(1f);
57
58
        // Short term limit.
59
        if (tick < data.fastPlaceShortTermTick) {
60
            // TickTask got reset.
61
            data.fastPlaceShortTermTick = tick;
62
            data.fastPlaceShortTermCount = 1;
63
        }
64
        else if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks) {
65
            // Account for server side lag.
66
            if (!lag || TickTask.getLag(50L * (tick - data.fastPlaceShortTermTick), true) < 1.2f) {
67
                // Within range, add.
68
                data.fastPlaceShortTermCount ++;
69
            }
70
            else {
71
                // Too much lag, reset.
72
                data.fastPlaceShortTermTick = tick;
73
                data.fastPlaceShortTermCount = 1;
74
            }
75
        }
76
        else { 
77
            data.fastPlaceShortTermTick = tick;
78
            data.fastPlaceShortTermCount = 1;
79
        }
80
81
        // Find out if one of both are violations:
82
        final float fullViolation;
83
        if (fullScore > cc.fastPlaceLimit) {
84
            // Account for server side lag.
85
            fullViolation = lag ? fullScore / TickTask.getLag(data.fastPlaceBuckets.bucketDuration() * data.fastPlaceBuckets.numberOfBuckets(), true) - cc.fastPlaceLimit
86
                                : fullScore - cc.fastPlaceLimit;
87
        }
88
        else fullViolation = 0;
89
        final float shortTermViolation = data.fastPlaceShortTermCount - cc.fastPlaceShortTermLimit; 
90
        final float violation = Math.max(fullViolation, shortTermViolation);
91
        boolean cancel = false;
92
93
        if (violation > 0.0) {
94
            final double change = (double) violation;
95
            data.fastPlaceVL += change;
96
            cancel = executeActions(player, data.fastPlaceVL, change, cc.fastPlaceActions).willCancel();
97
        }
98
        else if (data.fastPlaceVL > 0D && fullScore < cc.fastPlaceLimit * .75) {
99
            data.fastPlaceVL *= 0.95;
100
        }
101
        return cancel;
102
    }
103
}

How it counteracts this module

NCP's FastPlace counts every block-placement event into data.fastPlaceBuckets (an ActionFrequency bucket queue, 1f per placement) and combines two limits: a full-window score against cc.fastPlaceLimit, and a short-term counter that counts placements within cc.fastPlaceShortTermTicks of each other against cc.fastPlaceShortTermLimit. Lag is folded in via TickTask so server lag does not inflate the counts. A violation adds to fastPlaceVL and executes the configured actions, which include cancellation of the placement.

The NCP and Hypixel modes feed this check one C08 per tick - roughly 20 placements per second sustained while blocking and moving - because every re-place in the cycle is processed as a block-placement event. The full-window score stays above the limit for the whole duration and the short-term counter trips the moment two placements land within the short-term window. The AAC mode's 65ms throttle is built to dodge exactly this: at ~15/s it stays under the short-term limit and only accumulates slowly against the full window, which is the honest bypass surface of this check. The Hypixel position spoof does not help, because FastPlace counts the events, not the validity of the position.

anticheat Speed (item-use discrepancy)

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 computes two expectations for every move: expected uses maxForce (which includes the item-use slowdown factor) and expectedNoItemUse uses maxForceNoItemUse (without it). If the player is blocking, consuming an item or pulling a bow and the no-item-use expectation fits the actual speed better, the check concludes the player is moving at normal speed while using an item - and grants exactly one extra tick for the known slot-switch quirk before falling back to the slowed expectation. When the accumulated positive discrepancy crosses DISCREPANCY_THRESHOLD it punishes with a rubber-band, and there is an escalation path: once the player's VL exceeds RELEASE_ITEM_OVER_VL while blocking/consuming/pulling, Hawk calls pp.releaseItem() to force the client out of the use state.

The module's per-tick release/place cycle is caught by the discrepancy branch: Hawk sees isBlocking true (its packet state tracks the sword block) and the actual move speed matching expectedNoItemUse, so after the one granted quirk tick the discrepancy accumulates against the slowed expectation every tick and crosses the threshold. The releaseItem() escalation is the direct countermeasure - it ends the use state server-side regardless of what the client re-sends, collapsing the cycle.

← Back to Analysis Hub