Sigma 4.11 AntiVelocity module 2 files, 375 lines

Sigma 4.11 AntiVelocity: Full Source Analysis

Sigma 4.11's AntiVelocity is a three-mode anti-knockback module selected by the MODE Options setting (Basic, AACPush, AACFlag) and driven from EventPacket plus EventUpdate.

info/sigmaclient/module/impl/combat/AntiVelocity.java · GitHub source ↗

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

Analysis

Overview

Sigma 4.11's AntiVelocity is a three-mode anti-knockback module selected by the MODE Options setting (Basic, AACPush, AACFlag) and driven from EventPacket plus EventUpdate. Basic is a packet modifier: it scales the S12 vector in place by the HORIZONTAL and VERTICAL percentage settings (default 0/0) using integer fixed-point arithmetic, cancels the packet outright when both percentages are zero, and additionally cancels S27 explosion knockback while in basic mode. AACPush is a motion rewriter: it lets the S12 through untouched, stores the vector, and for the next 10 ticks while hurtResistantTime is positive rewrites the horizontal motion every tick with MoveUtils.strafe at a decaying boost (0.05 down to 0), hard-cuts to a 0.2 strafe when speed exceeds 0.35, and damps motion when no keys are held. AACFlag is a teleport exploit: it cancels the S12 and pushes a C04PacketPlayerPosition with Double.NaN as Y (onGround true) straight into the send queue, exploiting vanilla's illegal-position check (which bounds only x and z) and the fact that NaN comparisons are always false, so the server resets the player with an S08 teleport to its pre-knockback position; the module absorbs the S08 by preserving the player's yaw and pitch while hurtResistantTime is positive.

The module never touches outgoing C03 packets (an early return skips them), only intercepts the self-entity S12, and disables itself implicitly while the Fly module is in BowFly mode. onEnable resets the AACPush tick counter.

Architecture

onEvent branches on event type. EventPacket handling starts with an early return for outgoing C03 packets, so the module never interferes with the player's own movement stream - the AACFlag C04 is injected through addToSendQueue directly and is covered by that same return. The S12 branch verifies the entity id against the player and skips interception while Fly is enabled in BowFly mode, then dispatches on the mode string. An S08PacketPlayerPosLook branch preserves yaw and pitch on the teleport when AACFlag is active and the player is in hurt time. EventUpdate runs the AACPush countdown and motion rewriting while hurtResistantTime is positive.

State is minimal: the count tick counter (reset in onEnable), the stored xmot/zmot from the last S12, and the mode string. The S27 explosion branch is mode-gated to basic (case-insensitive), so explosion knockback is only cancelled in that mode.

Basic: scale or cancel

Basic reads the VERTICAL and HORIZONTAL settings and rewrites the S12 with setMotX(horizontal * x / 100), setMotY(vertical * y / 100), setMotZ(horizontal * z / 100) - integer arithmetic on the fixed-point components, so the vector is reduced by the configured percentages. When both percentages are zero the packet is cancelled instead of scaled, which is the full anti-knockback case. The S27 branch cancels explosion knockback outright whenever basic is selected, so a Basic user takes neither entity knockback nor explosion knockback.

The same event handler runs for every mode; the mode string is read once per event and also written into the module suffix via setSuffix.

AACPush and AACFlag: motion rewrite and NaN teleport

AACPush is the only mode that does not cancel the S12: the vector is stored (xmot/zmot as x/1000, z/1000, used only for the speed magnitude check) and the vanilla knockback applies. Then, for up to 10 ticks while hurtResistantTime is positive, EventUpdate computes boost = 0.05 - count/200 and calls MoveUtils.strafe(boost), which rewrites motionX/motionZ from the facing yaw based on the held keys. If the resulting horizontal speed exceeds 0.35 the module zeroes motion and strafes at 0.2, and if no movement keys are held it multiplies motion by (0.8 - boost). The result is a controlled push-out trajectory rather than the vanilla knockback decay.

AACFlag instead cancels the S12 and injects C04PacketPlayerPosition(player posX, Double.NaN, player posZ, onGround true) through addToSendQueue. Vanilla's processPlayer bounds the illegal-position check to x and z at 3.0E7 and every NaN comparison is false, so the NaN Y is neither kicked nor flagged; the corrupted server-side position makes the server teleport the player back with S08 to its pre-knockback coordinates, which cancels the knockback on the server's own initiative. The module's S08 branch preserves yaw and pitch so the reset does not disorient the user. It only fires when the S12 has a horizontal component (x != 0 && z != 0).

source AntiVelocity.java (module)

AntiVelocity.java132 lines · JavaOriginal ↗
1
package info.sigmaclient.module.impl.combat;
2
3
import tv.twitch.chat.Chat;
4
import info.sigmaclient.Client;
5
import info.sigmaclient.event.Event;
6
import info.sigmaclient.event.RegisterEvent;
7
import info.sigmaclient.event.impl.EventPacket;
8
import info.sigmaclient.event.impl.EventUpdate;
9
import info.sigmaclient.management.MoveUtils;
10
import info.sigmaclient.module.Module;
11
import info.sigmaclient.module.data.ModuleData;
12
import info.sigmaclient.module.data.Options;
13
import info.sigmaclient.module.data.Setting;
14
import info.sigmaclient.module.impl.movement.Fly;
15
import info.sigmaclient.util.MathUtils;
16
import info.sigmaclient.util.misc.ChatUtil;
17
import net.minecraft.network.Packet;
18
import net.minecraft.network.play.client.C03PacketPlayer;
19
import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
20
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
21
import net.minecraft.network.play.server.S12PacketEntityVelocity;
22
import net.minecraft.network.play.server.S27PacketExplosion;
23
import net.minecraft.util.MathHelper;
24
/*
25
 * Made by LeakedPvP
26
 */
27
public class AntiVelocity extends Module {
28
    private String VELOCITY = "MODE";
29
    public AntiVelocity(ModuleData data) {
30
        super(data);
31
        settings.put(VELOCITY, new Setting<>(VELOCITY, new Options("Mode", "Basic", new String[]{"Basic", "AACPush", "AACFlag"}), "AntiVelocity method."));
32
        settings.put(HORIZONTAL, new Setting<>(HORIZONTAL, 0, "Horizontal velocity factor.", 10, 0, 100));
33
        settings.put(VERTICAL, new Setting<>(VERTICAL, 0, "Vertical velocity factor.", 10, 0, 100));
34
    }
35
    double count = 0;
36
    public static String HORIZONTAL = "HORIZONTAL";
37
    public static String VERTICAL = "VERTICAL";
38
    double xmot, zmot, ymot = 0;
39
    @Override
40
    public void onEnable() {
41
        super.onEnable();
42
        count = 0;
43
    }
44
    @Override
45
    @RegisterEvent(events = {EventPacket.class,EventUpdate.class})
46
    public void onEvent(Event event) {
47
    	String currentMode = ((Options) settings.get(VELOCITY).getValue()).getSelected();
48
        setSuffix(currentMode);
49
    	if(event instanceof EventPacket){
50
        EventPacket ep = (EventPacket) event;
51
        Packet p = ep.getPacket();
52
        if (ep.isOutgoing()) {
53
            if (p instanceof C03PacketPlayer)
54
                return;
55
        }    
56
        if(p instanceof S08PacketPlayerPosLook){
57
        	S08PacketPlayerPosLook pac = (S08PacketPlayerPosLook) ep.getPacket();
58
        	if(currentMode.equalsIgnoreCase("AACFlag") && mc.thePlayer.hurtResistantTime > 0){
59
        		pac.yaw = mc.thePlayer.rotationYaw;
60
            	pac.pitch = mc.thePlayer.rotationPitch;
61
        	}
62
           
63
        }
64
        if (p instanceof S12PacketEntityVelocity) {
65
        	
66
            S12PacketEntityVelocity packet = (S12PacketEntityVelocity) p;
67
        	int entId = packet.getEntityID();
68
			int x = packet.getX();
69
			int y = packet.getY();
70
			int z = packet.getZ();
71
            if (entId == mc.thePlayer.getEntityId() && !(Client.getModuleManager().isEnabled(Fly.class) && ((Options)Client.getModuleManager().get(Fly.class).getSetting("MODE").getValue()).getSelected().equalsIgnoreCase("BowFly"))) {
72
            	switch(currentMode){
73
            	case"AACPush":
74
            		if(x != 0 && z != 0){
75
                		count = 10;
76
                		xmot = x/1000;
77
                		zmot = z/1000;	
78
            		}
79
            		break;
80
            	case"Basic":
81
                    int vertical = ((Number) settings.get(VERTICAL).getValue()).intValue();
82
                    int horizontal = ((Number) settings.get(HORIZONTAL).getValue()).intValue();
83
                    if (vertical != 0 || horizontal != 0) {
84
                        packet.setMotX(horizontal * packet.getX() / 100);
85
                        packet.setMotY(vertical * packet.getY() / 100);
86
                        packet.setMotZ(horizontal * packet.getZ() / 100);
87
                    } else {
88
                        ep.setCancelled(true);
89
                    }
90
            		break;
91
            	case"AACFlag":
92
            		if(x != 0 && z != 0){
93
            			C04PacketPlayerPosition pack = new C04PacketPlayerPosition(mc.thePlayer.posX, Double.NaN, mc.thePlayer.posZ, true);
94
        	   			mc.thePlayer.sendQueue.addToSendQueue(pack);
95
        	   			ep.setCancelled(true);
96
            		}
97
            		break;
98
            	}
99
            } 
100
        }
101
        if (p instanceof S27PacketExplosion && currentMode.equalsIgnoreCase("basic")) {
102
        	if(ep.isPre()){
103
                ep.setCancelled(true);
104
        	}
105
        
106
        }
107
    	}else if(event instanceof EventUpdate && mc.thePlayer.hurtResistantTime > 0 && currentMode.equalsIgnoreCase("aacpush")){
108
               
109
    		if(count > 0){
110
    			double boost = 0.05 - count/200;
111
    			count --;
112
    			if(count <=10){
113
    				double speedcheck = Math.sqrt(xmot * xmot + zmot * zmot);
114
    				
115
    				MoveUtils.strafe(boost);
116
    				double speed = Math.sqrt(mc.thePlayer.motionX * mc.thePlayer.motionX + mc.thePlayer.motionZ * mc.thePlayer.motionZ);
117
    				if(speed > 0.35){
118
    					count = 0;
119
    					mc.thePlayer.motionX *= 0;
120
    					mc.thePlayer.motionZ *= 0;
121
    					MoveUtils.strafe(0.2);
122
    				}
123
    				if(mc.thePlayer.moveForward == 0 && mc.thePlayer.moveStrafing == 0){
124
    					double value = 0.8-boost;
125
    					mc.thePlayer.motionX *= value;
126
    					mc.thePlayer.motionZ *= value;
127
    				}			
128
    			}
129
    		}
130
    	}
131
    }
132
}

What this file does

The module is one file. The EventPacket branch contains the outgoing-C03 early return, the S08 yaw/pitch preservation for AACFlag, the entity-id and Fly/BowFly gates, and the mode dispatch: Basic scales or cancels the S12 via setMotX/Y/Z and cancels S27; AACPush stores the vector and arms the countdown; AACFlag cancels the S12 and injects the NaN-Y C04 through addToSendQueue. The EventUpdate branch runs the AACPush countdown: boost decay, MoveUtils.strafe, the speed > 0.35 hard cut to a 0.2 strafe, and the stationary damping. The MODE setting is an Options with Basic/AACPush/AACFlag, and HORIZONTAL/VERTICAL default to 0 with a 0-100 range.

Notable details: the S27 cancel is gated on the mode string matching 'basic', the outgoing-C03 early return guarantees the injected C04 is never re-intercepted, and onEnable resets the count so the AACPush burst restarts cleanly on each toggle.

source MoveUtils.java (strafe helper)

MoveUtils.java243 lines · JavaOriginal ↗
1
package info.sigmaclient.management;
2
3
import javafx.geometry.BoundingBox;
4
import info.sigmaclient.module.data.Options;
5
import info.sigmaclient.module.impl.combat.InfiniteAura;
6
import info.sigmaclient.util.misc.ChatUtil;
7
import net.minecraft.block.Block;
8
import net.minecraft.block.BlockAir;
9
import net.minecraft.block.BlockLiquid;
10
import net.minecraft.block.BlockPressurePlate;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.entity.Entity;
13
import net.minecraft.entity.player.EntityPlayer;
14
import net.minecraft.network.play.client.C03PacketPlayer;
15
import net.minecraft.potion.Potion;
16
import net.minecraft.util.AxisAlignedBB;
17
import net.minecraft.util.BlockPos;
18
import net.minecraft.util.EnumFacing;
19
import net.minecraft.util.MathHelper;
20
import net.minecraft.util.Vec3;
21
22
public class MoveUtils {
23
    private static Minecraft mc = Minecraft.getMinecraft();
24
    public static double defaultSpeed() {
25
        double baseSpeed = 0.2873D;
26
        if (Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.moveSpeed)) {
27
            int amplifier = Minecraft.getMinecraft().thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier();
28
          //  if(((Options) settings.get(MODE).getValue()).getSelected().equalsIgnoreCase("Hypixel")){
29
           // 	baseSpeed *= (1.0D + 0.225D * (amplifier + 1));
30
           // }else
31
            	baseSpeed *= (1.0D + 0.2D * (amplifier + 1));
32
        }
33
        return baseSpeed;
34
    }
35
    public static void strafe(double speed) {
36
        float a = mc.thePlayer.rotationYaw * 0.017453292F;
37
        float l = mc.thePlayer.rotationYaw * 0.017453292F - (float) Math.PI * 1.5f;
38
        float r = mc.thePlayer.rotationYaw * 0.017453292F + (float) Math.PI * 1.5f;
39
        float rf = mc.thePlayer.rotationYaw * 0.017453292F + (float) Math.PI * 0.19f;
40
        float lf = mc.thePlayer.rotationYaw * 0.017453292F + (float) Math.PI * -0.19f;
41
        float lb = mc.thePlayer.rotationYaw * 0.017453292F - (float) Math.PI * 0.76f;
42
        float rb = mc.thePlayer.rotationYaw * 0.017453292F - (float) Math.PI * -0.76f;
43
        if (mc.gameSettings.keyBindForward.pressed) {
44
            if (mc.gameSettings.keyBindLeft.pressed && !mc.gameSettings.keyBindRight.pressed) {
45
                mc.thePlayer.motionX -= (double) (MathHelper.sin(lf) * speed);
46
                mc.thePlayer.motionZ += (double) (MathHelper.cos(lf) * speed);
47
            } else if (mc.gameSettings.keyBindRight.pressed && !mc.gameSettings.keyBindLeft.pressed) {
48
                mc.thePlayer.motionX -= (double) (MathHelper.sin(rf) * speed);
49
                mc.thePlayer.motionZ += (double) (MathHelper.cos(rf) * speed);
50
            } else {
51
                mc.thePlayer.motionX -= (double) (MathHelper.sin(a) * speed);
52
                mc.thePlayer.motionZ += (double) (MathHelper.cos(a) * speed);
53
            }
54
        } else if (mc.gameSettings.keyBindBack.pressed) {
55
            if (mc.gameSettings.keyBindLeft.pressed && !mc.gameSettings.keyBindRight.pressed) {
56
                mc.thePlayer.motionX -= (double) (MathHelper.sin(lb) * speed);
57
                mc.thePlayer.motionZ += (double) (MathHelper.cos(lb) * speed);
58
            } else if (mc.gameSettings.keyBindRight.pressed && !mc.gameSettings.keyBindLeft.pressed) {
59
                mc.thePlayer.motionX -= (double) (MathHelper.sin(rb) * speed);
60
                mc.thePlayer.motionZ += (double) (MathHelper.cos(rb) * speed);
61
            } else {
62
                mc.thePlayer.motionX += (double) (MathHelper.sin(a) * speed);
63
                mc.thePlayer.motionZ -= (double) (MathHelper.cos(a) * speed);
64
            }
65
        } else if (mc.gameSettings.keyBindLeft.pressed && !mc.gameSettings.keyBindRight.pressed && !mc.gameSettings.keyBindForward.pressed && !mc.gameSettings.keyBindBack.pressed) {
66
            mc.thePlayer.motionX += (double) (MathHelper.sin(l) * speed);
67
            mc.thePlayer.motionZ -= (double) (MathHelper.cos(l) * speed);
68
        } else if (mc.gameSettings.keyBindRight.pressed && !mc.gameSettings.keyBindLeft.pressed && !mc.gameSettings.keyBindForward.pressed && !mc.gameSettings.keyBindBack.pressed) {
69
            mc.thePlayer.motionX += (double) (MathHelper.sin(r) * speed);
70
            mc.thePlayer.motionZ -= (double) (MathHelper.cos(r) * speed);
71
        }
72
73
    }
74
    public static void setMotion(double speed) {
75
        double forward = mc.thePlayer.movementInput.moveForward;
76
        double strafe = mc.thePlayer.movementInput.moveStrafe;
77
        float yaw = mc.thePlayer.rotationYaw;
78
        if ((forward == 0.0D) && (strafe == 0.0D)) {
79
        	mc.thePlayer.motionX = 0;
80
        	mc.thePlayer.motionZ = 0;
81
        } else {
82
            if (forward != 0.0D) {
83
                if (strafe > 0.0D) {
84
                    yaw += (forward > 0.0D ? -45 : 45);
85
                } else if (strafe < 0.0D) {
86
                    yaw += (forward > 0.0D ? 45 : -45);
87
                }
88
                strafe = 0.0D;
89
                if (forward > 0.0D) {
90
                    forward = 1;
91
                } else if (forward < 0.0D) {
92
                    forward = -1;
93
                }
94
            }
95
            mc.thePlayer.motionX = forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)); 
96
            mc.thePlayer.motionZ = forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F));
97
        }
98
    }   
99
100
    public static boolean checkTeleport(double x, double y, double z,double distBetweenPackets){
101
    	double distx = mc.thePlayer.posX - x;
102
    	double disty = mc.thePlayer.posY - y;
103
    	double distz = mc.thePlayer.posZ - z;
104
    	double dist = Math.sqrt(mc.thePlayer.getDistanceSq(x, y, z));
105
    	double distanceEntreLesPackets = distBetweenPackets;
106
    	double nbPackets = Math.round(dist / distanceEntreLesPackets + 0.49999999999) - 1;
107
    	
108
    	double xtp = mc.thePlayer.posX;
109
    	double ytp = mc.thePlayer.posY;
110
    	double ztp = mc.thePlayer.posZ;		
111
    		for (int i = 1; i < nbPackets;i++){		
112
    			double xdi = (x - mc.thePlayer.posX)/( nbPackets);	
113
    			 xtp += xdi;
114
    			 
115
    			double zdi = (z - mc.thePlayer.posZ)/( nbPackets);	
116
    			 ztp += zdi;
117
    			 
118
    			double ydi = (y - mc.thePlayer.posY)/( nbPackets);	
119
    			ytp += ydi;			
120
    	    	AxisAlignedBB bb = new AxisAlignedBB(xtp - 0.3, ytp, ztp - 0.3, xtp + 0.3, ytp + 1.8, ztp + 0.3);
121
    	    	if(!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb).isEmpty()){
122
    	    		return false;
123
    	    	}
124
    			
125
    		}
126
    	return true;
127
    }
128
129
130
    public static boolean isOnGround(double height) {
131
        if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(0.0D, -height, 0.0D)).isEmpty()) {
132
            return true;
133
        } else {
134
            return false;
135
        }
136
    }
137
    public static int getJumpEffect() {
138
        if (mc.thePlayer.isPotionActive(Potion.jump))
139
            return mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1;
140
        else
141
            return 0;
142
    }
143
    public static int getSpeedEffect() {
144
        if (mc.thePlayer.isPotionActive(Potion.moveSpeed))
145
            return mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier() + 1;
146
        else
147
            return 0;
148
    }
149
150
    public static Block getBlockUnderPlayer(EntityPlayer inPlayer, double height) {
151
        return Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(inPlayer.posX, inPlayer.posY - height, inPlayer.posZ)).getBlock();
152
    }
153
154
    public static Block getBlockAtPosC(double x, double y, double z) {
155
        EntityPlayer inPlayer = Minecraft.getMinecraft().thePlayer;
156
        return Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(inPlayer.posX + x, inPlayer.posY + y, inPlayer.posZ + z)).getBlock();
157
    }
158
159
    public static float getDistanceToGround(Entity e) {
160
        if (mc.thePlayer.isCollidedVertically && mc.thePlayer.onGround) {
161
            return 0.0F;
162
        }
163
        for (float a = (float) e.posY; a > 0.0F; a -= 1.0F) {
164
            int[] stairs = {53, 67, 108, 109, 114, 128, 134, 135, 136, 156, 163, 164, 180};
165
            int[] exemptIds = {
166
                    6, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59,
167
                    63, 65, 66, 68, 69, 70, 72, 75, 76, 77, 83, 92, 93, 94,
168
                    104, 105, 106, 115, 119, 131, 132, 143, 147, 148, 149, 150,
169
                    157, 171, 175, 176, 177};
170
            Block block = mc.theWorld.getBlockState(new BlockPos(e.posX, a - 1.0F, e.posZ)).getBlock();
171
            if (!(block instanceof BlockAir)) {
172
                if ((Block.getIdFromBlock(block) == 44) || (Block.getIdFromBlock(block) == 126)) {
173
                    return (float) (e.posY - a - 0.5D) < 0.0F ? 0.0F : (float) (e.posY - a - 0.5D);
174
                }
175
                int[] arrayOfInt1;
176
                int j = (arrayOfInt1 = stairs).length;
177
                for (int i = 0; i < j; i++) {
178
                    int id = arrayOfInt1[i];
179
                    if (Block.getIdFromBlock(block) == id) {
180
                        return (float) (e.posY - a - 1.0D) < 0.0F ? 0.0F : (float) (e.posY - a - 1.0D);
181
                    }
182
                }
183
                j = (arrayOfInt1 = exemptIds).length;
184
                for (int i = 0; i < j; i++) {
185
                    int id = arrayOfInt1[i];
186
                    if (Block.getIdFromBlock(block) == id) {
187
                        return (float) (e.posY - a) < 0.0F ? 0.0F : (float) (e.posY - a);
188
                    }
189
                }
190
                return (float) (e.posY - a + block.getBlockBoundsMaxY() - 1.0D);
191
            }
192
        }
193
        return 0.0F;
194
    }
195
    
196
    
197
    public static float[] getRotationsBlock(BlockPos block, EnumFacing face) {
198
        double x = block.getX() + 0.5 - mc.thePlayer.posX +  (double) face.getFrontOffsetX()/2;
199
        double z = block.getZ() + 0.5 - mc.thePlayer.posZ +  (double) face.getFrontOffsetZ()/2;
200
        double y = (block.getY() + 0.5);
201
        double d1 = mc.thePlayer.posY + mc.thePlayer.getEyeHeight() - y;
202
        double d3 = MathHelper.sqrt_double(x * x + z * z);
203
        float yaw = (float) (Math.atan2(z, x) * 180.0D / Math.PI) - 90.0F;
204
        float pitch = (float) (Math.atan2(d1, d3) * 180.0D / Math.PI);
205
        if (yaw < 0.0F) {
206
            yaw += 360f;
207
        }
208
        return new float[]{yaw, pitch};
209
    }
210
    public static boolean isBlockAboveHead(){
211
    	AxisAlignedBB bb =new AxisAlignedBB(mc.thePlayer.posX - 0.3, mc.thePlayer.posY+mc.thePlayer.getEyeHeight(), mc.thePlayer.posZ + 0.3,
212
 											mc.thePlayer.posX + 0.3, mc.thePlayer.posY+2.5 ,mc.thePlayer.posZ - 0.3);
213
 	  return !mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb).isEmpty();
214
    }
215
    public static boolean isCollidedH(double dist){
216
    	AxisAlignedBB bb =new AxisAlignedBB(mc.thePlayer.posX - 0.3, mc.thePlayer.posY+2, mc.thePlayer.posZ + 0.3,
217
											mc.thePlayer.posX + 0.3, mc.thePlayer.posY+3 ,mc.thePlayer.posZ - 0.3);
218
    	if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0.3 + dist, 0, 0)).isEmpty()) {
219
    		return true;
220
    	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(-0.3 - dist, 0, 0)).isEmpty()) {
221
    		return true;
222
    	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0, 0, 0.3 + dist)).isEmpty()) {
223
    		return true;
224
    	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0, 0, -0.3 - dist)).isEmpty()) {
225
    		return true;
226
	 	}
227
    	return false;
228
    }
229
    public static boolean isRealCollidedH(double dist){
230
		AxisAlignedBB bb =new AxisAlignedBB(mc.thePlayer.posX - 0.3, mc.thePlayer.posY + 0.5, mc.thePlayer.posZ + 0.3,
231
											mc.thePlayer.posX + 0.3, mc.thePlayer.posY+1.9 ,mc.thePlayer.posZ - 0.3);
232
		if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0.3 + dist, 0, 0)).isEmpty()) {
233
		  	return true;
234
	  	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(-0.3 - dist, 0, 0)).isEmpty()) {
235
		  	return true;
236
	  	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0, 0, 0.3 + dist)).isEmpty()) {
237
		  return true;
238
	  	}else if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb.offset(0, 0, -0.3 - dist)).isEmpty()) {
239
		  	return true;
240
	  	}
241
	  return false;
242
    }
243
}

What this file does

MoveUtils.strafe(double speed) is the only external helper the AACPush mode reads. It resolves the pressed movement keys (forward/back/left/right, including diagonals) against the player's current rotationYaw and rewrites motionX and motionZ as sin/cos projections at the given speed, so the AACPush burst moves the player along their facing rather than along the knockback vector. The same class also carries defaultSpeed() and setMotion() used by Sigma's movement modules, but only strafe matters to AntiVelocity.

This is the piece that turns AACPush from 'let the knockback through' into 'replace the knockback trajectory': every hurt tick the module overwrites the horizontal motion the vanilla client derived from the S12 with a fixed-magnitude facing-relative burst, which is what the countering checks below measure as a missing or altered required vector.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat KnockbackHandler (AntiKB, required-velocity prediction)

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

How it counteracts this module

Grim's KnockbackHandler is a PacketSendListener on ENTITY_VELOCITY that wraps the packet in a transaction sandwich: sendTransaction() before the velocity and a second transaction through tasksAfterSend after it. The vector is recorded into firstBreadMap keyed by the first transaction id, and tickKnockback promotes it into lastKnockbackKnownTaken once the client echoes a larger transaction id - proof the packet reached the client. From that moment the vector is required movement: the prediction engine must see it in the player's motion. onPredictionComplete compares the prediction offset against offsetToFlag (config Knockback.threshold, default 0.001), accumulates it into a threshold with decay 0.999 up to maxAdvantage 1, and set-backs at offset >= 0.1 (immediate-setback-threshold). A knockback that arrives while Grim itself is sending a setback is recorded with isSetback and treated leniently, because the position reset would mask it anyway.

All three Sigma modes fail the requirement. Basic at 0/0 cancels the S12, but the server already sent it and the sandwich confirmed delivery, so the required vector simply never appears in the predicted motion and the offset is the full knockback. Basic at partial percentages scales the packet client-side, which cannot change the server-side record Grim read, so any nonzero reduction produces an offset above the 0.001 floor. AACPush lets the S12 through but then rewrites motionX/Z with strafe every hurt tick and hard-cuts at 0.35, so the predicted trajectory diverges from the required vector even though the packet was received. AACFlag's cancelled S12 plus NaN-Y C04 leaves the required vector un-taken; the resulting server teleport is a teleport, not knockback consumption (and it is not a Grim setback, so the isSetback leniency does not apply). The only honest bypass surface is transaction eating - suppressing the client's transaction echo so the vector is never promoted out of the uncertain firstBreadMap bucket - which Sigma's modes do not attempt.

anticheat AntiVelocityBasic (pending knockback matching)

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

How it counteracts this module

Hawk's MoveEvent keeps a pending knockback list per player and matches every move's velocity against it. handlePendingVelocities computes the move delta (to - from), and for each pending kb entry checks the Y component within 0.01 (unless the player collides with a block, jumps, swims or steps), then X and Z inside maxDiscrepancy = weirdConstant * baseMultiplier * sprintMultiplier + 0.003 epsilon, where weirdConstant is 0.098 on ground (0.2518462 while jump-sprinting, 0.0196 swimming), baseMultiplier is 5 * walkSpeed * speed-pot multiplier (or 10 * flySpeed when flying) and sprintMultiplier 1.3 (2 flying). A kb entry older than ping + 200ms with no matching move sets failedKnockback (outside vehicles), and AntiVelocityBasic.check punishes that at VL 5 with 'may be using anti-velocity (basic)'. The class comment says it is tested to detect down to a 10% difference.

Basic at 0/0 cancels the S12, so no move ever matches the pending entry and it expires into a flag. Basic at partial percentages keeps the move inside maxDiscrepancy only while the reduction leaves the scaled remainder inside the window - for the default 10% detection claim, reductions beyond roughly 10% of the vector fall outside and flag. AACFlag produces the same expiry: the NaN C04 and the follow-up S08 teleport are teleport events, not knockback matches, so the entry ages out. AACPush is the subtle case: the S12 is received and the vanilla vertical motion does follow the kb, but every hurt tick strafe() overwrites motionX/motionZ with a facing-relative boost, so the X/Z match test fails and the entry expires - the vertical component alone cannot satisfy the check.

anticheat VelocityListener (claimed velocity feed)

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

How it counteracts this module

Spartan's VelocityListener is a MONITOR-priority ProtocolLib adapter on ENTITY_VELOCITY. For the self entity it reads the fixed-point x, y, z through BackPlib.getSafeInt divided by 8000.0, builds a CPlayerVelocityEvent carrying the claimed vector, forwards the packet's cancellation state, and dispatches it on the CheckThread to VelocityEvent.event, which stores it as protocol.claimedVelocity, pushes it onto the claimedVeloGravity and claimedVeloSpeed queues (each capped at two entries) and runs Spartan's checks with executeRunners. The flagging lives in the movement checks that consume claimedVelocity - the file is the feed, not the verdict - but the feed is what matters here: it records the vector the server itself sent.

Because the claimed vector is read server-side from the wire, Sigma's client-side manipulation cannot change it. Basic at 0/0 and AACFlag cancel the S12, so the player's movement shows a total deficit against the claimed vector. Basic at partial percentages still shows a proportional deficit, since the queue compares the reported movement against the full server vector. AACPush overshoots in a different way: the module adds horizontal boost on top of the received knockback, so the movement exceeds the claimed horizontal profile while the vertical decay is normal. The two-entry queue cap is the tolerance surface - only the last two claims are compared, so a module that alternates clean movement between hits can stay under the checks' tolerances, but Sigma's per-hit rewriting leaves no clean window.

anticheat UnusedVelocity (unused knockback ledger)

UnusedVelocity.java87 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.moving.player;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.checks.CheckType;
20
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
21
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
22
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleAxisVelocity;
23
import fr.neatmonster.nocheatplus.checks.moving.velocity.UnusedTracker;
24
import fr.neatmonster.nocheatplus.logging.debug.DebugUtil;
25
import fr.neatmonster.nocheatplus.players.IPlayerData;
26
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
27
28
public class UnusedVelocity {
29
    
30
    // TODO: Currently is debug only (!). Only call if some debug flag is set. Needs checks.moving.debug to work at all.
31
32
    /**
33
     * Test if any unused velocity has been tracked and what that means. (Convenience.)
34
     * 
35
     * @param player
36
     * @return If the player has failed the check, whatever that means.
37
     */
38
    public static boolean checkUnusedVelocity(final Player player, 
39
            final CheckType checkType, final IPlayerData pData) {
40
        return checkUnusedVelocity(
41
                player, checkType, 
42
                pData.getGenericInstance(MovingData.class), 
43
                pData.getGenericInstance(MovingConfig.class)
44
                );
45
    }
46
47
48
    /**
49
     * Test if any unused velocity has been tracked and what that means.
50
     * 
51
     * @param player
52
     * @param data
53
     * @param cc
54
     * @return If the player has failed the check, whatever that means.
55
     */
56
    public static boolean checkUnusedVelocity(final Player player, 
57
            final CheckType checkType, final MovingData data, final MovingConfig cc) {
58
        boolean violation = false;
59
        final SimpleAxisVelocity verVel = data.getVerticalVelocityTracker();
60
        violation |= quickCheckDirection(player, verVel.unusedTrackerPos, checkType, "vert/pos", data, cc);
61
        violation |= quickCheckDirection(player, verVel.unusedTrackerNeg, checkType, "vert/neg", data, cc);
62
        return violation;
63
    }
64
65
    /**
66
     * Quick check tracker for one direction.
67
     * @param player
68
     * @param checkType 
69
     * @param unusedTrackerPos
70
     * @param string
71
     * @param data
72
     * @param cc
73
     */
74
    private static boolean quickCheckDirection(final Player player, 
75
            final UnusedTracker tracker, final CheckType checkType, final String trackerId ,
76
            MovingData data, MovingConfig cc) {
77
        final int countV = tracker.getResultViolationCount();
78
        if (countV > 0) {
79
            String msg = "Unused velocity " + trackerId + ": c_v: " + countV + " , a_v: " + tracker.getResultViolationAmount() + " , c_u: " + tracker.getResultUpdateCount();
80
            DebugUtil.debug(CheckUtils.getLogMessagePrefix(player, checkType) + msg);
81
        }
82
        tracker.resetResults(); // Reset for now.
83
        // TODO: A real check, e.g. track frequency and/or average amount of violation per so and so time.
84
        return false; // Player can't possibly fail this yet.
85
    }
86
87
}

How it counteracts this module

NCP's movement model queues the vertical velocity the server applied and later consumes it to explain the player's actual movement. checkUnusedVelocity reads the pos and neg UnusedTracker instances of the SimpleAxisVelocity vertical tracker; UnusedTracker.addValue records a violation amount only when the direction has been blocked since the entry was added, i.e. the server pushed velocity in a direction the player never moved, and quickCheckDirection reports the violation count, accumulated amount and update count before resetting the results.

In this build the check is a debug ledger: quickCheckDirection logs through DebugUtil and returns false with a TODO for a real frequency or amount check, so the player cannot fail it yet - the honest framing is that NCP's velocity queue model is what would expose the module once the check is enabled. Basic at 0/0 and AACFlag leave the vertical push un-consumed (the cancelled S12 means the client never moves along it, and the NaN move is not a consumption), so the tracker accumulates; AACPush consumes the vertical component normally but the extra horizontal strafe is outside what the vertical tracker models. As shipped, an AntiVelocity user faces NCP's SurvivalFly envelope, not this check.

← Back to Analysis Hub