Sigma 4.11 Killaura module 3 files, 1028 lines

Sigma 4.11 Killaura: Full Source Analysis

Sigma 4.11's Killaura is a full combat automation module driven entirely from the pre phase of EventUpdate, with EventRender3D reserved for ESP and EventStep for critical timing.

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

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

Analysis

Overview

Sigma 4.11's Killaura is a full combat automation module driven entirely from the pre phase of EventUpdate, with EventRender3D reserved for ESP and EventStep for critical timing. One onEvent method branches on event type: the pre update picks a target (or a whole list in Multi mode), writes the aim into the outgoing movement packet via em.setYaw/setPitch, gates attacks on a per-tick timer (cps is re-rolled between the MIN/MAX APS settings every tick), and then either fires hitEntity or fakes a miss with a bare swing. Rotation is pluggable across Basic (instant snap), Smooth (yaw/1.7 easing), Legit (a nonlinear easing with a carried momentum term aacB) and Predict (one-tick velocity extrapolation), and the aura itself has Switch/Single/Multi/Multi2 target cycling, a Pre/Post attack-timing split, a hit-chance gate that also hard-misses when the needed yaw change exceeds an interval that shrinks with distance, and four autoblock flavors (NCP, Hypixel, Basic1, Basic2) that park the sword via a client-side itemInUseCount = 999 flag while the real block state is driven by C02 INTERACT + C08 placement packets. It also folds in a miniCrit integration that rewrites the movement packet's Y and onGround to manufacture fall-criticals whenever the Criticals module runs in Minis or HMinis mode.

Architecture

All logic lives in one @RegisterEvent handler listening for EventUpdate, EventRender3D and EventStep. The pre update first runs the death and respawn guards (toggle off when GuiGameOver shows or ticksExisted <= 1), then a conflict check that bails whenever BedFucker or CakeEater is mid block-break or Scaffold owns the look (Legit/Cubecraft/Custom with ROT), because those modules would fight Killaura for the rotation. Targeting is a two-pass sweep over mc.theWorld.loadedEntityList: getOptimalTarget(range) for the primary and blockTarget = getOptimalTarget(blockRange) for autoblock, each filtered by validEntity (distance, WALLS-gated visibility, AntiBot exclusion, friends, teams, invisibles, players-only) and ranked by sortList under the Angle/Range/FOV/Armor priority. In Single/Switch/Multi2 the chosen target is stored and the hit pipeline runs once per tick when timer >= 20/cps; Multi instead builds the full loaded list, aims at the first entry and sends one attack to every entry in the same tick. The post phase (TYPE=Post) runs the identical interval/hitchance gate on the post update, and blockTarget handling arms or parks the shield around it.

Rotation and miss gating

The rotation modes differ in how much of the required yaw is written per tick. Basic writes the exact rotation via em.setYaw/em.setPitch, so the movement packet that tick carries the full snap. Smooth steps yaw by targetYaw / 1.7 per tick. Legit uses customRots, a piecewise easing: yawFactor = targetYaw^2 / (4.7 * targetYaw) normally (targetYaw / 3.7 when the delta is under 5 degrees), and whenever the raw factor exceeds 7 it stores aacB = yawFactor * 7 and switches to targetYaw / 3.7, so the next tick adds the remembered momentum (yawFactor = targetYaw^2 / (6.7 * targetYaw) + aacB) -- an explicit attempt to break per-tick yaw-rate limits by splitting one large rotation across two packets. Predict aims at posX + (posX - lastTickPosX), one tick of extrapolation. getCustomRotsChange randomizes the aim point by +-0.3 blocks on x/z and -(0.4 + mult * randoms[1]) on y whenever the target is not inside the player's own bounding box, and bakes a -2.5 degree pitch bias into the returned delta. Independently of the rotation mode, shouldMiss is forced true when a random draw exceeds the HITCHANCE percent, when a new target was picked within the last 70ms (newTarget.delay(70)), while AutoPot is potting, or when the yaw still needed at attack time exceeds interval = 60 - distance * 10 (50 - distance * 10 in Legit), which collapses to near zero at max range; a miss still swings (swingItem) so the client-side animation and the server-side C0A both fire without an attack.

Attack cadence and autoblock packet flow

The attack gate is a tick counter, not a timer: timer increments every pre update and an attack fires when timer >= 20/cps, with cps re-rolled as randomNumber(min, max) between the MIN and MAX APS settings (both default 5, range 1-20), so at 20 APS one C02 ATTACK lands per tick and in Multi mode one per target per tick. hitEntity unblocks first if needed, fires the EventAttack hook around swingItem + playerController.attackEntity (the vanilla local attack so knockback and item damage simulate), then re-blocks in Basic1 mode. Autoblock is a three-packet sequence: with the INTERACT setting on, block() sends a C02 carrying a random Vec3 (x/z in +-0.5, y in 0-2.0) and a second C02 with Action.INTERACT, then a C08PacketPlayerBlockPlacement with the held item; blockHypixel() swaps the C08 position for PlayerUtil.getHypixelBlockpos(username) with facing 255. The shield is represented client-side by forcing mc.thePlayer.itemInUseCount = 999, and unBlock() reverses it with syncCurrentPlayItem plus a C07PacketPlayerDigging RELEASE_USE_ITEM at BlockPos.ORIGIN. The miniCrit hook rewrites the movement packet instead: in HMinis it cycles em.setY(posY + 0.0625 / 0.0626 / 0 / 0) with lastReportedPosY = 0 and setOnGround(false), and in Minis it staggers a 0.0628 offset off lastStep timing (the C04 it builds is commented out, so only the Y rewrite ships) -- the server sees the player fall ~0.06 blocks between hits and awards the fall-critical damage bonus.

source Killaura.java (module)

Killaura.java800 lines · JavaOriginal ↗
1
package info.sigmaclient.module.impl.combat;
2
3
import info.sigmaclient.Client;
4
import info.sigmaclient.event.Event;
5
import info.sigmaclient.event.EventSystem;
6
import info.sigmaclient.event.RegisterEvent;
7
import info.sigmaclient.event.impl.EventAttack;
8
import info.sigmaclient.event.impl.EventPacket;
9
import info.sigmaclient.event.impl.EventRender3D;
10
import info.sigmaclient.event.impl.EventStep;
11
import info.sigmaclient.event.impl.EventUpdate;
12
import info.sigmaclient.management.ColorManager;
13
import info.sigmaclient.management.MoveUtils;
14
import info.sigmaclient.management.friend.FriendManager;
15
import info.sigmaclient.management.notifications.Notifications;
16
import info.sigmaclient.module.Module;
17
import info.sigmaclient.module.data.ModuleData;
18
import info.sigmaclient.module.data.Options;
19
import info.sigmaclient.module.data.Setting;
20
import info.sigmaclient.module.impl.minigames.BedFucker;
21
import info.sigmaclient.module.impl.minigames.CakeEater;
22
import info.sigmaclient.module.impl.movement.Bhop;
23
import info.sigmaclient.module.impl.movement.Fly;
24
import info.sigmaclient.module.impl.movement.LongJump;
25
import info.sigmaclient.module.impl.movement.Step;
26
import info.sigmaclient.module.impl.player.Scaffold;
27
import info.sigmaclient.util.PlayerUtil;
28
import info.sigmaclient.util.RenderingUtil;
29
import info.sigmaclient.util.RotationUtils;
30
import info.sigmaclient.util.TeamUtils;
31
import info.sigmaclient.util.Timer;
32
import info.sigmaclient.util.misc.BlockUtils;
33
import info.sigmaclient.util.misc.ChatUtil;
34
import info.sigmaclient.util.render.Colors;
35
36
import java.awt.Color;
37
import java.util.ArrayList;
38
import java.util.Arrays;
39
import java.util.Comparator;
40
import java.util.List;
41
import java.util.concurrent.CopyOnWriteArrayList;
42
43
import net.minecraft.block.Block;
44
import net.minecraft.block.BlockSlab;
45
import net.minecraft.block.BlockStairs;
46
import net.minecraft.client.entity.EntityPlayerSP;
47
import net.minecraft.client.gui.GuiGameOver;
48
import net.minecraft.client.renderer.GlStateManager;
49
import net.minecraft.client.renderer.Tessellator;
50
import net.minecraft.client.renderer.WorldRenderer;
51
import net.minecraft.client.renderer.entity.RenderManager;
52
import net.minecraft.entity.Entity;
53
import net.minecraft.entity.EntityLivingBase;
54
import net.minecraft.entity.monster.EntityIronGolem;
55
import net.minecraft.entity.monster.EntityMob;
56
import net.minecraft.entity.passive.EntityAnimal;
57
import net.minecraft.entity.passive.EntityVillager;
58
import net.minecraft.entity.player.EntityPlayer;
59
import net.minecraft.item.ItemSword;
60
import net.minecraft.network.Packet;
61
import net.minecraft.network.play.client.C02PacketUseEntity;
62
import net.minecraft.network.play.client.C02PacketUseEntity.Action;
63
import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
64
import net.minecraft.network.play.client.C03PacketPlayer;
65
import net.minecraft.network.play.client.C07PacketPlayerDigging;
66
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
67
import net.minecraft.network.play.client.C0APacketAnimation;
68
import net.minecraft.network.play.client.C0BPacketEntityAction;
69
import net.minecraft.util.AxisAlignedBB;
70
import net.minecraft.util.BlockPos;
71
import net.minecraft.util.EnumFacing;
72
import net.minecraft.util.MathHelper;
73
import net.minecraft.util.Vec3;
74
75
import org.lwjgl.opengl.GL11;
76
77
public class Killaura extends Module {
78
79
	public static EntityLivingBase target, vip, blockTarget;
80
	public static final String TYPE = "TYPE";
81
	private final String TARGETMODE = "PRIORITY";
82
	private final String AUTOBLOCK = "AUTOBLOCK";
83
	private final String RANGE = "RANGE";
84
	private final String BLOCKRANGE = "BLOCKRANGE";
85
	private final String PLAYERS = "PLAYERS";
86
	private final String ANIMALS = "OTHERS";
87
	private final String TEAMS = "TEAMS";
88
	private final String ESP = "ESP";
89
	private final String HITCHANCE = "HITCHANCE";
90
	private final String WALLS = "WALLS";
91
	private final String INVISIBLES = "INVISIBLES";
92
	private final String MAX = "MAXAPS";
93
	private final String MIN = "MINAPS";
94
	private final String ROTATIONS = "ROTATIONS";
95
	private final String AUTOBLOCKMODE = "AUTOBLOCKMODE";
96
	private final String MODE = "MODE";
97
	private final String DEATH = "DEATH";
98
	private final String INTERACT = "INTERACT";
99
	
100
	private Timer switchTimer = new Timer();
101
	public static float sYaw, sPitch, aacB;
102
	private double fall;
103
	int[] randoms = {0,1,0};
104
	private boolean isBlocking = false;
105
	public static boolean isSetup = false;
106
	private Timer newTarget = new Timer();
107
	private Timer lastStep = new Timer();
108
	private Timer rtimer = new Timer();
109
	private List<EntityLivingBase> loaded = new CopyOnWriteArrayList<>();
110
	private int index, timer, crits, groundTicks;
111
	ArrayList<Module>moveMods = new ArrayList<Module>(Arrays.asList(Client.getModuleManager().get(Bhop.class), Client.getModuleManager().get(LongJump.class),Client.getModuleManager().get(Fly.class)));
112
    public Killaura(ModuleData data) {
113
        super(data);
114
        settings.put(RANGE, new Setting<>(RANGE, 4.5, "Range for KillAura.", 0.05, 1, 8));
115
        settings.put(BLOCKRANGE, new Setting<>(BLOCKRANGE, 4.5, "Range for Autoblock.", 0.05, 1, 12));
116
		settings.put(MIN, new Setting<>(MIN, 5, "Minimum APS.", 1, 1, 20));
117
		settings.put(MAX, new Setting<>(MAX, 5, "Maximum APS.", 1, 1, 20));
118
		settings.put(HITCHANCE, new Setting<>(HITCHANCE, 90, "Chance to hit (Percent)", 1, 1, 100));
119
		settings.put(PLAYERS, new Setting<>(PLAYERS, true, "Attack players."));
120
		settings.put(INTERACT, new Setting<>(INTERACT, true, "Interact autoblock."));
121
		settings.put(WALLS, new Setting<>(WALLS, true, "Hit through walls."));
122
		settings.put(ANIMALS, new Setting<>(ANIMALS, false, "Attack Animals."));
123
		settings.put(TEAMS, new Setting<>(TEAMS, false, "Check if player is not on your team."));
124
		settings.put(INVISIBLES, new Setting<>(INVISIBLES, false, "Attack invisibles."));
125
		settings.put(AUTOBLOCK, new Setting<>(AUTOBLOCK, true, "Automatically blocks for you."));
126
		settings.put(DEATH, new Setting<>(DEATH, true,"Disables KillAura when you die."));
127
		settings.put(TARGETMODE, new Setting<>(TARGETMODE, new Options("Priority", "Angle", new String[] { "Angle", "Range", "FOV", "Armor" }), "Target mode priority."));
128
		settings.put(ROTATIONS, new Setting<>(ROTATIONS, new Options("Rotations", "Basic", new String[] { "Basic", "Smooth", "Legit", "Predict" }), "Rotations method."));
129
		settings.put(AUTOBLOCKMODE, new Setting<>(AUTOBLOCKMODE, new Options("Autoblock", "Basic1", new String[] { "NCP","Hypixel", "Basic1", "Basic2"  }),"Autoblock method."));
130
		settings.put(MODE, new Setting<>(MODE, new Options("Mode", "Single",new String[] { "Switch", "Single", "Multi", "Multi2" }), "Aura method."));
131
		settings.put(TYPE, new Setting<>(TYPE, new Options("Type", "Pre", new String[] { "Pre", "Post"  }),"KillAura type."));
132
		settings.put(ESP, new Setting<>(ESP, true, "Draw boxes on targets."));
133
    }
134
    public static boolean isSetupTick() {
135
		return isSetup;
136
	}
137
    @Override
138
    public void onEnable(){
139
    	if(mc.thePlayer != null){
140
    		sYaw = mc.thePlayer.rotationYaw;
141
    		sPitch = mc.thePlayer.rotationPitch;
142
    		loaded.clear();
143
    		isBlocking = mc.thePlayer.isBlocking()?true:false;		
144
    	}
145
    	newTarget.reset();
146
    	timer = 20;
147
    	groundTicks = MoveUtils.isOnGround(0.01)?1:0;
148
    	aacB = 0;
149
    }
150
    
151
    @Override
152
    public void onDisable(){
153
       	loaded.clear();
154
    	if(mc.thePlayer == null)
155
    		return;
156
    	if(isBlocking && hasSword() && mc.thePlayer.getItemInUseCount() == 999)
157
    		unBlock();  
158
    	
159
    	if(mc.thePlayer.itemInUseCount == 999)
160
    		mc.thePlayer.itemInUseCount = 0;  	
161
    	target = null;
162
    	blockTarget = null;
163
    }
164
    
165
    @RegisterEvent(events = {EventUpdate.class, EventRender3D.class, EventStep.class})
166
    public void onEvent(Event event) {
167
    	final String mode = ((Options) settings.get(MODE).getValue()).getSelected();
168
		final String rotationsMode = ((Options) settings.get(ROTATIONS).getValue()).getSelected();
169
		final String autoblockMode = ((Options) settings.get(AUTOBLOCKMODE).getValue()).getSelected();
170
		final String type = ((Options) settings.get(TYPE).getValue()).getSelected();
171
		final int min = ((Number) settings.get(MIN).getValue()).intValue();
172
		final int max = ((Number) settings.get(MAX).getValue()).intValue();
173
		final double hitchance = ((Number) settings.get(HITCHANCE).getValue()).doubleValue();
174
		final int cps = randomNumber(min, max);
175
		double range = ((Number) settings.get(RANGE).getValue()).floatValue();
176
		double blockRange = ((Number) settings.get(BLOCKRANGE).getValue()).floatValue();
177
		final boolean autoblock = (Boolean) settings.get(AUTOBLOCK).getValue();
178
		Module critsMod = Client.getModuleManager().get(Criticals.class);
179
		String critsMode = ((Options) critsMod.getSetting(Criticals.PACKET).getValue()).getSelected();
180
		boolean minicrit =critsMod.isEnabled() && (critsMode.equalsIgnoreCase("Minis") || critsMode.equalsIgnoreCase("HMinis")) ;
181
		this.setSuffix(mode);
182
		if(event instanceof EventStep){
183
			EventStep es = (EventStep)event;
184
			if(!es.isPre()){
185
				lastStep.reset();
186
			}
187
		}
188
		if(event instanceof EventRender3D){
189
			EventRender3D er = (EventRender3D)event;
190
			if(target != null && (Boolean) settings.get(ESP).getValue()){
191
				int color = target.hurtResistantTime > 15 ? Colors.getColor(new Color(255, 70, 70, ColorManager.esp.getAlpha())) : ColorManager.esp.getColorInt();
192
				if(mode.equalsIgnoreCase("Multi")){
193
					for(EntityLivingBase ent : loaded){
194
						drawESP(ent, color);
195
					}	
196
				}else{
197
					drawESP(target, color);
198
				}				
199
			}
200
		}
201
		if (event instanceof EventUpdate) {
202
            EventUpdate em = (EventUpdate) event;
203
        	boolean shouldMiss = randomNumber(0, 100) > hitchance;
204
        	EntityLivingBase newT = getOptimalTarget(range);
205
206
            if (em.isPre()) {
207
            	timer ++;
208
            	if((Boolean) settings.get(DEATH).getValue()) {
209
            		if ((!mc.thePlayer.isEntityAlive() || (mc.currentScreen != null && mc.currentScreen instanceof GuiGameOver))) {
210
						this.toggle();
211
						Notifications.getManager().post("Aura Death","Aura disabled due to death.");
212
						return;
213
					}
214
            		if(mc.thePlayer.ticksExisted <= 1){
215
            			this.toggle();
216
						Notifications.getManager().post("Aura","Aura disabled due to respawn.");
217
						return;
218
            		}
219
            	}
220
            	Module cakeEater = Client.getModuleManager().get(CakeEater.class);
221
    			Module scaffold = Client.getModuleManager().get(Scaffold.class);
222
    			if ((BedFucker.blockBreaking != null)
223
    				|| (CakeEater.blockBreaking != null&& cakeEater.getSetting(CakeEater.MODE) != null && ((Options) cakeEater.getSetting(CakeEater.MODE).getValue()).getSelected().equals("Basic"))
224
    				|| (((((Options)scaffold.getSetting(Scaffold.MODE).getValue()).getSelected().equalsIgnoreCase("Custom") 
225
    					&& ((boolean)scaffold.getSetting(Scaffold.ROT).getValue()) || ((Options)scaffold.getSetting(Scaffold.MODE).getValue()).getSelected().equalsIgnoreCase("Legit") || ((Options)scaffold.getSetting(Scaffold.MODE).getValue()).getSelected().equalsIgnoreCase("Cubecraft"))) && Scaffold.yaw != 999 && Scaffold.pitch != 999)) {
226
    				if(mc.thePlayer.getItemInUseCount() == 999){
227
    					mc.thePlayer.itemInUseCount = 0;
228
    				}
229
    				return;
230
    			}
231
    			
232
				blockTarget = getOptimalTarget(blockRange);
233
				
234
235
236
            	if(mode.equalsIgnoreCase("Multi")){
237
            		loaded = getTargets(range);
238
            		if (loaded.size() > 0){
239
            			target = loaded.get(0);
240
                		final float[] rot = RotationUtils.getRotations(target);
241
                		em.setYaw(rot[0]);
242
                    	em.setPitch(rot[1]);
243
    					sYaw = rot[0];
244
    					sPitch = rot[1];
245
						if(autoblock){
246
	            			if (hasSword())
247
	            				mc.thePlayer.itemInUseCount = 999;
248
	            			else if(mc.thePlayer.itemInUseCount == 999)
249
	            				mc.thePlayer.itemInUseCount = 0;
250
	            		}else if(mc.thePlayer.itemInUseCount == 999){
251
	            			if(isBlocking && hasSword())
252
	            				unBlock();
253
	            			mc.thePlayer.itemInUseCount = 0;
254
	            		}
255
						if (minicrit) {
256
							miniCrit(em, critsMode);
257
						}
258
						if(timer >= 20/cps ){
259
	            			timer = 0;
260
	            			if(AutoPot.isPotting()){
261
								shouldMiss = true;
262
								mc.thePlayer.swingItem();
263
	            			}
264
	            			if(isBlocking){
265
            					if (hasSword())	
266
            						unBlock();
267
            				}
268
	            			if(loaded.size() >= 1 && !shouldMiss){
269
	            				mc.playerController.syncCurrentPlayItem();
270
	            				mc.thePlayer.swingItem();
271
	            			}
272
	            			
273
							for(EntityLivingBase targ : loaded){
274
		            			if(!shouldMiss){
275
		            				EventAttack ej = (EventAttack) EventSystem.getInstance(EventAttack.class);
276
		            				ej.fire(target, true);
277
		            				mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(targ, C02PacketUseEntity.Action.ATTACK));
278
		            				mc.thePlayer.attackTargetEntityWithCurrentItem(targ);
279
		            				ej.fire(target,  false);
280
		            				
281
		            			}
282
	            			}
283
							if(autoblock){
284
            					if(autoblockMode.equalsIgnoreCase("Basic1")){
285
            						if (hasSword())
286
            							block(target);
287
            					}
288
            				}
289
	            		}else if(autoblock){
290
	            			if(autoblockMode.equalsIgnoreCase("NCP") || autoblockMode.equalsIgnoreCase("Hypixel")){
291
	            				if(hasSword() && isBlocking)
292
	            					unBlock();
293
	            			}
294
	            		}
295
            			
296
            		}
297
            	}else{
298
                 	if (mode.equalsIgnoreCase("Switch")) {
299
        				float cooldown = rotationsMode.equalsIgnoreCase("Smooth") ? 500
300
        						: 400;
301
        				if (switchTimer.delay(cooldown)) {
302
        					loaded = getTargets(range);
303
        				}
304
        				if (index >= loaded.size()) {
305
        					index = 0;
306
        				}
307
        				if (switchTimer.delay(cooldown) && loaded.size() > 0) {
308
        					index += 1;
309
        					if (index >= loaded.size()) {
310
        						index = 0;
311
        					}
312
        					switchTimer.reset();
313
        				}	
314
        				
315
        				
316
        				if (loaded.size() > 0)
317
        					newT = loaded.get(index);
318
        				else
319
        					newT = null;		
320
        			}else if(mode.equalsIgnoreCase("Multi2")){
321
        					loaded = getTargets(range);
322
         				if (index >= loaded.size()) 
323
        					index = 0;
324
        				
325
        				if (timer >= 20/cps && loaded.size() > 0) {
326
        					index += 1;
327
        					if (index >= loaded.size()) {
328
        						index = 0;
329
        					}
330
        				}
331
        				if (loaded.size() > 0)
332
        					newT = loaded.get(index);
333
        				else
334
        					newT = null;	
335
        			}
336
                	if(target != newT){
337
                		newTarget.reset();
338
                		if(!mode.equalsIgnoreCase("Multi2"))
339
                			shouldMiss = true;
340
                		target = newT;
341
                		if(target == null){
342
                    		sYaw = mc.thePlayer.rotationYaw;
343
                    		sPitch = mc.thePlayer.rotationPitch;
344
                		}
345
                	}
346
                	if(target != null){
347
                		if ((!validEntity(target, range) || !mc.theWorld.loadedEntityList.contains(target)) && mode.equalsIgnoreCase("Switch")) {
348
        					loaded = getTargets(range);
349
        					index += 1;
350
        					if (index >= loaded.size()) 
351
        						index = 0;
352
        					return;
353
        				}
354
                		if(!validEntity(target, range) && mode.equalsIgnoreCase("Multi2")){
355
                			loaded = getTargets(range);
356
                
357
                			return;
358
                		}
359
                		if (minicrit) {
360
        					miniCrit(em, critsMode);
361
        				}
362
                    	float[] rot = RotationUtils.getRotations(target);
363
                    	switch(rotationsMode){
364
                    	case"Basic":
365
                    		em.setYaw(rot[0]);
366
                        	em.setPitch(rot[1]);
367
        					sYaw = rot[0];
368
        					sPitch = rot[1];
369
370
                    		break;
371
                    	case"Smooth":
372
                    		smoothAim(em);
373
                    		break;
374
                    	case"Legit":
375
                    		aacB/=2;
376
                    		customRots(em, target);
377
                    		break;
378
                    	case"Predict":
379
                    		rot = RotationUtils.getPredictedRotations(target);
380
                    		em.setYaw(rot[0]);
381
                        	em.setPitch(rot[1]);
382
        					sYaw = rot[0];
383
        					sPitch = rot[1];
384
                    		break;
385
                    	}
386
                		if(timer >= 20/cps && type.equalsIgnoreCase("Pre")){
387
                			timer = 0;
388
                			int XR = randomNumber(1, -1);
389
                        	int YR = randomNumber(1, -1);
390
                        	int ZR = randomNumber(1, -1);
391
                        	randoms[0] = XR;
392
                        	randoms[1] = YR;
393
                        	randoms[2] = ZR;
394
                			float neededYaw = RotationUtils.getYawChange(sYaw, target.posX,target.posZ);
395
                			if(rotationsMode.equalsIgnoreCase("Legit"))
396
                				neededYaw = getCustomRotsChange(sYaw, sPitch, target.posX, target.posY, target.posZ)[0];
397
    						float interval = 60 - mc.thePlayer.getDistanceToEntity(target) * 10;
398
    						if(rotationsMode.equalsIgnoreCase("Legit"))
399
    							interval = 50 - mc.thePlayer.getDistanceToEntity(target) * 10;
400
    						if(neededYaw > interval || neededYaw < -interval || !newTarget.delay(70) || AutoPot.isPotting())
401
    							shouldMiss = true;
402
                			if(!shouldMiss || mode.equalsIgnoreCase("Multi2"))
403
                				hitEntity(target, autoblock, autoblockMode);
404
                			else
405
                				mc.thePlayer.swingItem();
406
                		}
407
                	}
408
            	}
409
           
410
            	if(blockTarget != null){
411
            		if(autoblock){
412
            			if (hasSword()){
413
            				if(autoblockMode.equalsIgnoreCase("NCP") || autoblockMode.equalsIgnoreCase("Hypixel")){
414
                				if(hasSword() && isBlocking)
415
                					unBlock();       				
416
                			}else if(mc.thePlayer.itemInUseCount == 0){
417
               					block(blockTarget);              				
418
                			}
419
            				mc.thePlayer.itemInUseCount = 999;
420
            			}else if(mc.thePlayer.itemInUseCount == 999)
421
            				mc.thePlayer.itemInUseCount = 0;
422
            		}else if(mc.thePlayer.itemInUseCount == 999){
423
            			if(isBlocking && hasSword())
424
            				unBlock();
425
            			mc.thePlayer.itemInUseCount = 0;
426
            		}
427
            		
428
            	}else{
429
            		if(mc.thePlayer.itemInUseCount == 999){
430
            			if(isBlocking && hasSword()){
431
            				unBlock();
432
            			}
433
        				mc.thePlayer.itemInUseCount = 0;
434
        			}
435
            	}
436
            }else{
437
            	if(type.equalsIgnoreCase("Post") && target != null){
438
            		timer = 0;
439
        			int XR = randomNumber(1, -1);
440
                	int YR = randomNumber(1, -1);
441
                	int ZR = randomNumber(1, -1);
442
                	randoms[0] = XR;
443
                	randoms[1] = YR;
444
                	randoms[2] = ZR;
445
        			float neededYaw = RotationUtils.getYawChange(sYaw, target.posX,target.posZ);
446
        			if(rotationsMode.equalsIgnoreCase("Legit"))
447
        				neededYaw = getCustomRotsChange(sYaw, sPitch, target.posX, target.posY, target.posZ)[0];
448
					float interval = 60 - mc.thePlayer.getDistanceToEntity(target) * 10;
449
					if(rotationsMode.equalsIgnoreCase("Legit"))
450
						interval = 50 - mc.thePlayer.getDistanceToEntity(target) * 10;
451
					if(neededYaw > interval || neededYaw < -interval || !newTarget.delay(70) || AutoPot.isPotting())
452
						shouldMiss = true;
453
        			if(!shouldMiss || mode.equalsIgnoreCase("Multi2"))
454
        				hitEntity(target, autoblock, autoblockMode);
455
        			else
456
        				mc.thePlayer.swingItem();
457
            	}
458
            	if(blockTarget != null){
459
            		if(!isBlocking && autoblock){
460
                		if(hasSword()){
461
                			if(autoblockMode.equalsIgnoreCase("Hypixel"))
462
                				blockHypixel(blockTarget);     			
463
                			else if(autoblockMode.equalsIgnoreCase("NCP"))
464
                				block(blockTarget);
465
                			else if(autoblockMode.equalsIgnoreCase("Basic2") && timer == 0)
466
                				block(blockTarget);
467
                		}	
468
                	}
469
            	}
470
            	
471
            }
472
        }
473
    }
474
	public void miniCrit(EventUpdate em, String mode) {
475
		double offset = 0;
476
		boolean ground = false;
477
		final int min = ((Number) settings.get(MIN).getValue()).intValue();
478
		final int max = ((Number) settings.get(MAX).getValue()).intValue();
479
		final double hitchance = ((Number) settings.get(HITCHANCE).getValue()).doubleValue();
480
		final int cps = randomNumber(min, max);
481
		final int delay =20/cps;
482
		//TODO
483
		if(mode.equalsIgnoreCase("Minis")){
484
			if(crits == 0){
485
				double x = mc.thePlayer.posX; double y = mc.thePlayer.posY; double z = mc.thePlayer.posZ;
486
				C04PacketPlayerPosition p = new C04PacketPlayerPosition(x, y+0.0626001, z, false);
487
				//mc.thePlayer.sendQueue.addToSendQueue(p);
488
				offset = 0;
489
				crits = 1;	
490
			
491
			}else
492
			if(timer == delay-2 || (delay-2 <= 0 && timer <= delay-2) || timer >= delay){
493
				if(crits >= 1 && lastStep.delay(20)){
494
					crits =0;
495
					offset = 0.0628;
496
					fall += offset;
497
				}
498
			}
499
		}else if(mode.equalsIgnoreCase("HMinis")){
500
			if(!lastStep.delay(20) || groundTicks <= 0){
501
				crits = -1;
502
				ground = true;
503
			}
504
			
505
			crits++; 
506
			if(crits == 1){
507
				offset = 0.0625;
508
			}else if(crits == 2){
509
				offset = 0.0626;
510
			}else if(crits == 3){
511
512
				offset = 0;
513
			}else if(crits == 4){
514
				offset = 0.0;
515
				crits = 0;
516
			}
517
		}
518
		
519
		boolean aa = BlockUtils.isOnGround(0.001);
520
		if(!aa){
521
			groundTicks = 0;
522
			crits = 0;
523
			fall = 0;
524
		}else{
525
			groundTicks ++;
526
		}
527
		if (mc.thePlayer.isCollidedVertically && aa
528
				&& !mc.thePlayer.isJumping && !mc.thePlayer.isInWater()
529
				&& !mc.gameSettings.keyBindJump.getIsKeyPressed()) {
530
			for(Module m : moveMods){
531
				if(m.isEnabled()){
532
					if(m instanceof LongJump){
533
						if(!((Options) m.getSetting(LongJump.MODE).getValue()).getSelected().equalsIgnoreCase("Cubecraft")){
534
							return;
535
						}
536
					}else{
537
						return;
538
					}
539
				}	
540
			}
541
			if (mc.thePlayer.motionY != -0.1552320045166016) {
542
				if (offset != 0) {
543
					isSetup = true;
544
				} else {
545
					isSetup = false;
546
				}
547
				mc.thePlayer.lastReportedPosY = 0;
548
				em.setY(mc.thePlayer.posY + offset);
549
				em.setOnGround(ground);
550
			}
551
		}
552
	}
553
    
554
    private EntityLivingBase getOptimalTarget(double range) {
555
		List<EntityLivingBase> load = new ArrayList<>();
556
	//	List entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox.expand(range, range, range));
557
		//for (Object o : entities) {
558
    	for(Object o : mc.theWorld.loadedEntityList){
559
			if (o instanceof EntityLivingBase) {
560
561
				EntityLivingBase ent = (EntityLivingBase) o;
562
				if (validEntity(ent, range)) {
563
					if (ent == vip) {
564
						return ent;
565
					}
566
					load.add(ent);
567
				}
568
			}
569
		}
570
		if (load.isEmpty()) {
571
			return null;
572
		}
573
		return getTarget(load);
574
	}
575
    
576
	boolean validEntity(EntityLivingBase entity, double range) {
577
		boolean players = (Boolean) settings.get(PLAYERS).getValue();
578
		boolean animals = (Boolean) settings.get(ANIMALS).getValue();
579
		if ((mc.thePlayer.isEntityAlive()) && !(entity instanceof EntityPlayerSP)) {
580
			if (mc.thePlayer.getDistanceToEntity(entity) <= range) {
581
				if (!RotationUtils.canEntityBeSeen(entity) && !(Boolean) settings.get(WALLS).getValue()) 
582
					return false;
583
				if (AntiBot.getInvalid().contains(entity) || entity.isPlayerSleeping()) 
584
					return false;
585
				if (FriendManager.isFriend(entity.getName())) 
586
					return false;
587
				if (entity instanceof EntityPlayer) {
588
					if (players) {
589
						EntityPlayer player = (EntityPlayer) entity;
590
						if (!player.isEntityAlive()
591
								&& player.getHealth() == 0.0) {
592
							return false;
593
						} else if (TeamUtils.isTeam(mc.thePlayer, player) && (Boolean) settings.get(TEAMS).getValue()) 
594
							return false;
595
						 else if (player.isInvisible() && !(Boolean) settings.get(INVISIBLES).getValue()) {
596
							return false;
597
						} else if (FriendManager.isFriend(player.getName())) {
598
							return false;
599
						} else
600
							return true;
601
					}
602
				} else {
603
					if (!entity.isEntityAlive()) 
604
						return false;
605
				}
606
				if(animals){
607
					if(entity instanceof EntityMob || entity instanceof EntityIronGolem ||
608
							entity instanceof EntityAnimal || entity instanceof EntityVillager){
609
						if (entity.getName().equals("Villager") && entity instanceof EntityVillager) {
610
							return false;
611
						}
612
						return true;
613
					}
614
				}
615
			}
616
		}
617
		return false;
618
	}
619
	private EntityLivingBase getTarget(List<EntityLivingBase> list) {
620
		sortList(list);
621
		if (list.isEmpty()) {
622
			return null;
623
		}
624
		return list.get(0);
625
	}
626
	private void sortList(List<EntityLivingBase> weed) {
627
		String current = ((Options) settings.get(TARGETMODE).getValue())
628
				.getSelected();
629
		switch (current) {
630
		case "Range":
631
			weed.sort((o1, o2) -> (int) (o1.getDistanceToEntity(mc.thePlayer) * 1000 - o2
632
					.getDistanceToEntity(mc.thePlayer) * 1000));
633
634
			break;
635
		case "FOV":
636
			weed.sort(Comparator.comparingDouble(o -> (RotationUtils
637
					.getDistanceBetweenAngles(mc.thePlayer.rotationPitch,
638
							RotationUtils.getRotations(o)[0]))));
639
			break;
640
		case "Angle":
641
			weed.sort((o1, o2) -> {
642
				float[] rot1 = RotationUtils.getRotations(o1);
643
				float[] rot2 = RotationUtils.getRotations(o2);
644
				return (int) ((mc.thePlayer.rotationYaw - rot1[0]) - (mc.thePlayer.rotationYaw - rot2[0]));
645
			});
646
			break;
647
		case "Health":
648
			weed.sort((o1, o2) -> (int) (o1.getHealth() - o2.getHealth()));
649
			break;
650
		case "Armor":
651
			weed.sort(Comparator
652
					.comparingInt(o -> (o instanceof EntityPlayer ? ((EntityPlayer) o).inventory
653
							.getTotalArmorValue() : (int) o.getHealth())));
654
			break;
655
		}
656
	}
657
	public static int randomNumber(int max, int min) {
658
		return Math.round(min + (float)Math.random() * ((max - min)));
659
	}
660
	private void smoothAim(EventUpdate em){
661
		double randomYaw = 0.05;
662
		double randomPitch = 0.05;
663
		float targetYaw = RotationUtils.getYawChange(sYaw, target.posX + randomNumber(1,-1) * randomYaw, target.posZ + randomNumber(1,-1) * randomYaw);
664
		float yawFactor = targetYaw / 1.7F;
665
		em.setYaw(sYaw + yawFactor);
666
		sYaw += yawFactor;
667
		float targetPitch = RotationUtils.getPitchChange(sPitch, target, target.posY + randomNumber(1,-1) * randomPitch);
668
		float pitchFactor = targetPitch / 1.7F;
669
		em.setPitch(sPitch + pitchFactor);
670
		sPitch += pitchFactor;
671
	}
672
	
673
	private void block(EntityLivingBase ent) {
674
		isBlocking = true;		
675
		if((Boolean) settings.get(INTERACT).getValue()){
676
			mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, new Vec3((double)randomNumber(-50, 50)/100, (double)randomNumber(0, 200)/100, (double)randomNumber(-50, 50)/100)));
677
			mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, Action.INTERACT));
678
		}
679
680
		mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
681
	}
682
	private void blockHypixel(EntityLivingBase ent) {
683
		isBlocking = true;		
684
		if((Boolean) settings.get(INTERACT).getValue()){
685
			mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, new Vec3((double)randomNumber(-50, 50)/100, (double)randomNumber(0, 200)/100, (double)randomNumber(-50, 50)/100)));
686
			mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, Action.INTERACT));
687
		}
688
		mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(PlayerUtil.getHypixelBlockpos(mc.getSession().getUsername()), 255, mc.thePlayer.inventory.getCurrentItem(), 0,0,0));
689
	}
690
	private void unBlock() {
691
		isBlocking = false;
692
		mc.playerController.syncCurrentPlayItem();
693
		mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
694
	}
695
	private boolean hasSword(){
696
		return mc.thePlayer.inventory.getCurrentItem() != null && mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword;
697
	}
698
	private void hitEntity(EntityLivingBase ent, boolean shouldBlock, String autoblockMode){
699
		if(isBlocking){
700
			if (hasSword())	
701
				unBlock();
702
		}
703
		C0BPacketEntityAction act = new C0BPacketEntityAction(mc.thePlayer, net.minecraft.network.play.client.C0BPacketEntityAction.Action.START_SPRINTING);
704
		//mc.thePlayer.sendQueue.addToSendQueue(act);
705
		EventAttack ej = (EventAttack) EventSystem.getInstance(EventAttack.class);
706
		ej.fire(target, true);
707
		mc.thePlayer.swingItem();
708
		mc.playerController.attackEntity(mc.thePlayer, target);
709
		ej.fire(target,  false);
710
		if(shouldBlock){
711
			if(autoblockMode.equalsIgnoreCase("Basic1")){
712
				if (hasSword())
713
					block(ent);
714
			}
715
		}
716
	}
717
	private List<EntityLivingBase> getTargets(double range) {
718
		List<EntityLivingBase> targets = new ArrayList<>();
719
		//List entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox.expand(range, range, range));
720
		//for (Object o : entities) {
721
		for (Object o : mc.theWorld.loadedEntityList) {
722
			if (o instanceof EntityLivingBase) {
723
				EntityLivingBase entity = (EntityLivingBase) o;
724
				if (validEntity(entity, range)) {
725
					targets.add(entity);
726
				}
727
			}
728
		}
729
		sortList(targets);
730
		return targets;
731
	}
732
	public void drawESP(Entity entity, int color) {     
733
		double x = entity.lastTickPosX
734
				+ (entity.posX - entity.lastTickPosX) * mc.timer.renderPartialTicks;
735
736
		double y = entity.lastTickPosY
737
				+ (entity.posY - entity.lastTickPosY) * mc.timer.renderPartialTicks + entity.getEyeHeight()*1.2;
738
739
		double z = entity.lastTickPosZ
740
				+ (entity.posZ - entity.lastTickPosZ) * mc.timer.renderPartialTicks;
741
		double width = Math.abs(entity.boundingBox.maxX - entity.boundingBox.minX) + 0.2;
742
		double height = 0.1;
743
        Vec3 vec = new Vec3(x - width/2, y, z - width/2);
744
        Vec3 vec2 = new Vec3(x + width/2, y + height, z + width/2);
745
        RenderingUtil.pre3D();
746
        mc.entityRenderer.setupCameraTransform(mc.timer.renderPartialTicks, 2);
747
        RenderingUtil.glColor(color);
748
        RenderingUtil.drawBoundingBox(new AxisAlignedBB(
749
        		vec.xCoord - RenderManager.renderPosX, vec.yCoord - RenderManager.renderPosY, vec.zCoord - RenderManager.renderPosZ,
750
        		vec2.xCoord - RenderManager.renderPosX, vec2.yCoord - RenderManager.renderPosY, vec2.zCoord - RenderManager.renderPosZ));
751
        GL11.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
752
        RenderingUtil.post3D();
753
    }
754
	public void customRots(EventUpdate em, EntityLivingBase ent) {
755
        double randomYaw = 0.05;
756
		double randomPitch = 0.05;
757
		float[] rotsN = getCustomRotsChange(sYaw, sPitch, target.posX + randomNumber(1,-1) * randomYaw, target.posY+ randomNumber(1,-1) * randomPitch, target.posZ+ randomNumber(1,-1) * randomYaw);
758
		float targetYaw = rotsN[0];
759
		float yawFactor = targetYaw*targetYaw/(4.7f * targetYaw);
760
		if(targetYaw < 5){
761
			yawFactor = targetYaw*targetYaw/(3.7f * targetYaw);
762
		}
763
		if(Math.abs(yawFactor) > 7){
764
			aacB = yawFactor*7;
765
			yawFactor = targetYaw*targetYaw/(3.7f * targetYaw);
766
		}else{
767
			yawFactor = targetYaw*targetYaw/(6.7f * targetYaw) + aacB;
768
		}
769
		
770
	
771
		em.setYaw(sYaw + yawFactor);
772
		sYaw += yawFactor;
773
		float targetPitch = rotsN[1];
774
		float pitchFactor = targetPitch / 3.7F;
775
		em.setPitch(sPitch + pitchFactor);
776
		sPitch += pitchFactor;
777
    }
778
	public float[] getCustomRotsChange(float yaw, float pitch, double x, double y, double z){
779
    	
780
        double xDiff = x - mc.thePlayer.posX;
781
        double zDiff = z - mc.thePlayer.posZ;
782
        double yDiff = y - mc.thePlayer.posY;
783
        
784
        double dist = MathHelper.sqrt_double(xDiff * xDiff + zDiff * zDiff);
785
    	double mult =  (1/(dist+0.0001)) * 2;
786
    	if(mult > 0.2)
787
    		mult = 0.2;
788
    	if(!mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox).contains(target)){
789
        	x += 0.3 * randoms[0];
790
        	y -= 0.4 + mult * randoms[1];
791
        	z += 0.3 * randoms[2];
792
    	}
793
    	xDiff = x - mc.thePlayer.posX;
794
        zDiff = z - mc.thePlayer.posZ;
795
        yDiff = y - mc.thePlayer.posY;
796
        float yawToEntity = (float) (Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D) - 90.0F;
797
        float pitchToEntity = (float) -(Math.atan2(yDiff, dist) * 180.0D / 3.141592653589793D);
798
        return new float[]{MathHelper.wrapAngleTo180_float(-(yaw- (float) yawToEntity)), -MathHelper.wrapAngleTo180_float(pitch - (float) pitchToEntity) - 2.5F};
799
    }
800
}

What this file does

The constructor declares the full setting surface: RANGE (default 4.5, up to 8), BLOCKRANGE (up to 12), MIN/MAX APS (1-20), HITCHANCE, WALLS (on by default), INTERACT, AUTOBLOCK, TEAMS, INVISIBLES, ANIMALS, DEATH, TARGETMODE (Angle/Range/FOV/Armor), ROTATIONS (Basic/Smooth/Legit/Predict), AUTOBLOCKMODE (NCP/Hypixel/Basic1/Basic2), MODE (Switch/Single/Multi/Multi2), TYPE (Pre/Post) and ESP. onEnable snapshots the current yaw/pitch into the static sYaw/sPitch, records isBlocking from the vanilla isBlocking() state and seeds groundTicks; onDisable unwinds a parked shield (itemInUseCount == 999) with unBlock() so a disabled aura never leaves the client thinking it is blocking.

The onEvent dispatcher is where every combat decision happens. In the pre phase it runs the death/respawn toggles, the BedFucker/CakeEater/Scaffold conflict bail, target selection, rotation write, the timer >= 20/cps gate and the shouldMiss computation (line 400: neededYaw outside the 60 - distance*10 interval, newTarget under 70ms, or AutoPot potting forces a swing-only tick). Multi mode (line 236) aims at loaded.get(0) and then iterates the whole list firing EventAttack, a C02PacketUseEntity ATTACK and attackTargetEntityWithCurrentItem per entity; the swing-only miss path still calls mc.thePlayer.swingItem() so the client animation is never empty. Switch mode re-rolls the target list every 400/500ms via switchTimer, and Multi2 cycles an index every attack tick. The blockTarget section (line 410) keeps the sword parked across ticks with itemInUseCount = 999 and dispatches block()/unBlock() by autoblock flavor, while the post branch (line 436) repeats the hit gate for TYPE=Post.

The helper block is the packet layer: hitEntity unblocks then swings and calls playerController.attackEntity (vanilla local damage path) before re-blocking; block() emits the C02+Vec3 / C02 INTERACT / C08 sequence; blockHypixel() emits C08 with PlayerUtil.getHypixelBlockpos(username) and facing 255; unBlock() emits C07 RELEASE_USE_ITEM at BlockPos.ORIGIN. getTargets/sortList rank by distance, FOV angle, absolute yaw difference, health or armor, and miniCrit (line 474) rewrites EventUpdate Y/onGround with the 0.0625/0.0626/0.0628 offset cycle, gated by groundTicks and the moveMods (Bhop/LongJump/Fly) enabled check.

source RotationUtils.java (aim math)

RotationUtils.java197 lines · JavaOriginal ↗
1
package info.sigmaclient.util;
2
3
import info.sigmaclient.util.misc.ChatUtil;
4
5
import java.util.List;
6
import java.util.Objects;
7
8
import net.minecraft.client.Minecraft;
9
import net.minecraft.entity.Entity;
10
import net.minecraft.entity.EntityLivingBase;
11
import net.minecraft.entity.player.EntityPlayer;
12
import net.minecraft.util.AxisAlignedBB;
13
import net.minecraft.util.MathHelper;
14
import net.minecraft.util.Vec3;
15
16
public class RotationUtils {
17
	static Minecraft mc = Minecraft.getMinecraft();
18
    public static float[] getRotations(EntityLivingBase ent) {
19
        double x = ent.posX;
20
        double z = ent.posZ;
21
        double y = ent.posY + ent.getEyeHeight() / 2.0F;
22
        return getRotationFromPosition(x, z, y);
23
    }
24
    public static float[] getPredictedRotations(EntityLivingBase ent) {
25
        double x = ent.posX + (ent.posX - ent.lastTickPosX);
26
        double z = ent.posZ + (ent.posZ - ent.lastTickPosZ);
27
        double y = ent.posY + ent.getEyeHeight() / 2.0F;
28
        return getRotationFromPosition(x, z, y);
29
    }
30
    public static float[] getAverageRotations(List<EntityLivingBase> targetList) {
31
        double posX = 0.0D;
32
        double posY = 0.0D;
33
        double posZ = 0.0D;
34
        for (Entity ent : targetList) {
35
            posX += ent.posX;
36
            posY += ent.boundingBox.maxY - 2.0D;
37
            posZ += ent.posZ;
38
        }
39
        posX /= targetList.size();
40
        posY /= targetList.size();
41
        posZ /= targetList.size();
42
43
        return new float[]{getRotationFromPosition(posX, posZ, posY)[0], getRotationFromPosition(posX, posZ, posY)[1]};
44
    }
45
    public static float getStraitYaw(){
46
    	float YAW = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw);
47
    	if(YAW < 45 && YAW > -45){
48
			YAW = 0;
49
		}else if(YAW > 45 && YAW < 135){
50
			YAW = 90f;
51
		}else if(YAW > 135 || YAW < -135){
52
			YAW = 180;
53
		}else{
54
			YAW = -90f;
55
		}	 
56
    	return YAW;
57
    }
58
    public static float[] getBowAngles(final Entity entity) {
59
        final double xDelta = (entity.posX - entity.lastTickPosX) * 0.4;
60
        final double zDelta = (entity.posZ - entity.lastTickPosZ) * 0.4;
61
        double d = Minecraft.getMinecraft().thePlayer.getDistanceToEntity(entity);
62
        d -= d % 0.8;
63
        double xMulti = 1.0;
64
        double zMulti = 1.0;
65
        final boolean sprint = entity.isSprinting();
66
        xMulti = d / 0.8 * xDelta * (sprint ? 1.25 : 1.0);
67
        zMulti = d / 0.8 * zDelta * (sprint ? 1.25 : 1.0);
68
        final double x = entity.posX + xMulti - Minecraft.getMinecraft().thePlayer.posX;
69
        final double z = entity.posZ + zMulti - Minecraft.getMinecraft().thePlayer.posZ;
70
        final double y = Minecraft.getMinecraft().thePlayer.posY + Minecraft.getMinecraft().thePlayer.getEyeHeight() - (entity.posY + entity.getEyeHeight());
71
        final double dist = Minecraft.getMinecraft().thePlayer.getDistanceToEntity(entity);
72
        final float yaw = (float) Math.toDegrees(Math.atan2(z, x)) - 90.0f;
73
		double d1 = MathHelper.sqrt_double(x * x + z * z);
74
        final float pitch =  (float) - (Math.atan2(y, d1) * 180.0D / Math.PI) + (float)dist*0.11f;
75
        
76
        return new float[]{yaw, -pitch};
77
    }
78
79
    public static float[] getRotationFromPosition(double x, double z, double y) {
80
        double xDiff = x - Minecraft.getMinecraft().thePlayer.posX;
81
        double zDiff = z - Minecraft.getMinecraft().thePlayer.posZ;
82
        double yDiff = y - Minecraft.getMinecraft().thePlayer.posY - 1.2;
83
84
        double dist = MathHelper.sqrt_double(xDiff * xDiff + zDiff * zDiff);
85
        float yaw = (float) (Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D) - 90.0F;
86
        float pitch = (float) -(Math.atan2(yDiff, dist) * 180.0D / 3.141592653589793D);
87
        return new float[]{yaw, pitch};
88
    }
89
90
    public static float getTrajAngleSolutionLow(float d3, float d1, float velocity) {
91
        float g = 0.006F;
92
        float sqrt = velocity * velocity * velocity * velocity - g * (g * (d3 * d3) + 2.0F * d1 * (velocity * velocity));
93
        return (float) Math.toDegrees(Math.atan((velocity * velocity - Math.sqrt(sqrt)) / (g * d3)));
94
    }
95
96
    public static float getYawChange(float yaw, double posX, double posZ) {
97
        double deltaX = posX - Minecraft.getMinecraft().thePlayer.posX;
98
        double deltaZ = posZ - Minecraft.getMinecraft().thePlayer.posZ;
99
        double yawToEntity = 0;
100
        if ((deltaZ < 0.0D) && (deltaX < 0.0D)) {
101
        	if(deltaX != 0)
102
            yawToEntity = 90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
103
        } else if ((deltaZ < 0.0D) && (deltaX > 0.0D)) {
104
        	if(deltaX != 0)
105
            yawToEntity = -90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
106
        } else {
107
        	if(deltaZ != 0)
108
            yawToEntity = Math.toDegrees(-Math.atan(deltaX / deltaZ));
109
        }
110
111
        return MathHelper.wrapAngleTo180_float(-(yaw- (float) yawToEntity));
112
    }
113
114
    public static float getPitchChange(float pitch, Entity entity, double posY) {
115
        double deltaX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
116
        double deltaZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
117
        double deltaY = posY - 2.2D + entity.getEyeHeight() - Minecraft.getMinecraft().thePlayer.posY;
118
        double distanceXZ = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
119
        double pitchToEntity = -Math.toDegrees(Math.atan(deltaY / distanceXZ));
120
        return -MathHelper.wrapAngleTo180_float(pitch - (float) pitchToEntity) - 2.5F;
121
    }
122
123
124
    public static float getNewAngle(float angle) {
125
        angle %= 360.0F;
126
        if (angle >= 180.0F) {
127
            angle -= 360.0F;
128
        }
129
        if (angle < -180.0F) {
130
            angle += 360.0F;
131
        }
132
        return angle;
133
    }
134
135
    public static boolean canEntityBeSeen(Entity e){
136
    	Vec3 vec1 = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.getEyeHeight(),mc.thePlayer.posZ);
137
138
    	AxisAlignedBB box = e.getEntityBoundingBox();
139
        Vec3 vec2 = new Vec3(e.posX, e.posY + (e.getEyeHeight()/1.32F),e.posZ);	
140
        double minx = e.posX - 0.25;
141
        double maxx = e.posX + 0.25;
142
        double miny = e.posY;
143
        double maxy = e.posY + Math.abs(e.posY - box.maxY) ;
144
        double minz = e.posZ - 0.25;
145
        double maxz = e.posZ + 0.25;
146
        boolean see =  mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
147
	    if(see)
148
	    	return true;
149
	    vec2 = new Vec3(maxx,miny,minz);	
150
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
151
	    if(see)
152
	    	return true;
153
	    vec2 = new Vec3(minx,miny,minz);	
154
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
155
	  
156
	    if(see)
157
	    	return true;
158
	    vec2 = new Vec3(minx,miny,maxz);	
159
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
160
	    if(see)
161
	    	return true;
162
	    vec2 = new Vec3(maxx,miny,maxz);	
163
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
164
	    if(see)
165
	    	return true;
166
	    
167
	    vec2 = new Vec3(maxx, maxy,minz);	
168
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
169
	  
170
	    if(see)
171
	    	return true;
172
	    vec2 = new Vec3(minx, maxy,minz);	
173
	
174
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
175
	    if(see)
176
	    	return true;
177
	    vec2 = new Vec3(minx, maxy,maxz - 0.1);	
178
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
179
	    if(see)
180
	    	return true;
181
	    vec2 = new Vec3(maxx, maxy,maxz);	
182
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
183
	    if(see)
184
	    	return true;
185
	    
186
	
187
    	return false;
188
    }
189
    public static float getDistanceBetweenAngles(float angle1, float angle2) {
190
        float angle = Math.abs(angle1 - angle2) % 360.0F;
191
        if (angle > 180.0F) {
192
            angle = 360.0F - angle;
193
        }
194
        return angle;
195
    }
196
}

What this file does

This is the geometric core every rotation mode funnels through. getRotations aims at ent.posY + ent.getEyeHeight() / 2.0F, i.e. the vertical aim point is only half an eye-height above the target's feet, and getRotationFromPosition subtracts a hardcoded 1.2 from the player's Y before the atan2, so the pitch the module writes is consistently biased low relative to a true eye-line -- a constant, machine-like offset in the server-visible rotation. getPredictedRotations adds one tick of velocity (posX + (posX - lastTickPosX)) on x/z, which is exactly what the Predict mode writes into the movement packet. getYawChange and getPitchChange return the wrapped delta between the current look and the entity (getPitchChange carries the same -2.5 degree bias used by getCustomRotsChange), and these deltas are what Smooth (yaw/1.7) and Legit (customRots easing) consume each tick. canEntityBeSeen is the ray-cast the WALLS setting consults, and getDistanceBetweenAngles powers the FOV target sort. Because the same file is shared by the aim-assist and bow modules, its methods are the canonical aim vector source for the whole client.

source Timer.java (tick-rate gate)

Timer.java31 lines · JavaOriginal ↗
1
package info.sigmaclient.util;
2
3
public class Timer {
4
5
    private long prevMS;
6
7
    public Timer() {
8
        this.prevMS = 0L;
9
    }
10
11
    public boolean delay(float milliSec) {
12
        return (float) (getTime() - this.prevMS) >= milliSec;
13
    }
14
15
    public void reset() {
16
        this.prevMS = getTime();
17
    }
18
19
    public long getTime() {
20
        return System.nanoTime() / 1000000L;
21
    }
22
23
    public long getDifference() {
24
        return getTime() - this.prevMS;
25
    }
26
27
    public void setDifference(long difference) {
28
        this.prevMS = (getTime() - difference);
29
    }
30
31
}

What this file does

A 26-line millisecond stopwatch: delay(float milliSec) returns true once getTime() - prevMS reaches the argument and reset() re-anchors prevMS, with getTime() reading System.nanoTime() / 1e6 so it is monotonic rather than wall-clock. Killaura instantiates four of these: switchTimer drives the Switch mode cooldown (400ms, 500ms in Smooth rotation), newTarget enforces the 70ms grace after a target change that forces shouldMiss, lastStep is reset by the post EventStep to time the Minis critical offset, and rtimer is unused legacy. The module deliberately does not use this timer for the attack rate -- the cps gate is the EventUpdate tick counter (timer >= 20/cps), which is why the aura's attack interval is tied to game ticks rather than real milliseconds and stays exactly in phase with the movement packets.

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 FightHitbox (combat hitbox ray trace)

FightHitbox.java232 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.combat;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.Cancelless;
23
import me.islandscout.hawk.check.CustomCheck;
24
import me.islandscout.hawk.event.Event;
25
import me.islandscout.hawk.event.InteractEntityEvent;
26
import me.islandscout.hawk.event.MoveEvent;
27
import me.islandscout.hawk.util.*;
28
import me.islandscout.hawk.wrap.block.WrappedBlock;
29
import me.islandscout.hawk.wrap.entity.WrappedEntity;
30
import org.bukkit.GameMode;
31
import org.bukkit.Location;
32
import org.bukkit.Material;
33
import org.bukkit.block.Block;
34
import org.bukkit.entity.Entity;
35
import org.bukkit.entity.Player;
36
import org.bukkit.util.BlockIterator;
37
import org.bukkit.util.Vector;
38
39
import java.util.HashMap;
40
import java.util.Map;
41
import java.util.UUID;
42
43
/**
44
 * The hit detection in Minecraft is mostly determined by the client,
45
 * thus servers are left to trust the client. (There are a few exceptions
46
 * for the unmodified Notchian server such as preventing hits exceeding 6
47
 * blocks from the target entity). This poses a problem for players and
48
 * server owners since players can modify the client to manipulate hit
49
 * detection and allow for cheating when in combat with other players.
50
 *
51
 * Hawk’s hitbox checking aims to detect cheating during player vs.
52
 * player combat by validating hits on the server. When the server
53
 * receives an interaction packet from the client, Hawk gets the client’s
54
 * last known position and next direction, and uses it to perform a ray
55
 * trace test on the victim’s hitbox. Before the ray-trace test begins,
56
 * though, Hawk must factor in latency by rewinding the victim’s hitbox
57
 * to an appropriate time based on the client’s ping latency. To
58
 * accomplish this, Hawk keeps a history of players’ positions and
59
 * timestamps in a table and it retrieves a position that best
60
 * approximates where it appeared to the client when the client attacked
61
 * it. Hawk then performs the ray-trace test to determine whether the
62
 * client landed the hit or not. Although the system may produce false
63
 * positives with clients on unstable connections, it is a fair tradeoff
64
 * between user experience and cheat prevention.
65
 *
66
 * There are other sources of error which will probably not be accounted
67
 * for in Hawk anytime soon. Other sources of error include:
68
 *   - The client receives entity relative moves in 1/32 block precision.
69
 *   - The client holds off one tick to smoothly animate other players
70
 *     on the screen in the case of slight network jitter. It will
71
 *     linearly interpolate from the last position to the latest
72
 *     position up to 3 ticks if it doesn't receive a relative move
73
 *     packet to update the player's position.
74
 *   - The client will predict the motion of some entities, such as
75
 *     arrows. If there is latency and something unexpected happens
76
 *     to the entity, the client may desynchronize from the server.
77
 *
78
 * In most cases, the client uses the current frame's yaw and pitch to
79
 * compute the direction vector for the attack hit-scan. Fortunately,
80
 * ticking and rendering is done in the same thread. Unfortunately, in
81
 * the tick stack, attacking is done before sending yaw/pitch updates
82
 * to the server, which means that we must wait until the next flying
83
 * packet to get the direction of the hit-scan.
84
 *
85
 * For realtime protection, it's best to use the EntityInteractDirection
86
 * check. It actively enforces directions, but it extrapolates the
87
 * yaw/pitch because of how the client hit-scanning works.
88
 */
89
public class FightHitbox extends CustomCheck implements Cancelless {
90
91
    private final double MAX_REACH;
92
    private final int PING_LIMIT;
93
    private final boolean CHECK_OTHER_ENTITIES;
94
    private final boolean LAG_COMPENSATION;
95
    private final boolean DEBUG_HITBOX;
96
    private final boolean DEBUG_RAY;
97
    private final boolean CHECK_OCCLUSION;
98
    private final boolean CHECK_BOX_INTERSECTION;
99
    private final double BOX_EPSILON = 0.005;
100
101
    private Map<UUID, InteractEntityEvent> lastInteractionMap;
102
103
    public FightHitbox() {
104
        super("fighthitbox", false, 5, 10000, 0.95, 5000, "%player% failed combat hitbox. %type% VL: %vl%", null);
105
        CHECK_BOX_INTERSECTION = (boolean) customSetting("checkBoxIntersection", "", true);
106
        CHECK_OCCLUSION = (boolean) customSetting("checkOccluding", "", false);
107
        MAX_REACH = (double) customSetting("maxReach", "", 3.1);
108
        CHECK_OTHER_ENTITIES = (boolean) customSetting("checkOtherEntities", "", false);
109
        LAG_COMPENSATION = (boolean) customSetting("lagCompensation", "", true);
110
        PING_LIMIT = (int) customSetting("pingLimit", "", -1);
111
        DEBUG_HITBOX = (boolean) customSetting("hitbox", "debug", false);
112
        DEBUG_RAY = (boolean) customSetting("ray", "debug", false);
113
        lastInteractionMap = new HashMap<>();
114
    }
115
116
    @Override
117
    protected void check(Event event) {
118
        if(event instanceof InteractEntityEvent)
119
            processHit((InteractEntityEvent)event);
120
        else if(event instanceof MoveEvent) {
121
            InteractEntityEvent interactEntityEvent = lastInteractionMap.get(event.getHawkPlayer().getUuid());
122
            if(interactEntityEvent != null) {
123
                MoveEvent move = (MoveEvent) event;
124
125
                float yaw;
126
                float pitch;
127
                //In 1.8, the yaw of the cursor is behind by one tick.
128
                if(event.getHawkPlayer().getClientVersion() == 8) {
129
                    yaw = event.getHawkPlayer().getYaw();
130
                } else {
131
                    yaw = move.getTo().getYaw();
132
                }
133
                pitch = move.getTo().getPitch();
134
135
                processDirection(interactEntityEvent, yaw, pitch);
136
            }
137
            lastInteractionMap.put(event.getHawkPlayer().getUuid(), null);
138
        }
139
    }
140
141
    private void processHit(InteractEntityEvent e) {
142
        lastInteractionMap.put(e.getHawkPlayer().getUuid(), e);
143
    }
144
145
    private void processDirection(InteractEntityEvent e, float yaw, float pitch) {
146
        Entity entity = e.getEntity();
147
        if (!(entity instanceof Player) && !CHECK_OTHER_ENTITIES)
148
            return;
149
        Player attacker = e.getPlayer();
150
        int ping = ServerUtils.getPing(attacker);
151
        if (ping > PING_LIMIT && PING_LIMIT != -1)
152
            return;
153
154
        HawkPlayer att = e.getHawkPlayer();
155
        Location attackerEyeLocation = att.getPosition().clone().add(new Vector(0, 1.62, 0)).toLocation(att.getWorld());
156
        Vector attackerDirection = MathPlus.getDirection(yaw, pitch);
157
158
        double maxReach = MAX_REACH;
159
        if (attacker.getGameMode() == GameMode.CREATIVE)
160
            maxReach += 1.9;
161
162
        Vector victimLocation;
163
        if (LAG_COMPENSATION)
164
            //No need to add 50ms; the move and attack are already chronologically so close together
165
            victimLocation = hawk.getLagCompensator().getHistoryLocation(ping, e.getEntity()).toVector();
166
        else
167
            victimLocation = e.getEntity().getLocation().toVector();
168
169
        Vector eyePos;
170
        if(e.getHawkPlayer().isInVehicle()) {
171
            eyePos = hawk.getLagCompensator().getHistoryLocation(ping, e.getPlayer()).toVector();
172
            eyePos.setY(eyePos.getY() + e.getPlayer().getEyeHeight());
173
        }
174
        else {
175
            eyePos = new Vector(attackerEyeLocation.getX(), attacker.isSneaking() ? attackerEyeLocation.getY() - 0.08 : attackerEyeLocation.getY(), attackerEyeLocation.getZ());
176
        }
177
        Vector direction = new Vector(attackerDirection.getX(), attackerDirection.getY(), attackerDirection.getZ());
178
        Ray attackerRay = new Ray(eyePos, direction);
179
180
        AABB victimAABB;
181
        victimAABB = WrappedEntity.getWrappedEntity(entity).getHitbox(victimLocation);
182
        victimAABB.expand(BOX_EPSILON, BOX_EPSILON, BOX_EPSILON);
183
184
        Vector intersectVec3d = victimAABB.intersectsRay(attackerRay, 0, Float.MAX_VALUE);
185
186
        if (DEBUG_HITBOX) {
187
            victimAABB.highlight(hawk, attacker.getWorld(), 0.29);
188
        }
189
190
        if (DEBUG_RAY) {
191
            attackerRay.highlight(hawk, attacker.getWorld(), maxReach, 0.1);
192
        }
193
194
        if (intersectVec3d != null) {
195
            Location intersect = new Location(attacker.getWorld(), intersectVec3d.getX(), intersectVec3d.getY(), intersectVec3d.getZ());
196
            double interDistance = intersect.distance(attackerEyeLocation);
197
            if (interDistance > maxReach) {
198
                punish(att, 1, true, e, new Placeholder("type", "Reach: " + MathPlus.round(interDistance, 2) + "m"));
199
                return;
200
            }
201
            if (CHECK_OCCLUSION && interDistance > 1D) {
202
                BlockIterator iter = new BlockIterator(attacker.getWorld(), eyePos, attackerDirection, 0, (int) interDistance + 1);
203
                while (iter.hasNext()) {
204
                    Block bukkitBlock = iter.next();
205
206
                    if (bukkitBlock.getType() == Material.AIR || bukkitBlock.isLiquid())
207
                        continue;
208
209
                    WrappedBlock b = WrappedBlock.getWrappedBlock(bukkitBlock, att.getClientVersion());
210
                    Vector intersection = b.getHitBox().intersectsRay(new Ray(attackerEyeLocation.toVector(), attackerDirection), 0, Float.MAX_VALUE);
211
                    if (intersection != null) {
212
                        if (intersection.distance(eyePos) < interDistance) {
213
                            punish(att, 1, true, e, new Placeholder("type", "Interacted through " + b.getBukkitBlock().getType()));
214
                            return;
215
                        }
216
                    }
217
                }
218
219
            }
220
        } else if (CHECK_BOX_INTERSECTION) {
221
            punish(att, 1, true, e, new Placeholder("type", "Did not hit hitbox."));
222
            return;
223
        }
224
225
        reward(att); //reward player
226
    }
227
228
    @Override
229
    public void removeData(Player p) {
230
        lastInteractionMap.remove(p.getUniqueId());
231
    }
232
}

How it counteracts this module

Hawk's FightHitbox is the reach-and-hitbox check: MAX_REACH defaults to 3.1 (creative adds 1.9), and when a C02 lands the check defers the verdict until the next movement packet, because in 1.8 the yaw used for the hit-scan is one tick older than the attack. processDirection then takes the attacker's eye position (position + 1.62, minus 0.08 when sneaking), builds a ray from the yaw/pitch of that deferred move, fetches the victim's hitbox from the lag compensator at the attacker's ping (getHistoryLocation), expands it by BOX_EPSILON = 0.005, and punishes when the ray-box intersection lies more than maxReach from the eye. Occlusion is optional (CHECK_OCCLUSION defaults false), so wall-hits are only blocked when the server enables it.

Sigma's range setting defaults to 4.5 and tops out at 8, with BLOCKRANGE up to 12, so a default-config hit from 4.5 blocks has an interDistance of ~4.5 against a 3.1 ceiling: every attack in range 3.1-8 flags on the first punish. The Multi and Multi2 modes gain nothing here because each of the per-tick C02s is ray-traced independently. The WALLS=true default bypasses the (off by default) occlusion half of the check but not the reach half: the ray still intersects the victim box through the wall, and the intersection distance is still beyond 3.1. Lag compensation does not save the module either, because both positions are desynced in the same direction -- the victim is rewound to where the client saw it and the attacker eye is near-current.

anticheat AimbotHeuristic (mouse-move pattern analysis)

AimbotHeuristic.java164 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.look;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.CustomCheck;
23
import me.islandscout.hawk.check.Cancelless;
24
import me.islandscout.hawk.event.*;
25
import me.islandscout.hawk.util.Debug;
26
import me.islandscout.hawk.util.MathPlus;
27
import org.bukkit.entity.Player;
28
import org.bukkit.util.Vector;
29
30
import java.util.*;
31
32
/**
33
 * AimbotHeuristic exploits flaws in aim-bot cheats by
34
 * analyzing mouse movement patterns during interaction. Although
35
 * easily bypassed, it catches a significant number of cheaters.
36
 * Caution is advised since this check may false flag during
37
 * certain circumstances. This check should only be used as a
38
 * hint that the player might be cheating.
39
 */
40
public class AimbotHeuristic extends CustomCheck implements Cancelless {
41
42
    private final Map<UUID, List<Vector>> mouseMoves;
43
    private final Map<UUID, List<Long>> clickTimes;
44
45
    private static final int MOVES_PER_SAMPLE = 4; //must be greater than 0
46
    private final int MOVES_AFTER_HIT;
47
    private final boolean DEBUG;
48
49
    public AimbotHeuristic() {
50
        super("aimbotheuristic", false, -1, 5, 0.99, 5000, "&7%player% failed aimbot (heuristic), VL %vl%", null);
51
        mouseMoves = new HashMap<>();
52
        clickTimes = new HashMap<>();
53
54
        MOVES_AFTER_HIT = MOVES_PER_SAMPLE - MOVES_PER_SAMPLE / 2;
55
56
        DEBUG = (boolean) customSetting("debug", "", false);
57
    }
58
59
    public void check(Event e) {
60
        if (e instanceof MoveEvent) {
61
            processMove((MoveEvent) e);
62
        } else if (e instanceof InteractEntityEvent || e instanceof InteractWorldEvent) {
63
            processClick(e);
64
        }
65
    }
66
67
    private void processMove(MoveEvent e) {
68
        Player p = e.getPlayer();
69
        HawkPlayer pp = e.getHawkPlayer();
70
        UUID uuid = p.getUniqueId();
71
72
        List<Vector> lastMoves = mouseMoves.getOrDefault(uuid, new ArrayList<>());
73
        Vector mouseMove = new Vector(e.getTo().getYaw() - e.getFrom().getYaw(), e.getTo().getPitch() - e.getFrom().getPitch(), 0);
74
75
        lastMoves.add(mouseMove);
76
        //make size 1 bigger so that we can get the move before
77
        //the first move that we check
78
        if(lastMoves.size() > MOVES_PER_SAMPLE + 1) {
79
            lastMoves.remove(0);
80
        }
81
        mouseMoves.put(uuid, lastMoves);
82
83
        if(clickedXMovesBefore(MOVES_AFTER_HIT, pp)) {
84
            double minSpeed = Double.MAX_VALUE;
85
            double maxSpeed = 0D;
86
            double maxAngle = 0D;
87
            for(int i = 1; i < lastMoves.size(); i++) {
88
                Vector lastMouseMove = lastMoves.get(i - 1);
89
                Vector currMouseMove = lastMoves.get(i);
90
                double speed = currMouseMove.length();
91
                double lastSpeed = lastMouseMove.length();
92
                double angle = (lastSpeed != 0 && lastSpeed != 0) ? MathPlus.angle(lastMouseMove, currMouseMove) : 0D;
93
                if(Double.isNaN(angle))
94
                    angle = 0D;
95
                maxSpeed = Math.max(speed, maxSpeed);
96
                minSpeed = Math.min(speed, minSpeed);
97
                maxAngle = Math.max(angle, maxAngle);
98
99
                //stutter
100
                if(maxSpeed - minSpeed > 4 && minSpeed < 0.01 && maxAngle < 0.1 && lastSpeed > 1) { //this lastSpeed check eliminates a false positive
101
                    if(DEBUG) {
102
                        p.sendMessage("AimbotHeuristic: A");
103
                    }
104
                    punishEm(pp, e);
105
                }
106
                //twitching or zig zags
107
                else if(speed > 20 && lastSpeed > 20 && angle > 2.86) {
108
                    if(DEBUG) {
109
                        p.sendMessage("AimbotHeuristic: B");
110
                    }
111
                    punishEm(pp, e);
112
                }
113
                //jump discontinuity
114
                else if(speed - lastSpeed < -30 && angle > 0.8) {
115
                    if(DEBUG) {
116
                        p.sendMessage("AimbotHeuristic: C");
117
                    }
118
                    punishEm(pp, e);
119
                }
120
                else {
121
                    reward(pp);
122
                }
123
            }
124
        }
125
    }
126
127
    private boolean clickedXMovesBefore(long x, HawkPlayer pp) {
128
        List<Long> clickTimess = clickTimes.getOrDefault(pp.getUuid(), new ArrayList<>());
129
        long time = pp.getCurrentTick() - x;
130
        for(int i = 0; i < clickTimess.size(); i++) {
131
            if(time == clickTimess.get(i)) {
132
                clickTimess.remove(i);
133
                return true;
134
            }
135
        }
136
        return false;
137
    }
138
139
    private void processClick(Event e) {
140
        UUID uuid = e.getPlayer().getUniqueId();
141
        List<Long> clickTimess = clickTimes.getOrDefault(uuid, new ArrayList<>());
142
        long currTick = e.getHawkPlayer().getCurrentTick();
143
        if(!clickTimess.contains(currTick))
144
            clickTimess.add(e.getHawkPlayer().getCurrentTick());
145
146
        //memory leak fail-safe, if necessary?
147
        for(int i = clickTimess.size() - 1; i >= 0; i--) {
148
            if(currTick - clickTimess.get(i) > MOVES_PER_SAMPLE + 1)
149
                clickTimess.remove(i);
150
        }
151
152
        clickTimes.put(uuid, clickTimess);
153
    }
154
155
    private void punishEm(HawkPlayer pp, MoveEvent e) {
156
        punish(pp, false, e);
157
    }
158
159
    @Override
160
    public void removeData(Player p) {
161
        mouseMoves.remove(p.getUniqueId());
162
        clickTimes.remove(p.getUniqueId());
163
    }
164
}

How it counteracts this module

AimbotHeuristic samples the 4 move packets after each click (MOVES_PER_SAMPLE = 4, MOVES_AFTER_HIT = 2) and scores the per-tick yaw/pitch deltas as 2D vectors. Three signatures punish: a stutter (maxSpeed - minSpeed > 4 with minSpeed < 0.01 and maxAngle < 0.1, i.e. a burst of near-zero rotation followed by a sudden move), a twitch or zigzag (two consecutive moves over 20 degrees each with a turn of more than 2.86 rad), and a jump discontinuity (speed - lastSpeed < -30 with a turn over 0.8 rad, i.e. a huge rotation that stops dead). It is cancelless and only feeds VL, and its own docs call it easily bypassed, but it flags a large fraction of stock auras.

Sigma's Basic mode writes the entire rotation to the movement packet in one tick -- a target behind the player produces a 180-degree snap followed by near-zero moves, which is precisely the jump-discontinuity signature. Smooth eases at yaw/1.7 per tick and Legit's customRots caps |yawFactor| at 7 with the aacB momentum carry, so their per-tick deltas stay bounded, but the stutter branch fires when the cap engages (the carried momentum appears as a stalled move right before the hit). Switch and Multi2 re-pick targets every 400-500ms and flip the yaw sign between opposing targets, feeding the zigzag branch. Because the module always swings on misses too, the click window around every swing is scored, not just the hits.

anticheat Angle (fight.angle multi-target ledger)

Angle.java255 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.fight;
16
17
import java.util.Iterator;
18
import java.util.LinkedList;
19
import java.util.List;
20
import java.util.UUID;
21
22
import org.bukkit.ChatColor;
23
import org.bukkit.Location;
24
import org.bukkit.entity.Entity;
25
import org.bukkit.entity.Player;
26
27
import fr.neatmonster.nocheatplus.actions.ParameterName;
28
import fr.neatmonster.nocheatplus.checks.Check;
29
import fr.neatmonster.nocheatplus.checks.CheckType;
30
import fr.neatmonster.nocheatplus.checks.ViolationData;
31
import fr.neatmonster.nocheatplus.permissions.Permissions;
32
import fr.neatmonster.nocheatplus.players.IPlayerData;
33
import fr.neatmonster.nocheatplus.utilities.StringUtil;
34
import fr.neatmonster.nocheatplus.utilities.TickTask;
35
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
36
37
/**
38
 * A check used to verify if the player isn't using a forcefield in order to attack multiple entities at the same time.
39
 * 
40
 * Thanks @asofold for the original idea!
41
 */
42
public class Angle extends Check {
43
  
44
45
  private final List<String> tags = new LinkedList<String>();
46
47
48
    public static class AttackLocation {
49
        public final double x, y, z;
50
        /** Yaw of the attacker. */
51
        public final float yaw;
52
        public long time;
53
        public final UUID damagedId;
54
        /** Squared distance to the last location (0 if none given). */
55
        public final double distSqLast;
56
        /** Difference in yaw to the last location (0 if none given). */
57
        public final double yawDiffLast;
58
        /** Time difference to the last location (0 if none given). */
59
        public final long timeDiff;
60
        /** If the id differs from the last damaged entity (true if no lastLoc is given). */
61
        public final boolean idDiffLast;
62
        public AttackLocation(final Location loc, final UUID damagedId, final long time, final AttackLocation lastLoc) {
63
            x = loc.getX();
64
            y = loc.getY();
65
            z = loc.getZ();
66
            yaw = loc.getYaw();
67
            this.time = time;
68
            this.damagedId = damagedId;
69
70
            if (lastLoc != null) {
71
                distSqLast = TrigUtil.distanceSquared(x, y, z, lastLoc.x, lastLoc.y, lastLoc.z);
72
                yawDiffLast = TrigUtil.yawDiff(yaw, lastLoc.yaw);
73
                timeDiff = Math.max(0L, time - lastLoc.time);
74
                idDiffLast = !damagedId.equals(lastLoc.damagedId);
75
            } 
76
            else {
77
                distSqLast = 0.0;
78
                yawDiffLast = 0f;
79
                timeDiff = 0L;
80
                idDiffLast = true;
81
            }
82
        }
83
    }
84
    
85
    /** Used to also monitor lag-time */
86
    public static long maxTimeDiff = 1000L;
87
88
89
    /**
90
     * Instantiates a new angle check.
91
     */
92
    public Angle() {
93
        super(CheckType.FIGHT_ANGLE);
94
    }
95
96
97
    /**
98
     * The Angle check.
99
     * @param player
100
     * @param loc Location of the player.
101
     * @param worldChanged
102
     * @param data
103
     * @param cc
104
     * @return
105
     */
106
    public boolean check(final Player player, final Location loc, 
107
                         final Entity damagedEntity, final boolean worldChanged, 
108
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
109
110
        if (worldChanged) {
111
            data.angleHits.clear();
112
        }
113
114
        boolean cancel = false;
115
        tags.clear();
116
117
        // Quick check for expiration of all entries.
118
        final long time = System.currentTimeMillis();
119
        AttackLocation lastLoc = data.angleHits.isEmpty() ? null : data.angleHits.getLast();
120
        if (lastLoc != null && time - lastLoc.time > maxTimeDiff) {
121
            data.angleHits.clear();
122
            lastLoc = null;
123
        }
124
125
        // Add the new location.
126
        data.angleHits.add(new AttackLocation(loc, damagedEntity.getUniqueId(), System.currentTimeMillis(), lastLoc));
127
128
        // Calculate the sums of differences.
129
        double deltaMove = 0D;
130
        long deltaTime = 0L;
131
        float deltaYaw = 0f;
132
        int deltaSwitchTarget = 0;
133
        final Iterator<AttackLocation> it = data.angleHits.iterator();
134
        while (it.hasNext()) {
135
            final AttackLocation refLoc = it.next();
136
            if (time - refLoc.time > maxTimeDiff) {
137
                it.remove();
138
                continue;
139
            }
140
            deltaMove += refLoc.distSqLast;
141
            final double yawDiff = Math.abs(refLoc.yawDiffLast);
142
            deltaYaw += yawDiff;
143
            deltaTime += refLoc.timeDiff;
144
            if (refLoc.idDiffLast && yawDiff > 30.0) {
145
                // TODO: Configurable sensitivity ? Scale with yawDiff?
146
                deltaSwitchTarget += 1;
147
            }
148
        }
149
150
        // Check if there is enough data present.
151
        if (data.angleHits.size() < 2) {
152
            return false;
153
        }
154
155
        final double n = (double) (data.angleHits.size() - 1);
156
157
        // Let's calculate the average move.
158
        double averageMove = deltaMove / n;
159
        // Adjust to server-sided lag
160
        averageMove *= TickTask.getLag(maxTimeDiff, true);
161
162
        // And the average time elapsed.
163
        double averageTime = (double) deltaTime / n;
164
        // Adjust to server-sided lag
165
        averageTime *= TickTask.getLag(maxTimeDiff, true);
166
167
        // And the average yaw delta.
168
        double averageYaw = (double) deltaYaw / n;
169
        // Adjust to server-sided lag
170
        averageYaw /= TickTask.getLag(maxTimeDiff, true);
171
172
        // Average target switching.
173
        double averageSwitching = (double) deltaSwitchTarget / n;
174
        // Adjust to server-sided lag
175
        averageSwitching /= TickTask.getLag(maxTimeDiff, true);
176
177
        // Declare the variables.
178
        double violation = 0.0;
179
        double violationMove = 0.0;
180
        double violationTime = 0.0;
181
        double violationYaw = 0.0;
182
        double violationSwitchSpeed = 0.0;
183
184
        // If the average move is between 0 and 0.2 block(s), add it to the violation.
185
        if (averageMove >= 0.0 && averageMove < 0.2D) {
186
            violationMove += 20.0 * (0.2 - averageMove) / 0.2;
187
            tags.add("avgmove");
188
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
189
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgMove: " + averageMove + " avgMove VL: " + violationMove + "/" + cc.angleMove);
190
            }
191
        }
192
193
        // If the average time elapsed is between 0 and 150 millisecond(s), add it to the violation.
194
        if (averageTime >= 0.0 && averageTime < 150.0) {
195
            violationTime += 30.0 * (150.0 - averageTime) / 150.0;
196
            tags.add("avgtime");
197
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
198
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgTime: " + averageTime + " avgTime VL: " + violationTime + "/" + cc.angleTime);
199
            }
200
        }
201
202
        // If the average difference of yaw is superior to 50 degrees, add it to the violation.
203
        if (averageYaw > 50.0) {
204
            violationYaw += 30.0 * averageYaw / 180.0;
205
            tags.add("avgyaw");
206
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
207
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgYaw: " + averageYaw + " avgYaw VL: " + violationYaw + "/" + cc.angleYaw);
208
            }
209
        }
210
        
211
        // Check for too quick target switch speed
212
        if (averageSwitching > 0.0) {
213
            violationSwitchSpeed += 20.0 * averageSwitching;
214
            tags.add("switchspeed");
215
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
216
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgSwitch: " + averageSwitching + " avgSwitch VL: " + violationSwitchSpeed + "/" + cc.angleSwitch);
217
            }
218
        }
219
220
221
        if (violationMove > cc.angleMove) {
222
            violation = violationMove;
223
            data.angleVL += violation;
224
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
225
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
226
            cancel = executeActions(vd).willCancel();
227
        }
228
        else if (violationTime > cc.angleTime) {
229
            violation = violationTime;
230
            data.angleVL += violation;
231
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
232
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
233
            cancel = executeActions(vd).willCancel();
234
        }
235
        else if (violationYaw > cc.angleYaw) {
236
            violation = violationYaw;
237
            data.angleVL += violation;
238
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
239
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
240
            cancel = executeActions(vd).willCancel();
241
        } 
242
        else if (violationSwitchSpeed > cc.angleSwitch) {
243
            violation = violationSwitchSpeed;
244
            data.angleVL += violation;
245
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
246
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
247
            cancel = executeActions(vd).willCancel();
248
        } 
249
        else {
250
            // Reward the player by lowering their violation level.
251
            data.angleVL *= 0.98D;  
252
        }
253
        return cancel;
254
    }
255
}

How it counteracts this module

NCP's fight Angle check keeps a 1-second ledger (maxTimeDiff = 1000ms) of every attack location and scores four averages over it: average move between consecutive hits (avgmove < 0.2 blocks adds 20 * (0.2 - avgMove) / 0.2), average time between hits (avgtime < 150ms adds 30 * (150 - avgTime) / 150), average yaw change per hit (avgyaw > 50 degrees adds 30 * avgYaw / 180), and target-switch rate (each hit on a different entity whose yaw jumped more than 30 degrees adds 20 * avgSwitching). The largest term over its config threshold (angleMove/angleTime/angleYaw/angleSwitch) fires; otherwise angleVL decays by 0.98. It is the classic forcefield check and its four terms map onto Sigma mode by mode.

Multi mode sends one C02 to every entity in range within the same tick, so consecutive ledger entries have zero movement between them: avgmove sits at 0 and the violationMove term alone is 20 per pair of hits, immediately over the default threshold. At 20 APS the per-tick attacks land 50ms apart, which is under the 150ms avgtime bound and adds 30 * (150 - 50) / 150 = 20 per pair. Switch mode re-picks targets every 400-500ms and Basic rotation snaps the yaw to the new target in one packet, so any two targets more than 30 degrees apart in yaw contribute deltaSwitchTarget entries; a single multi-target fight with standing players scores avgmove + avgtime + switchspeed simultaneously and the check cancels the hits.

anticheat KillAura (fight.killaura direction/reach/speed)

KillAura.java114 lines · Java
1
package me.vrekt.arc.check.combat;
2
3
import me.vrekt.arc.Arc;
4
import me.vrekt.arc.check.Check;
5
import me.vrekt.arc.check.CheckType;
6
import me.vrekt.arc.data.combat.FightData;
7
import me.vrekt.arc.utilties.LocationHelper;
8
import org.bukkit.ChatColor;
9
import org.bukkit.entity.Entity;
10
import org.bukkit.entity.Player;
11
import org.bukkit.util.Vector;
12
13
public class KillAura extends Check {
14
15
    private double maxAngle, maxReach;
16
    private int maxSwingTime, maxAttacks, maxAttackPackets;
17
18
    public KillAura() {
19
        super(CheckType.KILLAURA);
20
21
        maxAngle = Arc.getCheckManager().getValueDouble(CheckType.KILLAURA, "max-direction-angle");
22
        maxSwingTime = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-swing-time");
23
        maxReach = Arc.getCheckManager().getValueDouble(CheckType.KILLAURA, "max-reach");
24
        maxAttacks = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-attacks");
25
        maxAttackPackets = Arc.getCheckManager().getValueInt(CheckType.KILLAURA, "max-attack-packets");
26
27
    }
28
29
    public boolean check(FightData data, Player player) {
30
        result.reset();
31
32
        Entity last = data.getLastAttackedEntity();
33
        Entity entity = data.getAttackedEntity();
34
35
        // Calculate angle stuff.
36
        Vector playerLocation = player.getLocation().toVector();
37
        Vector entityLocation = entity.getLocation().toVector();
38
        double angle = entityLocation.subtract(playerLocation).angle(player.getLocation().getDirection());
39
40
        if (last != null && !entity.equals(last)) {
41
            // check the angle between the two entities
42
            Vector lastLocation = last.getLocation().toVector();
43
            double angleToLast = lastLocation.subtract(playerLocation).angle(player.getLocation().getDirection());
44
            double angleDifference = Math.abs(angleToLast - angle);
45
            double distanceDifference = LocationHelper.distance(last.getLocation(), entity.getLocation());
46
            if (angleDifference > maxAngle && distanceDifference <= maxReach) {
47
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Multi)");
48
                result.set(checkViolation(player, "Angle difference greater than allowed. a=" + angleDifference + " e=" + maxAngle));
49
            }
50
        }
51
52
        // check yaw difference.
53
        if (angle > maxAngle) {
54
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Direction)");
55
            result.set(checkViolation(player, "Angle distance greater than allowed. a=" + angle + " e=" + maxAngle));
56
        }
57
58
        // check swing time.
59
        long time = System.currentTimeMillis() - data.getLastArmSwing();
60
        if (time > maxSwingTime) {
61
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(NoSwing)");
62
            result.set(checkViolation(player, "Player did not swing their arm in time."));
63
        }
64
65
        // distance to entity excluding knockback.
66
        double distance = LocationHelper.distance(player.getLocation(), entity.getLocation().subtract(entity.getVelocity()));
67
        // check for reach
68
        if (distance > maxReach) {
69
            getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Reach)");
70
            result.set(checkViolation(player, "Entity is out of players range. d=" + distance + " e=" + maxReach));
71
        }
72
73
        // check max attacks
74
        if (data.getLastAttackCheck() == 0) {
75
            data.setLastAttackCheck(System.currentTimeMillis());
76
        }
77
        long lastAttack = System.currentTimeMillis() - data.getLastAttackCheck();
78
        if (lastAttack >= 1000) {
79
            // check if we exceeded the max attacks in the last second.
80
            int totalAttacks = data.getTotalAttacks();
81
            if (totalAttacks > maxAttacks) {
82
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Speed)");
83
                result.set(checkViolation(player, "Attacking too fast. a=" + totalAttacks + " e=" + maxAttacks));
84
            }
85
            // reset data for next check.
86
            data.setTotalAttacks(0);
87
            data.setLastAttackCheck(System.currentTimeMillis());
88
        }
89
90
        getCheck().setCheckName("KillAura");
91
        return result.failed();
92
    }
93
94
    public boolean checkFrequency(FightData data, Player player) {
95
        if (data.getLastAttackCheck() == 0) {
96
            data.setLastAttackCheck(System.currentTimeMillis());
97
            return false;
98
        }
99
100
        long time = System.currentTimeMillis() - data.getLastAttackCheck();
101
        if (time >= 1000) {
102
            data.setLastAttackCheck(System.currentTimeMillis());
103
            int totalPackets = data.getAttackPackets();
104
            if (totalPackets > maxAttackPackets) {
105
                data.setAttackPackets(0);
106
                getCheck().setCheckName("Kill Aura " + ChatColor.GRAY + "(Speed)");
107
                return checkViolation(player, "Attacking too fast a=" + totalPackets + " e=" + maxAttackPackets);
108
            }
109
        }
110
111
        return false;
112
    }
113
114
}

How it counteracts this module

Arc v2's KillAura check runs on every combat event with defaults max-direction-angle 1.2 (radians), max-swing-time 80ms, max-reach 4.2, max-attacks 16/s and max-attack-packets 20/s. Direction computes the 3D angle between the server-side look direction and the vector to the attacked entity; Reach measures distance from the player to the entity's position minus its velocity; NoSwing fires when more than 80ms elapsed since the last ARM_ANIMATION (C0A) packet; Speed counts every USE_ENTITY packet (interact and attack alike, incremented in PacketListener for all C02s) against max-attacks per second, and checkFrequency counts ATTACK-action C02s against max-attack-packets.

The Reach default is the sharpest cut for Sigma: range defaults to 4.5 (max 8), so an out-of-the-box 4.5-block hit already exceeds 4.2 and flags, and the setting's whole upper half is unusable under default config. Speed is a close second: at 20 APS the module sends 20 ATTACK C02s per second, right at the max-attack-packets ceiling, and with the INTERACT setting on each block()/hit cycle adds two more C02s (vector interact + INTERACT), so totalAttacks easily exceeds 16/s even at moderate APS. NoSwing and Direction are the two checks the module passes: every hit is preceded by swingItem (C0A arrives within the 80ms window) and the rotation is written into the movement packet that same tick before the C02 is flushed, so the server-side look matches the attack vector. The practical bypass surface is to keep APS at or under 15 and range under 4.2 with INTERACT off -- which is exactly what the default settings are not.

anticheat CombatListener (use-entity pipeline + transaction desync)

CombatListener.java131 lines · Java
1
package ai.idealistic.spartan.listeners.protocol.combat;
2
3
import ai.idealistic.spartan.Register;
4
import ai.idealistic.spartan.abstraction.event.PlayerUseEvent;
5
import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6
import ai.idealistic.spartan.compatibility.necessary.protocollib.BackPlib;
7
import ai.idealistic.spartan.compatibility.necessary.protocollib.EntityUseActionPlib;
8
import ai.idealistic.spartan.functionality.concurrent.CheckThread;
9
import ai.idealistic.spartan.functionality.moderation.AwarenessNotifications;
10
import ai.idealistic.spartan.functionality.server.Config;
11
import ai.idealistic.spartan.functionality.server.PluginBase;
12
import ai.idealistic.spartan.listeners.bukkit.CombatEvent;
13
import ai.idealistic.spartan.utils.java.OverflowMap;
14
import com.comphenix.protocol.PacketType;
15
import com.comphenix.protocol.ProtocolLibrary;
16
import com.comphenix.protocol.events.ListenerPriority;
17
import com.comphenix.protocol.events.PacketAdapter;
18
import com.comphenix.protocol.events.PacketContainer;
19
import com.comphenix.protocol.events.PacketEvent;
20
import com.comphenix.protocol.wrappers.EnumWrappers;
21
import org.bukkit.Bukkit;
22
import org.bukkit.entity.Entity;
23
import org.bukkit.entity.Player;
24
import org.bukkit.event.entity.EntityDamageByEntityEvent;
25
26
import java.util.Map;
27
import java.util.UUID;
28
import java.util.concurrent.ConcurrentHashMap;
29
30
public class CombatListener extends PacketAdapter {
31
32
    private final Map<UUID, Integer> pendingAttacks = new OverflowMap<>(
33
            new ConcurrentHashMap<>(),
34
            1_024
35
    );
36
37
    public CombatListener() {
38
        super(
39
                Register.plugin,
40
                ListenerPriority.HIGHEST,
41
                PacketType.Play.Client.USE_ENTITY,
42
                PacketType.Play.Server.DAMAGE_EVENT
43
        );
44
    }
45
46
    @Override
47
    public void onPacketReceiving(PacketEvent event) {
48
        if (event.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
49
            PlayerProtocol protocol = PluginBase.getProtocol(event.getPlayer());
50
51
            if (!Config.settings.getBoolean("Important.bedrock_on_protocollib")
52
                    && protocol.isBedrockPlayer()) {
53
                return;
54
            }
55
            PacketContainer packet = event.getPacket();
56
            int entityId = BackPlib.getSafeInt(packet, 0);
57
58
            Player target = null;
59
            for (Player player : Bukkit.getOnlinePlayers()) {
60
                if (player.getEntityId() == entityId) {
61
                    target = player;
62
                    break;
63
                }
64
            }
65
            if (packet.getEntityUseActions().size() > 0 ?
66
                    EntityUseActionPlib.getSafeEntityUseActions(packet, 0).equals(EnumWrappers.EntityUseAction.ATTACK)
67
                    : EntityUseActionPlib.getSafeEnumEntityUseActions(packet, 0).getAction().equals(
68
                    EnumWrappers.EntityUseAction.ATTACK)) {
69
                if (protocol.isSDesync()) {
70
                    AwarenessNotifications.optionallySend(protocol.bukkit().getName()
71
                            + " attack faster than the transaction response.");
72
                    //protocol.teleport(protocol.getLocation());
73
                    //event.setCancelled(true);
74
                    //return;
75
                }
76
                if (target != null) {
77
                    Player targetFinal = target;
78
                    CheckThread.run(protocol, () -> CombatEvent.use(
79
                            new PlayerUseEvent(
80
                                    event.getPlayer(),
81
                                    targetFinal,
82
                                    event.isCancelled()
83
                            )
84
                    ));
85
                }
86
                pendingAttacks.put(protocol.getUUID(), entityId);
87
            }
88
        }
89
    }
90
91
    @Override
92
    public void onPacketSending(PacketEvent event) {
93
        if (event.getPacketType() == PacketType.Play.Server.DAMAGE_EVENT) {
94
            PlayerProtocol protocol = PluginBase.getProtocol(event.getPlayer());
95
96
            if (!Config.settings.getBoolean("Important.bedrock_on_protocollib")
97
                    && protocol.isBedrockPlayer()) {
98
                return;
99
            }
100
            int entityId = BackPlib.getSafeInt(event.getPacket(), 0);
101
102
            pendingAttacks.entrySet().removeIf(entry -> {
103
                UUID playerUUID = entry.getKey();
104
                int pendingEntityId = entry.getValue();
105
106
                if (pendingEntityId == entityId) {
107
                    Player attacker = plugin.getServer().getPlayer(playerUUID);
108
                    Entity target = ProtocolLibrary.getProtocolManager().
109
                            getEntityFromID(protocol.getWorld(), entityId);
110
111
                    if (attacker != null && target != null) {
112
                        EntityDamageByEntityEvent event1 = new EntityDamageByEntityEvent(
113
                                attacker,
114
                                target,
115
                                EntityDamageByEntityEvent.DamageCause.ENTITY_ATTACK,
116
                                0.0D
117
                        );
118
                        event1.setCancelled(event.isCancelled());
119
                        CheckThread.run(protocol, () -> CombatEvent.event(
120
                                event1,
121
                                true
122
                        ));
123
                    }
124
                    return true;
125
                }
126
                return false;
127
            });
128
        }
129
    }
130
131
}

How it counteracts this module

In this Spartan snapshot (the ai.idealistic line, CheckEnums wiring the KILL_AURA and HIT_REACH hacks to their check classes), CombatListener is the USE_ENTITY pipeline: onPacketReceiving resolves the target entity id against online players, fires a PlayerUseEvent into the combat checks for every ATTACK action, and records the attack in a pendingAttacks map (an OverflowMap capped at 1024 entries). The map is drained onPacketSending when the server's damage event for that entity arrives, and a pending attack that outlives the matching transaction is flagged through isSDesync() with the message 'attack faster than the transaction response' -- Spartan's rate check is keyed to the transaction echo, not to a fixed APS ceiling.

That transaction anchor is the relevant counter for Sigma's burst shapes. Multi mode emits N C02 attacks in a single tick, and at 20 APS the module sustains 20 attacks per second, while the transaction stream is one server response per tick: bursts of simultaneous C02s cannot each have a distinct transaction predecessor, so the pendingAttacks map accumulates entries that never drain in order, and the desync path reports attacks arriving faster than the transaction responses. The combat event that CombatListener fans out also feeds the hitbox validation (RayUtils.inHitbox ray tests) that the HIT_REACH hack is wired to in CheckEnums, which is where the module's 4.5-8 block default range is caught by the server-side hitbox intersection instead of the client's own claim.

← Back to Analysis Hub