Spicy Killaura module 3 files, 826 lines

Spicy Killaura: Full Source Analysis

Spicy's Killaura is a compact 1.8 combat module driven from a single EventMotion pre handler, with EventRenderGUI reserved for an on-screen target HUD (health bar, HP readout and a rendered entity preview).

info/spicyclient/modules/combat/Killaura.java · GitHub source ↗

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

Analysis

Overview

Spicy's Killaura is a compact 1.8 combat module driven from a single EventMotion pre handler, with EventRenderGUI reserved for an on-screen target HUD (health bar, HP readout and a rendered entity preview). Every tick it rebuilds the candidate list by streaming loadedEntityList through a distance filter and a Players/Animals/Mobs/Everything type filter, keeps the last target in Switch mode until switchTime expires, optionally prunes Hypixel 'watchdog bots' by tab-list responseTime, writes the aim into the outgoing movement packet (lock mode: exact yaw minus 2 degrees plus a triangular pitch oscillation; smooth mode: updateRotation easing capped at 180 degrees per tick), and attacks on a real millisecond timer whose period is 1000 / (APS + a fresh random float), so inter-hit intervals jitter. The attack packet itself is preceded by an arm swing (or a direct C0APacketAnimation when noSwing is set) and followed by client-side critical particles when the Criticals module is on and the player is grounded, and the Hypixel autoblock flavor re-blocks with a sendPacketNoEvent burst of C02 vector-interact, C02 INTERACT and a C08 block placement at BlockPos(-1, -1, -1) with facing 255.

Architecture

The EventMotion pre branch is the whole brain. It first toggles the module off when disableOnDeath and the player is dead, then clears the target and rebuilds the candidate list every tick: loadedEntityList entities that are EntityLivingBase are streamed, sorted by distance, filtered to the range setting (and to alive entities with health > 0 when dontHitDeadEntitys is on), then run through the targetsSetting type filter (players-only, animals-only, mobs-only or everything) via a targetsToRemove pass. When the list is empty the module resets the render rotations (RenderUtils.resetPlayerYaw/Pitch), stops blocking and returns. Otherwise target = targets.get(0), with Switch mode holding lastTarget while it is still in range and only re-picking to targets.get(0) once targetSwitchTimer.hasTimeElapsed(switchTime * 1000). The Hypixel antibot branch removes a targeted player whose netHandler responseTime is greater than 1 (their heuristic for a watchdog bot) and returns. A position-equality guard skips rotation entirely when the target occupies the player's own coordinates, which the source comment says avoids the 'invalid player movement' kick.

Rotation and attack timing

lock mode writes yaw = rotations[0] - 2 every tick and drives pitch with upAndDownPitch, a 20-tick triangular wave: each tick adds 2 + random, below 10 the pitch is rotations[1] - upAndDownPitch, between 10 and 20 it is rotations[1] + 10 - (upAndDownPitch - 10), and at 20 the accumulator resets, with a -90 clamp at the end. The effect is a sawtooth sweep of up to 20 degrees across the target's vertical angle, re-synced every 20 ticks -- a periodic, machine-regular pitch pattern. smooth mode runs customRots: sYaw = updateRotation(lastSmoothYaw, targetYaw, 180) and sPitch likewise, then re-converges with updateRotation(..., 360), clamping pitch to +-90; updateRotation wraps the delta with MathHelper.wrapAngleTo180_float and clamps it to the factor, so the per-tick yaw delta is bounded at 180 degrees but still reaches the target within one or two packets. The attack gate is a Timer, not a tick counter: timer.hasTimeElapsed((long)(1000 / (aps + new Random().nextFloat())), true), so the inter-hit interval at 10 APS averages ~95ms with +-1ms of random dither, and at 20 APS drops to ~48-50ms. hitOnHurtTime returns early while target.hurtTime > 2, and the Sprint module's state is re-asserted with setSprinting(true) both before and after the attack so the server never sees sprint drop mid-combat.

Autoblock packet flow and target HUD

startBlocking is called every tick a target exists and routes by mode: Vanilla uses playerController.sendUseItem (the real use-item path, so the server sees a genuine item-use begin), Hypixel uses blockHypixel, which sends three packets through sendPacketNoEvent (bypassing the event bus): a C02PacketUseEntity with Action.INTERACT and a Vec3 built from RotationUtils.getVectorForRotation(rotations[0], rotations[1]) -- the aim vector itself as the interact point -- a second C02 with Action.INTERACT, and a C08PacketPlayerBlockPlacement at BlockPos(-1, -1, -1) with facing 255 and the held item. The negative-coordinate placement is the classic Hypixel sword-block spoof: the server treats it as blocking without a real block face. Before each attack stopBlocking sends a C07PacketPlayerDigging RELEASE_USE_ITEM at BlockPos.ORIGIN and clears keyBindUseItem.pressed, and onDisable unwinds Hypixel blocking with onStoppedUsingItem inside a try/catch. The EventRenderGUI branch draws the target HUD: a health bar whose position lerps toward the target value at /5 per frame (healthBar += (target - healthBar) / 5), an HSB or rainbowgui-driven color, the target name, an HP line, and a live entity preview via GuiInventory.drawEntityOnScreen.

source Killaura.java (module)

Killaura.java734 lines · JavaOriginal ↗
1
package info.spicyclient.modules.combat;
2
3
import java.awt.Color;
4
import java.text.DecimalFormat;
5
import java.util.Comparator;
6
import java.util.List;
7
import java.util.Random;
8
import java.util.stream.Collectors;
9
10
import org.lwjgl.input.Keyboard;
11
12
import info.spicyclient.SpicyClient;
13
import info.spicyclient.chatCommands.Command;
14
import info.spicyclient.events.Event;
15
import info.spicyclient.events.listeners.EventMotion;
16
import info.spicyclient.events.listeners.EventRenderGUI;
17
import info.spicyclient.events.listeners.EventUpdate;
18
import info.spicyclient.modules.Module;
19
import info.spicyclient.modules.movement.Sprint;
20
import info.spicyclient.settings.BooleanSetting;
21
import info.spicyclient.settings.ModeSetting;
22
import info.spicyclient.settings.NumberSetting;
23
import info.spicyclient.settings.SettingChangeEvent;
24
import info.spicyclient.util.MovementUtils;
25
import info.spicyclient.util.RenderUtils;
26
import info.spicyclient.util.RotationUtils;
27
import info.spicyclient.util.Timer;
28
import net.minecraft.client.Minecraft;
29
import net.minecraft.client.gui.FontRenderer;
30
import net.minecraft.client.gui.Gui;
31
import net.minecraft.client.gui.GuiScreen;
32
import net.minecraft.client.gui.ScaledResolution;
33
import net.minecraft.client.gui.inventory.GuiInventory;
34
import net.minecraft.client.renderer.GlStateManager;
35
import net.minecraft.client.renderer.RenderHelper;
36
import net.minecraft.enchantment.EnchantmentHelper;
37
import net.minecraft.entity.Entity;
38
import net.minecraft.entity.EntityLivingBase;
39
import net.minecraft.entity.monster.EntityMob;
40
import net.minecraft.entity.passive.EntityAnimal;
41
import net.minecraft.entity.player.EntityPlayer;
42
import net.minecraft.item.ItemStack;
43
import net.minecraft.item.ItemSword;
44
import net.minecraft.network.play.client.C02PacketUseEntity;
45
import net.minecraft.network.play.client.C02PacketUseEntity.Action;
46
import net.minecraft.network.play.client.C03PacketPlayer;
47
import net.minecraft.network.play.client.C07PacketPlayerDigging;
48
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
49
import net.minecraft.network.play.client.C0APacketAnimation;
50
import net.minecraft.util.BlockPos;
51
import net.minecraft.util.EnumFacing;
52
import net.minecraft.util.MathHelper;
53
import net.minecraft.util.Vec3;
54
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
55
import net.minecraft.world.World;
56
import net.minecraft.world.WorldSettings;
57
58
public class Killaura extends Module {
59
	
60
	public static EntityLivingBase target = null;
61
	
62
	public NumberSetting range = new NumberSetting("Range", 4, 1, 6, 0.1);
63
	private NumberSetting aps = new NumberSetting("APS", 10, 0, 20, 1);
64
	private BooleanSetting noSwing = new BooleanSetting("NoSwing", false);
65
	private BooleanSetting disableOnDeath = new BooleanSetting("DisableOnDeath", false);
66
	public BooleanSetting dontHitDeadEntitys = new BooleanSetting("Don't hit dead entitys", true);
67
	public ModeSetting targetsSetting = new ModeSetting("Targets", "Players", "Players", "Animals", "Mobs", "Everything");
68
	public ModeSetting rotationSetting = new ModeSetting("Rotation setting", "lock", "lock", "smooth");
69
	public ModeSetting newAutoblock = new ModeSetting("Autoblock mode", "None", "None", "Vanilla", "Hypixel");
70
	public ModeSetting targetingMode = new ModeSetting("Targeting mode", "Single", "Single", "Switch");
71
	public NumberSetting switchTime = new NumberSetting("Switch Time", 2, 0.1, 10, 0.1);
72
	public BooleanSetting hitOnHurtTime = new BooleanSetting("Hit on hurt time", false);
73
	
74
	private static transient boolean blocking = false;
75
	
76
	private static transient float lastSmoothYaw, lastSmoothPitch;
77
	
78
	private static transient double dynamicAPS = 14;
79
	private static transient Timer dynamicAPSTimer = new Timer();
80
	
81
	private int[] randoms = {0,1,0};
82
	public static float sYaw, sPitch, upAndDownPitch = 0;
83
	
84
	public static transient double healthBarTarget = 0, healthBar = 0;
85
	
86
	// These settings are not used anymore but are still here so you can update old configs
87
	private BooleanSetting autoblock = new BooleanSetting("Autoblock", false);
88
	public ModeSetting targetModeSetting = new ModeSetting("Targets", "Players", "Players", "Animals", "Mobs", "Everything");
89
	
90
	public Killaura() {
91
		super("Killaura", Keyboard.KEY_NONE, Category.COMBAT);
92
		resetSettings();
93
	}
94
	
95
	private static Timer targetSwitchTimer = new Timer();
96
	private static EntityLivingBase lastTarget = null;
97
	
98
	@Override
99
	public void resetSettings() {
100
		this.settings.clear();
101
		this.addSettings(range, aps, noSwing, switchTime, disableOnDeath, dontHitDeadEntitys, targetsSetting, newAutoblock, targetingMode, rotationSetting, hitOnHurtTime);
102
	}
103
	
104
	public void onEnable() {
105
		
106
		lastSmoothYaw = mc.thePlayer.rotationYaw;
107
		lastSmoothPitch = mc.thePlayer.rotationPitch;
108
		
109
		healthBar = new ScaledResolution(mc).getScaledWidth() / 2 - 41;
110
		dynamicAPS = aps.getValue();
111
		upAndDownPitch = 0;
112
		
113
	}
114
	
115
	public void onDisable() {
116
		
117
		healthBar = new ScaledResolution(mc).getScaledWidth() / 2 - 41;
118
		RenderUtils.resetPlayerYaw();
119
		RenderUtils.resetPlayerPitch();
120
		
121
        if (mc.thePlayer != null && newAutoblock.is("Hypixel")) {
122
        	try {
123
                if (blocking && newAutoblock.is("Hypixel") && mc.thePlayer.inventory.getCurrentItem().getItem() != null && mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword) {
124
                    mc.gameSettings.keyBindUseItem.pressed = false;
125
                    mc.playerController.onStoppedUsingItem(mc.thePlayer);
126
                }
127
			} catch (NullPointerException e) {
128
				// TODO: handle exception
129
			}
130
        	
131
        }
132
133
	}
134
	
135
	public Timer timer = new Timer();
136
	
137
	@Override
138
	public void onSettingChange(SettingChangeEvent e) {
139
		
140
		if (e.setting != null & e.setting.equals(targetingMode)) {
141
			
142
			if (targetingMode.is("Single") && settings.contains(switchTime)) {
143
				settings.remove(switchTime);
144
				this.settings.sort(Comparator.comparing(s -> s == keycode ? 1 : 0));
145
			}
146
			else if (targetingMode.is("Switch") && !settings.contains(switchTime)) {
147
				settings.add(switchTime);
148
				this.settings.sort(Comparator.comparing(s -> s == keycode ? 1 : 0));
149
			}
150
			
151
		}
152
		
153
	}
154
	
155
	public void onEvent(Event e) {
156
		
157
		// For the target hud
158
		if (e instanceof EventRenderGUI && target != null) {
159
			
160
			if (target == null) {
161
				healthBar = new ScaledResolution(mc).getScaledWidth() / 2 - 41;
162
				return;
163
			}
164
			
165
			ScaledResolution sr = new ScaledResolution(mc);
166
			FontRenderer fr = mc.fontRendererObj;
167
			DecimalFormat dec = new DecimalFormat("#");
168
			
169
			healthBarTarget = sr.getScaledWidth() / 2 - 41 + (((140) / (target.getMaxHealth())) * (target.getHealth()));
170
			
171
			// Lower is faster, higher is slower
172
			double HealthBarSpeed = 5;
173
			
174
			if (healthBar > healthBarTarget) {
175
				healthBar = ((healthBar) - ((healthBar - healthBarTarget) / HealthBarSpeed));
176
			}
177
			else if (healthBar < healthBarTarget) {
178
				//healthBar = healthBarTarget;
179
				healthBar = ((healthBar) + ((healthBarTarget - healthBar) / HealthBarSpeed));
180
			}
181
			//Command.sendPrivateChatMessage(healthBarTarget + " : " + healthBar);
182
			
183
			int color = (target.getHealth() / target.getMaxHealth() > 0.66f) ? 0xff00ff00 : (target.getHealth() / target.getMaxHealth() > 0.33f) ? 0xffff9900 : 0xffff0000;
184
			
185
			color = 0xff00ff00;
186
			
187
			float[] hsb = Color.RGBtoHSB(((int)SpicyClient.config.hud.colorSettingRed.getValue()), ((int)SpicyClient.config.hud.colorSettingGreen.getValue()), ((int)SpicyClient.config.hud.colorSettingBlue.getValue()), null);
188
			float hue = hsb[0];
189
			float saturation = hsb[1];
190
			color = Color.HSBtoRGB(hue, saturation, 1);;
191
			
192
			if (SpicyClient.config.rainbowgui.isEnabled()) {
193
				float hue1 = System.currentTimeMillis() % (int)((100.5f - SpicyClient.config.rainbowgui.speed.getValue()) * 1000) / (float)((100.5f - SpicyClient.config.rainbowgui.speed.getValue()) * 1000);
194
				color = Color.HSBtoRGB(hue1, 0.65f, 1);
195
			}
196
			
197
			Gui.drawRect(sr.getScaledWidth() / 2 - 110, sr.getScaledHeight() / 2 + 100, sr.getScaledWidth() / 2 + 110, sr.getScaledHeight() / 2 + 170, 0xff36393f);
198
			Gui.drawRect(sr.getScaledWidth() / 2 - 41, sr.getScaledHeight() / 2 + 100 + 54, sr.getScaledWidth() / 2 + 100, sr.getScaledHeight() / 2 + 96 + 45, 0xff202225);
199
			Gui.drawRect(sr.getScaledWidth() / 2 - 41, sr.getScaledHeight() / 2 + 100 + 54, healthBar, sr.getScaledHeight() / 2 + 96 + 45, color);
200
			//Gui.drawRect(sr.getScaledWidth() / 2 - 41, sr.getScaledHeight() / 2 + 100 + 54, healthBarTarget, sr.getScaledHeight() / 2 + 96 + 45, color);
201
			
202
			GlStateManager.color(1, 1, 1);
203
			GuiInventory.drawEntityOnScreen(sr.getScaledWidth() / 2 - 75, sr.getScaledHeight() / 2 + 165, 25, 1f, 1f, target);
204
			fr.drawString(target.getName(), sr.getScaledWidth() / 2 - 40, sr.getScaledHeight() / 2 + 110, -1);
205
			fr.drawString("HP: ", sr.getScaledWidth() / 2 - 40, sr.getScaledHeight() / 2 + 125, -1);
206
			fr.drawString("§c❤: §f" + dec.format(target.getHealth()), sr.getScaledWidth() / 2 - 40 + fr.getStringWidth("HP: "), sr.getScaledHeight() / 2 + 125, color);
207
			//fr.drawString(dec.format(target.getMaxHealth()) + "", sr.getScaledWidth() / 2 - 40 + fr.getStringWidth("HP: ") + fr.getStringWidth(dec.format(target.getHealth()) + " / "), sr.getScaledHeight() / 2 + 125, color);
208
			
209
			/*
210
			RenderHelper.enableGUIStandardItemLighting();
211
			mc.getRenderItem().renderItemAndEffectIntoGUI(target.getHeldItem(), sr.getScaledWidth() / 2 - 40, sr.getScaledHeight() / 2 + 143);
212
			mc.getRenderItem().renderItemAndEffectIntoGUI(target.getCurrentArmor(3), sr.getScaledWidth() / 2 - 10, sr.getScaledHeight() / 2 + 143);
213
			mc.getRenderItem().renderItemAndEffectIntoGUI(target.getCurrentArmor(2), sr.getScaledWidth() / 2 + 20, sr.getScaledHeight() / 2 + 143);
214
			mc.getRenderItem().renderItemAndEffectIntoGUI(target.getCurrentArmor(1), sr.getScaledWidth() / 2 + 50, sr.getScaledHeight() / 2 + 143);
215
			mc.getRenderItem().renderItemAndEffectIntoGUI(target.getCurrentArmor(0), sr.getScaledWidth() / 2 + 80, sr.getScaledHeight() / 2 + 143);
216
			*/
217
			
218
			//Gui.drawRect(sr.getScaledWidth() / 2, sr.getScaledHeight() / 2 + 100, sr.getScaledWidth() / 2 + 10, sr.getScaledHeight() / 2 + 150, 0x50000000);
219
			
220
		}
221
		
222
		if (e instanceof EventUpdate) {
223
			
224
			if (e.isPre()) {
225
				
226
				//this.additionalInformation = targetingMode.getMode() + SpicyClient.hud.separator + rotationSetting.getMode();
227
				this.additionalInformation = "R: " + range.getValue() + SpicyClient.hud.separator + "APS: " + aps.getValue();
228
				
229
			}
230
			
231
		}
232
		
233
		if (e instanceof EventMotion) {
234
			
235
			if (e.isPre()) {
236
				
237
				Sprint s = SpicyClient.config.sprint;
238
				
239
				if (mc.thePlayer.isDead && disableOnDeath.isEnabled()) {
240
					
241
					toggled = false;
242
					
243
				}
244
				
245
				target = null;
246
				
247
				EventMotion event = (EventMotion) e;
248
				
249
				List<EntityLivingBase> targets = (List<EntityLivingBase>) mc.theWorld.loadedEntityList.stream().filter(EntityLivingBase.class::isInstance).collect(Collectors.toList());
250
				targets.sort(Comparator.comparingDouble(entity -> ((EntityLivingBase)entity).getDistanceToEntity(mc.thePlayer)));
251
				
252
				List<EntityLivingBase> targetsToRemove = (List<EntityLivingBase>) mc.theWorld.loadedEntityList.stream().filter(EntityLivingBase.class::isInstance).collect(Collectors.toList());
253
				targetsToRemove.clear();
254
				
255
				if (dontHitDeadEntitys.enabled) {
256
					targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.thePlayer) < range.getValue() && entity != mc.thePlayer && !entity.isDead && entity.getHealth() > 0).collect(Collectors.toList());
257
				}else {
258
					targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.thePlayer) < range.getValue() && entity != mc.thePlayer && !entity.isDead).collect(Collectors.toList());
259
				}
260
				
261
				
262
				if (targets.isEmpty()) {
263
					
264
					healthBar = new ScaledResolution(mc).getScaledWidth() / 2 - 41;
265
					stopBlocking();
266
					RenderUtils.resetPlayerYaw();
267
					RenderUtils.resetPlayerPitch();
268
					return;
269
				}
270
				
271
				if (!targets.isEmpty()) {
272
					
273
					for (EntityLivingBase a : targets) {
274
						if (a.getDistanceToEntity(mc.thePlayer) > range.getValue()) {
275
							targetsToRemove.add(a);
276
						}
277
					}
278
					
279
					int target_filter = targetsSetting.index;
280
					
281
					if (target_filter == 0) {
282
						// kill aura will only hit non invisible players
283
						//targets.stream().filter(EntityPlayer.class::isInstance).collect(Collectors.toList());
284
						for (EntityLivingBase a : targets) {
285
							if (a instanceof EntityPlayer) {
286
								
287
							}else {
288
								targetsToRemove.add(a);
289
							}
290
						}
291
					}
292
					else if (target_filter == 1) {
293
						// kill aura will only hit animals
294
						//targets.stream().filter(EntityAnimal.class::isInstance).collect(Collectors.toList());
295
						for (EntityLivingBase a : targets) {
296
							if (a instanceof EntityAnimal) {
297
								
298
							}else {
299
								targetsToRemove.add(a);
300
							}
301
						}
302
					}
303
					else if (target_filter == 2) {
304
						// kill aura will only hit mobs
305
						//targets.stream().filter(EntityMob.class::isInstance).collect(Collectors.toList());
306
						for (EntityLivingBase a : targets) {
307
							if (a instanceof EntityMob) {
308
								
309
							}else {
310
								targetsToRemove.add(a);
311
							}
312
						}
313
					}
314
					else if (target_filter == 3) {
315
						// kill aura will hit everything
316
						
317
					}else {
318
						
319
					}
320
					
321
					targets.removeAll(targetsToRemove);
322
					
323
					if (targets.isEmpty()) {
324
						RenderUtils.resetPlayerYaw();
325
						RenderUtils.resetPlayerPitch();
326
						stopBlocking();
327
						return;
328
					}
329
					
330
					if (newAutoblock.getMode() != "None") {
331
						
332
						startBlocking();
333
						
334
					}
335
					
336
					target = targets.get(0);
337
					
338
					if (target instanceof EntityPlayer && SpicyClient.config.antibot.isEnabled() && !mc.isSingleplayer() && mc.getCurrentServerData().serverIP.toLowerCase().contains("hypixel")) {
339
						
340
	                    try {
341
	                        if (mc.getNetHandler().getPlayerInfo(((EntityPlayer)target).getUniqueID()).responseTime > 1) {
342
	                        	Command.sendPrivateChatMessage("A watchdog bot was removed from your game");
343
	                        	mc.theWorld.removeEntity(target);
344
	                        	return;
345
	                        }
346
						} catch (NullPointerException e1) {
347
							e1.printStackTrace();
348
						}
349
						
350
					}
351
					
352
					if (targetingMode.is("Switch")) {
353
						
354
						if (lastTarget != null && targets.contains(lastTarget)) {
355
							target = lastTarget;
356
							if (targetSwitchTimer.hasTimeElapsed((long) (switchTime.getValue()*1000), true)) {
357
								target = targets.get(0);
358
							}
359
							
360
						}
361
						
362
					}
363
					
364
					if (target != lastTarget) {
365
						/*
366
						Command.sendPrivateChatMessage("F: " + target.getDisplayName().getFormattedText());
367
						Command.sendPrivateChatMessage("U: " + target.getDisplayName().getUnformattedText());
368
						Command.sendPrivateChatMessage("UC: " + target.getDisplayName().getUnformattedTextForChat());
369
						Command.sendPrivateChatMessage("C: " + target.getCustomNameTag());
370
						
371
						if (target instanceof EntityPlayer) {
372
							
373
							Command.sendPrivateChatMessage("Ping: " + mc.getNetHandler().getPlayerInfo(((EntityPlayer)target).getUniqueID()).responseTime);
374
							
375
						}
376
						*/
377
					}
378
					
379
					// if (mc.netHandler.getPlayerInfo(entity.asEntityPlayer().uniqueID)?.responseTime == 0)
380
	                // return true
381
					
382
					lastTarget = target;
383
					
384
					// This mostly removes a bug which would cause you get get kicked for invalid player movement
385
					if (target.posX == mc.thePlayer.posX && target.posY == mc.thePlayer.posY && target.posZ == mc.thePlayer.posZ) {
386
						
387
					}else {
388
						
389
						if (rotationSetting.is("lock") || rotationSetting.getMode() == "lock") {
390
							
391
							//event.setYaw(getRotations(target)[0]+10);
392
							//event.setPitch(RotationUtils.getRotations(target)[1]);
393
							
394
                            float[] rotations = RotationUtils.getRotations(target);
395
                            event.setYaw(rotations[0]);
396
                            event.setYaw(rotations[0] - 2);
397
                            
398
                            if (event.pitch < -90) {
399
                            	event.setPitch(-90);
400
                            }
401
                            
402
                            
403
                            upAndDownPitch += 2 + new Random().nextDouble();
404
                            
405
                            if (upAndDownPitch >= 20) {
406
								upAndDownPitch = 0;
407
								event.setPitch(rotations[1] - upAndDownPitch);
408
							}
409
                            else if (upAndDownPitch >= 10) {
410
                            	event.setPitch(rotations[1] + 10 - (upAndDownPitch - 10));
411
                            }
412
                            else {
413
                            	event.setPitch(rotations[1] - upAndDownPitch);
414
                            }
415
                            
416
                            if (event.pitch < -90) {
417
                            	event.setPitch(-90);
418
                            }
419
                            
420
                            
421
                            //Command.sendPrivateChatMessage(aacB);
422
                            
423
						}
424
						else if (rotationSetting.is("smooth") || rotationSetting.getMode() == "smooth") {
425
							
426
                    		upAndDownPitch/=2;
427
                    		customRots(event, target);
428
                    		
429
							/*
430
							try {
431
								getSmoothRotations(event);
432
							} catch (NullPointerException e2) {
433
								
434
								this.lastSmoothPitch = event.getPitch();
435
								this.lastSmoothYaw = event.getYaw();
436
								
437
								try {
438
									getSmoothRotations(event);
439
								} catch (NullPointerException e3) {
440
									return;
441
								}
442
								
443
							}
444
							*/
445
							
446
						}
447
						
448
						// Put client side rotation code here later
449
						
450
					}
451
					
452
					Random random = new Random();
453
					
454
					startBlocking();
455
					
456
					if (hitOnHurtTime.isEnabled()) {
457
						if (target.hurtTime > 2) {
458
							return;
459
						}
460
					}
461
					
462
					if (timer.hasTimeElapsed((long) (1000/(aps.getValue() + new Random().nextFloat())), true)) {
463
						
464
						if (s.toggled) {
465
							mc.thePlayer.setSprinting(true);
466
						}
467
						
468
						stopBlocking();
469
						
470
						if (noSwing.enabled) {
471
							mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation());
472
						}else {
473
							mc.thePlayer.swingItem();
474
						}
475
						
476
                        mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.ATTACK));
477
                        
478
                        float sharpLevel = EnchantmentHelper.func_152377_a(mc.thePlayer.inventory.getCurrentItem(), target.getCreatureAttribute());
479
                        if (sharpLevel > 0.0F) {
480
                            mc.thePlayer.onEnchantmentCritical(target);
481
                        }
482
                        
483
                        if (SpicyClient.config.criticals.isEnabled() && mc.thePlayer.onGround) {
484
                        	
485
                        	mc.thePlayer.onCriticalHit(target);
486
                        	
487
                        }
488
                        
489
						if (s.toggled) {
490
							mc.thePlayer.setSprinting(true);
491
						}
492
						if (newAutoblock.is("Hypixel") && !blocking) {
493
							
494
							blockHypixel(target);
495
							
496
							//startBlocking(true);
497
							//Random r = new Random();
498
							//mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(new BlockPos(-0.410153517, -0.4083644, -0.4186343), 255, mc.thePlayer.getHeldItem(), 0, 0, 0));
499
						}
500
						
501
						//if (dynamicAPSTimer.hasTimeElapsed(10000 + (new Random().nextInt(10) * 1000), true) && mc.getCurrentServerData().serverIP.toLowerCase().contains("hypixel")) {
502
							//Command.sendPrivateChatMessage("Packet sent");
503
							//mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C03PacketPlayer.C05PacketPlayerLook(0, 0, MovementUtils.isOnGround(0.000001)));
504
						//}
505
						
506
					}
507
					
508
				}else {
509
					
510
					healthBar = new ScaledResolution(mc).getScaledWidth() / 2 - 41;
511
					stopBlocking();
512
					RenderUtils.resetPlayerYaw();
513
					RenderUtils.resetPlayerPitch();
514
					
515
		            return;
516
		            
517
				}
518
				
519
			}
520
			
521
		}
522
		
523
	}
524
	
525
	private void blockHypixel(EntityLivingBase ent) {
526
		
527
		if (ent == null) {
528
			return;
529
		}
530
		
531
		sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getCurrentEquippedItem());
532
		
533
		float[] rotations = RotationUtils.getRotations(target);
534
		mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C02PacketUseEntity(ent, RotationUtils.getVectorForRotation(rotations[0], rotations[1])));
535
		mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C02PacketUseEntity(ent, Action.INTERACT));
536
		mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C08PacketPlayerBlockPlacement(new BlockPos(-1, -1, -1), 255, mc.thePlayer.getHeldItem(), 0, 0, 0));
537
		
538
	}
539
	
540
    public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn)
541
    {
542
        if (mc.playerController.currentGameType == WorldSettings.GameType.SPECTATOR)
543
        {
544
            return false;
545
        }
546
        else
547
        {
548
        	
549
        	if (itemStackIn == null) {
550
        		return false;
551
        	}
552
        	
553
            mc.playerController.syncCurrentPlayItem();
554
            int i = itemStackIn.stackSize;
555
            ItemStack itemstack = itemStackIn.useItemRightClick(worldIn, playerIn);
556
557
            if (itemstack != itemStackIn || itemstack != null && itemstack.stackSize != i)
558
            {
559
                playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = itemstack;
560
561
                if (itemstack.stackSize == 0)
562
                {
563
                    playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
564
                }
565
566
                return true;
567
            }
568
            else
569
            {
570
                return false;
571
            }
572
        }
573
    }
574
    
575
	private void stopBlocking() {
576
		
577
		try {
578
			if (blocking && newAutoblock.is("Hypixel") && mc.thePlayer.inventory.getCurrentItem().getItem() != null && mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword) {
579
	        	
580
	        	mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
581
	            mc.gameSettings.keyBindUseItem.pressed = false;
582
	            
583
	        }
584
		} catch (NullPointerException e) {
585
			blocking = false;
586
		}
587
        
588
        blocking = false;
589
        
590
		return;
591
		
592
	}
593
	
594
	private int interactBlock = 0;
595
	
596
	private void startBlocking() {
597
		
598
		if(newAutoblock.getMode() == "None") {
599
			return;
600
		}
601
		
602
		if (blocking) {
603
			if ((mc.thePlayer.inventory.getCurrentItem() != null) && ((mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword))) {
604
				sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getCurrentEquippedItem());
605
			}
606
			
607
			return;
608
		}
609
		
610
		blocking = true;
611
		
612
        if (newAutoblock.is("Hypixel") && (mc.thePlayer.inventory.getCurrentItem() != null) && ((mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword))) {
613
        	
614
        	blockHypixel(target);
615
        	
616
        	/*
617
        	if (target != null && interactAutoblock) {
618
        		//mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, new Vec3(randomNumber(-50, 50) / 100.0, randomNumber(0, 200) / 100.0, randomNumber(-50, 50) / 100.0)));
619
        		mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.INTERACT));
620
        		mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.INTERACT));
621
        		mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.INTERACT));
622
        		mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.INTERACT));
623
        	}
624
        	
625
        	mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(getHypixelBlockpos(mc.getSession().getUsername()), 255, mc.thePlayer.inventory.getCurrentItem(), 0.0f, 0.0f, 0.0f));
626
        	//mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
627
        	
628
        	mc.thePlayer.setItemInUse(mc.thePlayer.getCurrentEquippedItem(), 10);
629
        	//mc.gameSettings.keyBindUseItem.pressed = true;
630
        	//mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getCurrentEquippedItem());
631
            //mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.inventory.getCurrentItem());
632
             * 
633
             */
634
        }
635
        else if (newAutoblock.is("Vanilla") && (mc.thePlayer.inventory.getCurrentItem() != null) && ((mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword))) {
636
            mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.inventory.getCurrentItem());
637
        }
638
        
639
	}
640
	
641
	// I found these methods on github somewhere
642
    public static int randomNumber(final int max, final int min) {
643
        return Math.round(min + (float)Math.random() * (max - min));
644
    }
645
    
646
    private int randomNumber() {
647
        return -1 + (int) (Math.random() * ((1 - (-1)) + 1));
648
    }
649
    
650
    public float[] getCustomRotsChange(float yaw, float pitch, double x, double y, double z){
651
    	
652
        double xDiff = x - mc.thePlayer.posX;
653
        double zDiff = z - mc.thePlayer.posZ;
654
        double yDiff = y - mc.thePlayer.posY;
655
        
656
        double dist = MathHelper.sqrt_double(xDiff * xDiff + zDiff * zDiff);
657
    	double mult =  (1/(dist+0.0001)) * 2;
658
    	if(mult > 0.2)
659
    		mult = 0.2;
660
    	if(!mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.thePlayer, mc.thePlayer.boundingBox).contains(target)){
661
        	x += 0.3 * randoms[0];
662
        	y -= 0.4 + mult * randoms[1];
663
        	z += 0.3 * randoms[2];
664
    	}
665
    	xDiff = x - mc.thePlayer.posX;
666
        zDiff = z - mc.thePlayer.posZ;
667
        yDiff = y - mc.thePlayer.posY;
668
        float yawToEntity = (float) (Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D) - 90.0F;
669
        float pitchToEntity = (float) -(Math.atan2(yDiff, dist) * 180.0D / 3.141592653589793D);
670
        return new float[]{MathHelper.wrapAngleTo180_float(-(yaw- (float) yawToEntity)), -MathHelper.wrapAngleTo180_float(pitch - (float) pitchToEntity) - 2.5F};
671
    }
672
    
673
    public void customRots(EventMotion em, EntityLivingBase ent) {
674
    	
675
        if (target == null) {
676
        	
677
        	lastSmoothYaw = mc.thePlayer.rotationYaw;
678
        	lastSmoothPitch = mc.thePlayer.rotationPitch;
679
        	
680
        	return;
681
        	
682
        }
683
        
684
        float speed = 180;
685
        
686
        float sYaw = (float) updateRotation((float) lastSmoothYaw, (float) RotationUtils.getRotations(target)[0], speed);
687
		float sPitch = (float) updateRotation((float) lastSmoothPitch, (float) RotationUtils.getRotations(target)[1], speed);
688
		
689
		//Command.sendPrivateChatMessage("Old: " + sYaw + " : " + sPitch);
690
		
691
		//double move = 5;
692
		//move = new Random().nextInt(3) + 1;
693
		
694
		//move += new Random().nextDouble();
695
        //sYaw = (float) updateRotation((float) lastSmoothYaw, (float) RotationUtils.getRotations(target)[0], (float)((lastSmoothYaw - RotationUtils.getRotations(target)[0]) / move));
696
		//sPitch = (float) updateRotation((float) lastSmoothPitch, (float) RotationUtils.getRotations(target)[1], (float)((lastSmoothPitch - RotationUtils.getRotations(target)[1]) / move));
697
		
698
		//Command.sendPrivateChatMessage("New: " + sYaw + " : " + sPitch);
699
		
700
		lastSmoothYaw = updateRotation(lastSmoothYaw, sYaw, 360);
701
		//lastSmoothYaw = sYaw;
702
		lastSmoothPitch = updateRotation(lastSmoothPitch, sPitch, 360);
703
		
704
        if(lastSmoothPitch > 90) {
705
        	lastSmoothPitch = 90;
706
        } else if (lastSmoothPitch < -90) {
707
        	lastSmoothPitch = -90;
708
        }
709
        
710
        //Command.sendPrivateChatMessage("Done: " + sYaw + " : " + sPitch);
711
        //Command.sendPrivateChatMessage("Current: " + sYaw + " : " + sPitch);
712
        //Command.sendPrivateChatMessage("Intended: " + RotationUtils.getRotations(target)[0] + " : " + RotationUtils.getRotations(target)[1]);
713
        //Command.sendPrivateChatMessage(" ");
714
        
715
        em.setYaw(lastSmoothYaw);
716
        em.setPitch(lastSmoothPitch);
717
        
718
    }
719
    
720
	public static float updateRotation(float current, float intended, float factor) {
721
		float var4 = MathHelper.wrapAngleTo180_float(intended - current);
722
723
		if (var4 > factor) {
724
			var4 = factor;
725
		}
726
727
		if (var4 < -factor) {
728
			var4 = -factor;
729
		}
730
731
		return current + var4;
732
	}
733
    
734
}

What this file does

The settings surface is declared as public fields: range (default 4, max 6), aps (default 10, max 20), noSwing, disableOnDeath, dontHitDeadEntitys, targetsSetting, rotationSetting (lock/smooth), newAutoblock (None/Vanilla/Hypixel), targetingMode (Single/Switch), switchTime (0.1-10s), and hitOnHurtTime. onEnable snapshots lastSmoothYaw/Pitch, seeds dynamicAPS and resets the pitch oscillator; onDisable resets the render rotations and unwinds a parked Hypixel block via keyBindUseItem.pressed = false + onStoppedUsingItem in a try/catch. The EventMotion pre branch (line 233) does all targeting: stream filter + distance sort, type filter, Switch-mode lastTarget retention, the Hypixel responseTime > 1 bot removal (which literally calls mc.theWorld.removeEntity on the 'bot'), the position-equality rotation guard, and then the attack block (line 462): stopBlocking, swing (C0A direct when noSwing, else swingItem), the C02 ATTACK, onEnchantmentCritical when sharpness applies, onCriticalHit when the Criticals module is enabled and the player is onGround (client-side particles only, no packet), sprint re-assert, and the Hypixel re-block.

The helpers carry the packet work: blockHypixel (line 525) emits the C02 vector-interact + C02 INTERACT + C08(-1,-1,-1) triple through sendPacketNoEvent; sendUseItem (line 540) replicates the vanilla use-item path (syncCurrentPlayItem + useItemRightClick); startBlocking (line 596) switches on mode and re-sends the use-item while already blocking; stopBlocking (line 575) sends C07 RELEASE_USE_ITEM at BlockPos.ORIGIN; customRots (line 673) and updateRotation (line 720) implement the 180-degree-capped easing. The HUD branch (line 158) lerps the health bar and draws the entity preview. The file also keeps two dead settings (autoblock, targetModeSetting) solely to migrate old configs, and its noSwing path proves the arm-animation packet is always emitted one way or the other.

source RotationUtils.java (aim math)

RotationUtils.java65 lines · JavaOriginal ↗
1
package info.spicyclient.util;
2
3
import info.spicyclient.events.listeners.EventMotion;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.entity.Entity;
6
import net.minecraft.entity.EntityLivingBase;
7
import net.minecraft.util.MathHelper;
8
import net.minecraft.util.Vec3;
9
10
public class RotationUtils {
11
	
12
	// FOUND ON THE OLD SIGMA SOURCE CODE
13
	// here is a link to it https://gitlab.com/Arithmo/Sigma/-/blob/master/info/sigmaclient/util/RotationUtils.java
14
	
15
    public static float getYawChange(double posX, double posZ, float playerYaw, Double playerX, Double playerZ) {
16
        double deltaX = posX - playerX;
17
        double deltaZ = posZ - playerZ;
18
        double yawToEntity;
19
        if ((deltaZ < 0.0D) && (deltaX < 0.0D)) {
20
            yawToEntity = 90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
21
        } else if ((deltaZ < 0.0D) && (deltaX > 0.0D)) {
22
            yawToEntity = -90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
23
        } else {
24
            yawToEntity = Math.toDegrees(-Math.atan(deltaX / deltaZ));
25
        }
26
        return MathHelper.wrapAngleTo180_float(-(playerYaw - (float) yawToEntity));
27
    }
28
29
    public static float getPitchChange(Entity entity, double posY, float playerPitch, Double playerX, Double playerZ) {
30
        double deltaX = entity.posX - playerX;
31
        double deltaZ = entity.posZ - playerZ;
32
        double deltaY = posY - 2.2D + entity.getEyeHeight() - Minecraft.getMinecraft().thePlayer.posY;
33
        double distanceXZ = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
34
        double pitchToEntity = -Math.toDegrees(Math.atan(deltaY / distanceXZ));
35
        return -MathHelper.wrapAngleTo180_float(playerPitch - (float) pitchToEntity) - 2.5F;
36
    }
37
    
38
    public static float[] getRotationFromPosition(double x, double z, double y) {
39
        double xDiff = x - Minecraft.getMinecraft().thePlayer.posX;
40
        double zDiff = z - Minecraft.getMinecraft().thePlayer.posZ;
41
        double yDiff = y - Minecraft.getMinecraft().thePlayer.posY - 1.2;
42
43
        double dist = MathHelper.sqrt_double(xDiff * xDiff + zDiff * zDiff);
44
        float yaw = (float) (Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D) - 90.0F;
45
        float pitch = (float) -(Math.atan2(yDiff, dist) * 180.0D / 3.141592653589793D);
46
        return new float[]{yaw, pitch};
47
    }
48
    
49
    public static float[] getRotations(EntityLivingBase ent) {
50
        double x = ent.posX;
51
        double z = ent.posZ;
52
        double y = ent.posY + (ent.getEyeHeight() / 2.0F);
53
        return getRotationFromPosition(x, z, y);
54
    }
55
    
56
    public static Vec3 getVectorForRotation(float pitch, float yaw)
57
    {
58
        float f = MathHelper.cos(-yaw * 0.017453292F - (float)Math.PI);
59
        float f1 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
60
        float f2 = -MathHelper.cos(-pitch * 0.017453292F);
61
        float f3 = MathHelper.sin(-pitch * 0.017453292F);
62
        return new Vec3((double)(f1 * f2), (double)f3, (double)(f * f2));
63
    }
64
    
65
}

What this file does

This 65-line file is a direct port of old Sigma's RotationUtils -- the source comment says so verbatim ('FOUND ON THE OLD SIGMA SOURCE CODE' with a gitlab link) -- and it exposes exactly the geometry the module consumes. getRotations aims at ent.posY + ent.getEyeHeight() / 2.0F and getRotationFromPosition subtracts a fixed 1.2 from the player's Y, so the pitch is consistently biased low by a constant; getYawChange and getPitchChange return wrapped deltas with the same -2.5 degree bias baked into getPitchChange. getVectorForRotation is the standout: it converts a (pitch, yaw) pair into the unit Vec3 (sin/cos composition with -pitch * 0.017453292 radian scaling), which blockHypixel uses as the interact-point vector of the first C02 in its blocking burst -- the server receives an interact aimed exactly along the module's own aim line. Because the module shares this one file with its other combat modules, the same biased aim math shows up in every rotation-based feature, and the per-tick deltas the smooth/lock modes write to movement packets are all derived from this file's atan2 composition.

source Timer.java (attack-rate gate)

Timer.java27 lines · JavaOriginal ↗
1
package info.spicyclient.util;
2
3
public class Timer {
4
	
5
	public long lastMS = System.currentTimeMillis();;
6
	
7
	public void reset() {
8
		lastMS = System.currentTimeMillis();
9
	}
10
	
11
	public boolean hasTimeElapsed(long time, boolean reset) {
12
		
13
		if (System.currentTimeMillis()-lastMS > time) {
14
			
15
			if (reset)
16
				reset();
17
			
18
			return true;
19
				
20
			
21
		}else {
22
			return false;
23
		}
24
		
25
	}
26
	
27
}

What this file does

A 27-line stopwatch: hasTimeElapsed(long time, boolean reset) returns true once System.currentTimeMillis() - lastMS exceeds the argument, optionally re-anchoring lastMS. Killaura uses two instances. The attack gate timer is polled every EventMotion pre tick with 1000 / (aps + new Random().nextFloat()) -- the per-call random float means the period itself jitters by up to 1ms per roll, so the inter-attack intervals at any fixed APS are not perfectly uniform (at 10 APS ~95ms nominal, at 20 APS ~48ms). The static targetSwitchTimer gates Switch-mode re-picking with switchTime * 1000. Because the gate is wall-clock and not tick-synchronized, the attack cadence drifts relative to the 50ms tick grid, which is the one timing fingerprint that distinguishes this module from tick-locked auras -- at 20 APS it can fire two attacks in adjacent ticks during a drift, which is what the per-second attack counters in anticheats catch.

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 EntityInteractReach (interact reach)

EntityInteractReach.java88 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.interaction.entity;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.EntityInteractionCheck;
23
import me.islandscout.hawk.event.InteractEntityEvent;
24
import me.islandscout.hawk.util.*;
25
import me.islandscout.hawk.wrap.entity.WrappedEntity;
26
import org.bukkit.GameMode;
27
import org.bukkit.Location;
28
import org.bukkit.entity.Entity;
29
import org.bukkit.entity.Player;
30
import org.bukkit.util.Vector;
31
32
public class EntityInteractReach extends EntityInteractionCheck {
33
34
    //PASSED (6/24/2019)
35
36
    private final double MAX_REACH;
37
    private final double MAX_REACH_CREATIVE;
38
    private final int PING_LIMIT;
39
    private final boolean LAG_COMPENSATION;
40
    private final boolean CHECK_OTHER_ENTITIES;
41
42
    public EntityInteractReach() {
43
        super("entityinteractreach", "%player% failed entity interact reach. Reach: %distance%m VL: %vl%");
44
        MAX_REACH = (double) customSetting("maxReach", "", 3.1);
45
        MAX_REACH_CREATIVE = (double) customSetting("maxReachCreative", "", 5.0);
46
        PING_LIMIT = (int) customSetting("pingLimit", "", -1);
47
        LAG_COMPENSATION = (boolean) customSetting("lagCompensation", "", true);
48
        CHECK_OTHER_ENTITIES = (boolean) customSetting("checkOtherEntities", "", false);
49
    }
50
51
    @Override
52
    protected void check(InteractEntityEvent e) {
53
        Entity victimEntity = e.getEntity();
54
        if (!(victimEntity instanceof Player) && !CHECK_OTHER_ENTITIES)
55
            return;
56
        int ping = ServerUtils.getPing(e.getPlayer());
57
        if (PING_LIMIT > -1 && ping > PING_LIMIT)
58
            return;
59
        Player p = e.getPlayer();
60
        HawkPlayer att = e.getHawkPlayer();
61
62
        Location victimLocation;
63
        if (LAG_COMPENSATION)
64
            victimLocation = hawk.getLagCompensator().getHistoryLocation(ping, victimEntity);
65
        else
66
            victimLocation = victimEntity.getLocation();
67
68
        AABB victimAABB = WrappedEntity.getWrappedEntity(victimEntity).getHitbox(victimLocation.toVector());
69
70
        Vector attackerPos;
71
        if(att.isInVehicle()) {
72
            attackerPos = hawk.getLagCompensator().getHistoryLocation(ServerUtils.getPing(p), p).toVector();
73
            attackerPos.setY(attackerPos.getY() + p.getEyeHeight());
74
        }
75
        else {
76
            attackerPos = att.getHeadPosition();
77
        }
78
79
        double maxReach = att.getPlayer().getGameMode() == GameMode.CREATIVE ? MAX_REACH_CREATIVE : MAX_REACH;
80
        double dist = victimAABB.distanceToPosition(attackerPos);
81
82
        if (dist > maxReach) {
83
            punish(att, 1, true, e, new Placeholder("distance", MathPlus.round(dist, 2)));
84
        } else {
85
            reward(att);
86
        }
87
    }
88
}

How it counteracts this module

Hawk's EntityInteractReach validates every entity-interaction packet (C02 with INTERACT or ATTACK) by measuring the distance from the attacker's head position to the victim's hitbox, lag-compensated to the attacker's ping, with MAX_REACH 3.1 and MAX_REACH_CREATIVE 5.0 (set in the constructor, both overrideable). The victim AABB comes from WrappedEntity.getWrappedEntity().getHitbox(victimLocation) and the attacker point from att.getHeadPosition(); a distance over the ceiling punishes, otherwise it rewards. It deliberately does not ray trace -- it is a pure distance-to-box check, which makes it the harshest possible form of reach enforcement for interact-heavy auras.

Spicy's Hypixel autoblock is a direct target: every blocking cycle emits two C02 packets against the target (the vector INTERACT from blockHypixel and the plain INTERACT), and at the module's range setting of 4-6 (default 4) every one of those interacts sits beyond 3.1 and flags, so simply having Hypixel autoblock enabled turns the module into a reach violation generator regardless of the attack rate. Plain attacks in the 3.2-6 range band flag identically. The bypass is to keep range at or under 3.1 and drop Hypixel autoblock -- both of which gut the module's purpose, since its own range ceiling of 6 exists precisely to hit from outside normal reach.

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 window (maxTimeDiff = 1000ms) of attack locations and scores four averages over the window: avgmove (average distance between consecutive hits; below 0.2 blocks adds 20 * (0.2 - avgMove) / 0.2), avgtime (below 150ms adds 30 * (150 - avgTime) / 150), avgyaw (above 50 degrees adds 30 * avgYaw / 180) and switchspeed (each hit on a different entity with a yaw jump over 30 degrees adds 20 * avgSwitching). The largest term over its threshold fires; otherwise the VL decays by 0.98. The ledger is cleared whenever an entry ages out, so a player must sustain the pattern, not just spike once.

Spicy's Switch mode re-picks targets on a real-time timer (switchTime default 2s, minimum 0.1s) and lock mode snaps the yaw to the new target in one movement packet, so with two targets more than 30 degrees apart and a short switchTime the ledger fills with idDiffLast entries carrying yawDiffLast over 30 -- the switchspeed term runs at 20 per switch. Standing fights feed avgmove (attacks with no translation between hits) and the APS ceiling of 20 keeps hits ~50ms apart, so avgtime sits at a third of the 150ms bound and contributes ~20 per pair. At 20 APS + 0.1s switchTime all four terms accumulate simultaneously and the check cancels the hits before the window even fills. The mitigation that passes is the module's own default posture: 10 APS and 2s switching keeps avgtime near the bound and switchspeed sparse.

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 per 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. The Speed path is the one that sees Spicy immediately: PacketListener increments totalAttacks for every USE_ENTITY packet regardless of action, and only ATTACK-action C02s increment attackPackets (checked by checkFrequency). Spicy's Hypixel autoblock emits three C02s per blocking cycle (vector INTERACT + INTERACT + ATTACK), so even at the default 10 APS the totalAttacks rate runs ~30/s against the 16/s ceiling -- the module trips (Speed) at default settings the moment a Hypixel blocking fight starts, before any reach argument matters. At 20 APS the ATTACK-only stream alone sits at the 20/s max-attack-packets ceiling. Reach is the second term: the range setting climbs to 6 against max-reach 4.2, so hits beyond 4.2 flag. Direction and NoSwing are the passes: lock mode's -2 degree yaw offset and the upAndDownPitch sweep (bounded at 20 degrees) stay inside the 1.2-radian direction window, and the noSwing option still emits the C0A arm-animation packet, which is what feeds data.lastArmSwing within the 80ms window. The working bypass -- low APS, Hypixel autoblock off, range under 4.2 -- is the reverse of the module's defaults.

anticheat Reach (combat.reach with interpolation)

Reach.java404 lines · Java
1
// This file was designed and is an original check for GrimAC
2
// Copyright (C) 2021 DefineOutside
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
package ac.grim.grimac.checks.impl.combat;
17
18
import ac.grim.grimac.api.config.ConfigManager;
19
import ac.grim.grimac.api.storage.verbose.Verbose;
20
import ac.grim.grimac.checks.Check;
21
import ac.grim.grimac.checks.CheckData;
22
import ac.grim.grimac.checks.type.PacketReceiveListener;
23
import ac.grim.grimac.player.GrimPlayer;
24
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
25
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
26
import ac.grim.grimac.utils.data.packetentity.PacketEntitySizeable;
27
import ac.grim.grimac.utils.data.packetentity.dragon.PacketEntityEnderDragonPart;
28
import ac.grim.grimac.utils.math.Vector3dm;
29
import ac.grim.grimac.utils.nmsutil.ReachUtils;
30
import ac.grim.grimac.utils.viaversion.ViaVersionUtil;
31
import com.github.retrooper.packetevents.PacketEvents;
32
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
33
import com.github.retrooper.packetevents.manager.server.ServerVersion;
34
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
35
import com.github.retrooper.packetevents.protocol.component.ComponentTypes;
36
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttackRange;
37
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
38
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
39
import com.github.retrooper.packetevents.protocol.item.ItemStack;
40
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
41
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
42
import com.github.retrooper.packetevents.protocol.player.GameMode;
43
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
44
import com.github.retrooper.packetevents.util.Vector3d;
45
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientAttack;
46
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
47
import com.viaversion.viaversion.api.Via;
48
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
49
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
50
import org.jetbrains.annotations.NotNull;
51
52
import java.util.ArrayList;
53
import java.util.Arrays;
54
import java.util.Collections;
55
import java.util.List;
56
57
// You may not copy the check unless you are licensed under GPL
58
@CheckData(name = "Reach", stableKey = "grim.combat.reach", description = "Attacked an entity from too far away")
59
public class Reach extends Check implements PacketReceiveListener {
60
    private static final Verbose V = Verbose.of("{f64:%.5f} blocks, type={entity}");
61
62
    private static final List<EntityType> blacklisted = Arrays.asList(
63
            EntityTypes.BOAT,
64
            EntityTypes.CHEST_BOAT,
65
            EntityTypes.SHULKER);
66
    private static final CheckResult NONE = new CheckResult(ResultType.NONE, 0, 0, false);
67
    // Only one flag per reach attack, per entity, per tick.
68
    // We store position because lastX isn't reliable on teleports.
69
    private final Int2ObjectMap<InteractionData> playerAttackQueue = new Int2ObjectOpenHashMap<>();
70
    private boolean cancelImpossibleHits;
71
    private double threshold;
72
    private double cancelBuffer; // For the next 4 hits after using reach, we aggressively cancel reach
73
74
    public Reach(GrimPlayer player) {
75
        super(player);
76
    }
77
78
    @Override
79
    public void onPacketReceive(final PacketReceiveEvent event) {
80
        if (!player.disableGrim && event.getPacketType() == PacketType.Play.Client.ATTACK) {
81
            WrapperPlayClientAttack packet = new WrapperPlayClientAttack(event);
82
            onInteract(event, packet.getEntityId(), InteractionHand.MAIN_HAND);
83
        }
84
85
        if (!player.disableGrim && event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
86
            WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event);
87
            onInteract(event, packet.getEntityId(), packet.getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK ? InteractionHand.MAIN_HAND : packet.getHand());
88
        }
89
90
        // If the player set their look, or we know they have a new tick
91
        if (isUpdate(event.getPacketType())) {
92
            tickBetterReachCheckWithAngle();
93
        }
94
    }
95
96
    private void onInteract(PacketReceiveEvent event, int entityId, InteractionHand hand) {
97
        // Don't let the player teleport to bypass reach
98
        if (player.getSetbackTeleportUtil().shouldBlockMovement()) {
99
            event.setCancelled(true);
100
            player.onPacketCancel();
101
            return;
102
        }
103
104
        PacketEntity entity = player.compensatedEntities.entityMap.get(entityId);
105
        // Stop people from freezing transactions before an entity spawns to bypass reach
106
        // TODO: implement dragon parts?
107
        if (entity == null || entity instanceof PacketEntityEnderDragonPart) {
108
            // Only cancel if and only if we are tracking this entity
109
            // This is because we don't track paintings.
110
            if (shouldModifyPackets() && player.compensatedEntities.serverPositionsMap.containsKey(entityId)) {
111
                event.setCancelled(true);
112
                player.onPacketCancel();
113
            }
114
            return;
115
        }
116
117
        // Dead entities cause false flags (https://github.com/GrimAnticheat/Grim/issues/546)
118
        if (entity.isDead) return;
119
120
        // TODO: Remove when in front of via
121
        if (entity.getType() == EntityTypes.ARMOR_STAND && player.getClientVersion().isOlderThan(ClientVersion.V_1_8))
122
            return;
123
        // Prevents Happy Ghast Reach false on 1.21.6+ servers with ViaBackwards set up
124
        if (entity.getType() == EntityTypes.HAPPY_GHAST && player.getClientVersion().isOlderThan(ClientVersion.V_1_21_6))
125
            return;
126
        if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
127
            return;
128
        if (player.inVehicle()) return;
129
        if (entity.riding != null) return;
130
131
        ItemStack currentStack = player.inventory.getItemInHand(hand);
132
        ItemStack startStack = player.inventory.getStartOfTickStack();
133
134
        boolean hasRange = false;
135
        float maxReach = 0f;
136
        float hitboxMargin = 0f;
137
        Vector3dm attackRangeMovement = null;
138
139
        boolean clientAttackRangeExists = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_11);
140
        boolean clientAndServerAgrees = clientAttackRangeExists && ATTACK_RANGE_COMPONENT_EXISTS;
141
142
        boolean viaVersionAvailable = false;
143
        if (USE_1_8_HITBOX_MARGIN && ViaVersionUtil.isAvailable) {
144
            viaVersionAvailable = Via.getConfig().getValues().containsKey("use-1_8-hitbox-margin") && Via.getConfig().use1_8HitboxMargin();
145
        }
146
147
        boolean clientAndViaVersion = clientAttackRangeExists && viaVersionAvailable;
148
        if (clientAndServerAgrees || clientAndViaVersion) {
149
            ItemAttackRange startRange = startStack.getComponentOr(ComponentTypes.ATTACK_RANGE, null);
150
            ItemAttackRange currentRange = currentStack.getComponentOr(ComponentTypes.ATTACK_RANGE, null);
151
152
            if (clientAndViaVersion) {
153
                if (startStack != ItemStack.EMPTY) {
154
                    startRange = new ItemAttackRange(0F, 3F, 0F, 4F, 0.1F, 1F);
155
                }
156
157
                if (currentStack != ItemStack.EMPTY) {
158
                    currentRange = new ItemAttackRange(0F, 3F, 0F, 4F, 0.1F, 1F);
159
                }
160
            }
161
162
            // If the start stack has no range component, the client defaults to vanilla reach behavior,
163
            // regardless of what the current stack is (No Range -> X = No Range used).
164
            if (startRange != null) {
165
                hasRange = true;
166
                if (currentRange == null) {
167
                    // Range (Start) -> No Range (Current)
168
                    // Client logic uses Start Range, including the attack_range movement projection.
169
                    if (!clientAndViaVersion) {
170
                        attackRangeMovement = player.clientVelocity.clone();
171
                    }
172
                    maxReach = startRange.getMaxRange();
173
                    hitboxMargin = startRange.getHitboxMargin();
174
                } else {
175
                    // Range (Start) -> Range (Current)
176
                    // Client logic requires satisfying BOTH constraints
177
                    maxReach = Math.min(startRange.getMaxRange(), currentRange.getMaxRange());
178
                    hitboxMargin = Math.min(startRange.getHitboxMargin(), currentRange.getHitboxMargin());
179
                }
180
            }
181
        }
182
183
        boolean tooManyAttacks = playerAttackQueue.size() > 10;
184
        if (!tooManyAttacks) {
185
            playerAttackQueue.put(entityId, new InteractionData(
186
                    player.x, player.y, player.z,
187
                    hasRange, maxReach, hitboxMargin, attackRangeMovement
188
            )); // Queue for next tick for very precise check
189
        }
190
191
        boolean knownInvalid = attackRangeMovement == null && isKnownInvalid(entity, hasRange, maxReach, hitboxMargin);
192
193
        if ((shouldModifyPackets() && cancelImpossibleHits && knownInvalid) || tooManyAttacks) {
194
            event.setCancelled(true);
195
            player.onPacketCancel();
196
        }
197
    }
198
199
    // This method finds the most optimal point at which the user should be aiming at
200
    // and then measures the distance between the player's eyes and this target point
201
    //
202
    // It will not cancel every invalid attack but should cancel 3.05+ or so in real-time
203
    // Let the post look check measure the distance, as it will always return equal or higher
204
    // than this method.  If this method flags, the other method WILL flag.
205
    //
206
    // Meaning that the other check should be the only one that flags.
207
    private boolean isKnownInvalid(PacketEntity reachEntity, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin) {
208
        // If the entity doesn't exist, or if it is exempt, or if it is dead
209
        if ((blacklisted.contains(reachEntity.getType()) || !reachEntity.isLivingEntity) && reachEntity.getType() != EntityTypes.END_CRYSTAL)
210
            return false; // exempt
211
212
        if (player.gamemode == GameMode.CREATIVE || player.gamemode == GameMode.SPECTATOR)
213
            return false;
214
        if (player.inVehicle()) return false;
215
216
        // Filter out what we assume to be cheats
217
        if (cancelBuffer != 0) {
218
            CheckResult result = checkReach(reachEntity, player.x, player.y, player.z, hasAttackRange, itemMaxReach, itemHitboxMargin, null, true);
219
            return result.isFlag();
220
        } else {
221
            SimpleCollisionBox targetBox = getTargetBox(reachEntity);
222
223
            double maxReach = applyReachModifiers(targetBox, hasAttackRange, itemMaxReach, itemHitboxMargin, !player.packetStateData.didLastMovementIncludePosition);
224
            return ReachUtils.getMinReachToBox(player, targetBox) > maxReach;
225
        }
226
    }
227
228
    private void tickBetterReachCheckWithAngle() {
229
        for (Int2ObjectMap.Entry<InteractionData> attack : playerAttackQueue.int2ObjectEntrySet()) {
230
            PacketEntity reachEntity = player.compensatedEntities.entityMap.get(attack.getIntKey());
231
            if (reachEntity == null) continue;
232
233
            InteractionData interactionData = attack.getValue();
234
            CheckResult result = checkReach(reachEntity, interactionData.x, interactionData.y, interactionData.z, interactionData.hasAttackRange, interactionData.maxReach, interactionData.hitboxMargin, interactionData.attackRangeMovement, false);
235
            switch (result.type()) {
236
                case REACH -> flag(
237
                        V.write(verbose()).f64(result.minDistance()).uint(reachEntity.getType().getId(player.getClientVersion())),
238
                        () -> {
239
                            String added = ", type=" + reachEntity.getType().getName().getKey();
240
                            if (reachEntity instanceof PacketEntitySizeable sizeable) {
241
                                added += ", size=" + sizeable.size;
242
                            }
243
                            return result.verbose() + added;
244
                        });
245
                case HITBOX -> {
246
                    String added = "type=" + reachEntity.getType().getName().getKey();
247
                    if (reachEntity instanceof PacketEntitySizeable sizeable) {
248
                        added += ", size=" + sizeable.size;
249
                    }
250
                    player.checkManager.getCheck(Hitboxes.class).flag(result.verbose() + added);
251
                }
252
            }
253
        }
254
255
        playerAttackQueue.clear();
256
    }
257
258
    @NotNull
259
    private CheckResult checkReach(PacketEntity reachEntity, double x, double y, double z, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin, Vector3dm attackRangeMovement, boolean isPrediction) {
260
        SimpleCollisionBox targetBox = getTargetBox(reachEntity);
261
262
        double movementAllowance = attackRangeMovement == null ? 0 : getAttackRangeMovementAllowance(attackRangeMovement);
263
        double maxReach = applyReachModifiers(targetBox, hasAttackRange, itemMaxReach, itemHitboxMargin, !player.packetStateData.didLastLastMovementIncludePosition) + movementAllowance;
264
        double minDistance = Double.MAX_VALUE;
265
266
        // https://bugs.mojang.com/browse/MC-67665
267
        List<Vector3dm> possibleLookDirs = new ArrayList<>(Collections.singletonList(ReachUtils.getLook(player, player.yaw, player.pitch)));
268
269
        // If we are a tick behind, we don't know their next look so don't bother doing this
270
        if (!isPrediction) {
271
            // 1.7 players do not have any of these issues! They are always on the latest look vector
272
            if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8)) {
273
                possibleLookDirs.add(ReachUtils.getLook(player, player.lastYaw, player.pitch));
274
275
                // 1.9+ players could be a tick behind because we don't get skipped ticks
276
                if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) {
277
                    possibleLookDirs.add(ReachUtils.getLook(player, player.lastYaw, player.lastPitch));
278
                }
279
            }
280
        }
281
282
        // +3 would be 3 + 3 = 6, which is the pre-1.20.5 behaviour, preventing "Missed Hitbox"
283
        final double distance = maxReach + 3;
284
285
        final double[] possibleEyeHeights = player.getPossibleEyeHeights();
286
        for (Vector3dm lookVec : possibleLookDirs) {
287
            lookVec.multiply(distance);
288
289
            for (double eye : possibleEyeHeights) {
290
                final Vector3d eyePos = new Vector3d(x, y + eye, z);
291
                Vector3d endReachPos = eyePos.add(lookVec.getX(), lookVec.getY(), lookVec.getZ());
292
293
                Vector3d intercept = ReachUtils.calculateIntercept(targetBox, eyePos, endReachPos).first();
294
295
                if (ReachUtils.isVecInside(targetBox, eyePos)) {
296
                    minDistance = 0;
297
                    break;
298
                }
299
300
                if (intercept != null) {
301
                    minDistance = Math.min(eyePos.distance(intercept), minDistance);
302
                }
303
            }
304
        }
305
306
        // if the entity is not exempt and the entity is alive
307
        if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity) || reachEntity.getType() == EntityTypes.END_CRYSTAL) {
308
            if (minDistance == Double.MAX_VALUE) {
309
                cancelBuffer = 1;
310
                return new CheckResult(ResultType.HITBOX, 0, 0, false);
311
            } else if (minDistance > maxReach) {
312
                cancelBuffer = 1;
313
                return new CheckResult(ResultType.REACH, minDistance, movementAllowance, attackRangeMovement != null);
314
            } else {
315
                cancelBuffer = Math.max(0, cancelBuffer - 0.25);
316
            }
317
        }
318
319
        return NONE;
320
    }
321
322
    private SimpleCollisionBox getTargetBox(PacketEntity reachEntity) {
323
        if (reachEntity.getType() == EntityTypes.END_CRYSTAL) { // Hardcode end crystal box
324
            return new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
325
        }
326
        return reachEntity.getPossibleCollisionBoxes();
327
    }
328
329
    private double getAttackRangeMovementAllowance(Vector3dm attackRangeMovement) {
330
        if (attackRangeMovement.lengthSquared() == 0) {
331
            return 0;
332
        }
333
334
        return getForwardMovement(attackRangeMovement, player.yaw, player.pitch);
335
    }
336
337
    private double getForwardMovement(Vector3dm movement, float yaw, float pitch) {
338
        return Math.max(0, movement.dot(ReachUtils.getLook(player, yaw, pitch)));
339
    }
340
341
    private static final boolean ATTACK_RANGE_COMPONENT_EXISTS = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21_11);
342
    private static final boolean USE_1_8_HITBOX_MARGIN = PacketEvents.getAPI().getServerManager().getVersion().isOlderThanOrEquals(ServerVersion.V_1_8_8);
343
344
    private double applyReachModifiers(SimpleCollisionBox targetBox, boolean hasAttackRange, float itemMaxReach, float itemHitboxMargin, boolean giveMovementThreshold) {
345
        double maxReach;
346
        double hitboxMargin = threshold;
347
348
        if (hasAttackRange) {
349
            maxReach = itemMaxReach;
350
            hitboxMargin += itemHitboxMargin;
351
        } else {
352
            maxReach = player.compensatedEntities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
353
            // 1.7 and 1.8 players get a bit of extra hitbox (this is why you should use 1.8 on cross version servers)
354
            // Yes, this is vanilla and not uncertainty.  All reach checks have this or they are wrong.
355
            if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) {
356
                hitboxMargin += 0.1f;
357
            }
358
        }
359
360
        // This is better than adding to the reach, as 0.03 can cause a player to miss their target
361
        // Adds some more than 0.03 uncertainty in some cases, but a good trade off for simplicity
362
        //
363
        // Just give the uncertainty on 1.9+ clients as we have no way of knowing whether they had 0.03 movement
364
        // However, on 1.21.2+ we do know if they had 0.03 movement
365
        if (giveMovementThreshold || player.canSkipTicks()) {
366
            hitboxMargin += player.getMovementThreshold();
367
        }
368
369
        targetBox.expand(hitboxMargin);
370
371
        return maxReach;
372
    }
373
374
    @Override
375
    public void onReload(@NotNull ConfigManager config) {
376
        this.cancelImpossibleHits = config.getBooleanElse("Reach.block-impossible-hits", true);
377
        this.threshold = config.getDoubleElse("Reach.threshold", 0.0005);
378
    }
379
380
    private enum ResultType {
381
        REACH, HITBOX, NONE
382
    }
383
384
    private record CheckResult(ResultType type, double minDistance, double extraMovement, boolean hasExtraMovement) {
385
        public boolean isFlag() {
386
            return type != ResultType.NONE;
387
        }
388
389
        public String verbose() {
390
            if (type != ResultType.REACH) {
391
                return "";
392
            }
393
394
            String verbose = String.format("%.5f", minDistance) + " blocks";
395
            if (hasExtraMovement) {
396
                verbose += String.format(", extraMovement=%.5f", extraMovement);
397
            }
398
            return verbose;
399
        }
400
    }
401
402
    private record InteractionData(double x, double y, double z, boolean hasAttackRange,
403
                                   float maxReach, float hitboxMargin, Vector3dm attackRangeMovement) {}
404
}

How it counteracts this module

Grim's Reach is the modern reference for this module (Grim targets current versions, but the geometry it enforces is the same server-side reach the 1.8-era checks approximate). It derives maxReach from the entity-interaction attribute (3.0 base) plus a hitbox margin and a movement allowance, builds the victim box from ReachInterpolationData so the target's possible positions between movement packets are all unioned, fires a ray from the eye position along up to four look candidates (current/last yaw and pitch combinations, since the client's hit-scan can precede the rotation packet), and flags when the minimum distance to the box exceeds maxReach; Reach.threshold defaults to 0.0005 and block-impossible-hits cancels impossible rays. CheckManager lines 112/246 show Reach owning the flag with Hitboxes invoked from inside its verdict.

Spicy's range ceiling of 6 with a default of 4 defeats the check outright: any hit past ~3.1 (attribute 3.0 + margin) fails minDistance > maxReach, and because the module writes its rotation into the same tick's movement packet, all four look candidates resolve to the target direction, so there is no angle confusion to hide behind -- the reach term alone fires. The interpolation union also removes the classic latency dodge of attacking the client-side position of a moving target, since the box covers every server-possible location. The only pass path is range 3.0-3.1, which the module's 0.1-step setting can reach, at the cost of giving up its whole advantage.

← Back to Analysis Hub