November Recode 2.0 KillAura module 2 files, 415 lines

November Recode 2.0 KillAura: Full Source Analysis

November's KillAura is a compact combat module driven by a single EventWalkingUpdate subscription with two small support listeners.

feature/module/impl/combat/KillAuraModule.java · GitHub source ↗

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

Analysis

Overview

November's KillAura is a compact combat module driven by a single EventWalkingUpdate subscription with two small support listeners. Every walking tick it re-selects the attack target when the current one is invalid or the mode is SWITCH, streaming the loaded entity list through a comparator chosen by the Sort setting (Distance, Health, HurtTime, Armor), after validTarget rejects dead entities, armor stands, AntiBot-flagged bots and anything outside a range that shrinks to WallRange when the entity cannot be seen. Rotations come from RotationUtils.entity and are spoofed through November's rotation manager at HIGH priority. Attacks fire on the PRE stage of the walking update when the attack timer has elapsed: a swing, then either a direct C02PacketUseEntity ATTACK when KeepSprint is on or the vanilla playerController.attackEntity path otherwise. Six autoblock modes (NONE, FAKE, HOLD, BASIC, VANILLA, WATCHDOG) wrap the attacks in C08 block placements, keybind holds and C07 releases, with the WATCHDOG mode cancelling outgoing C02 attacks while the target is in hurt time.

Target selection and rotation spoofing

The walkingUpdate listener re-runs selection every tick whenever the stored attackTarget fails validTarget or the mode is SWITCH. Selection is a stream over mc.theWorld.loadedEntityList filtered to EntityLivingBase instances that pass validTarget, reduced with Comparator.comparingDouble on the Sort enum's comparator, so the entity minimizing distance, health, hurtTime or armor wins. validTarget rejects null, the local player, dead entities, health at or below zero and armor stands, consults the AntiBot module when it is toggled, then applies the range test: canEntityBeSeen selects the Range value, otherwise WallRange, and the target must satisfy getDistanceSqToEntity within the squared radius. Once a target exists, RotationUtils.entity computes the facing angles and November.instance().rotations().spoof(HIGH, 5, rots) pushes them into the rotation manager so the server-side look tracks the target while the camera may not. The attack and the spoof run inside the same walking update, which keeps the server-observed facing consistent with the hit.

Attack timing and execution

Attacks are scheduled by a Timer against attackTime(), which returns 1000 divided by a random integer between MinCPS and MaxCPS for the BASIC clicking mode and 0.0 for ADVANCED and UPDATED, meaning those two modes attack on every walking update tick. On the PRE stage, after the timer passes, the module sends the release packet for BASIC autoblock, calls swingItem, then dispatches the hit: the KeepSprint path queues a C02PacketUseEntity ATTACK directly through the send queue, while the default path calls playerController.attackEntity, which lets vanilla handle sprint stopping and the packet. The timer resets after each attack, and the BASIC autoblock mode re-asserts the block with a fresh C08 after the hit. The packetOut listener is the safety net: in WATCHDOG mode it cancels any outgoing C02 ATTACK while the target's hurtTime is above 2, so the module never stacks hits on a target that is already showing damage.

Autoblock modes and packet handling

Blocking is asserted through one of six modes. HOLD sets the inventory key binding pressed, BASIC and VANILLA send C08PacketPlayerBlockPlacement with the held item, and VANILLA returns immediately after blocking, skipping the attack for that tick, which makes it the block-only mode. WATCHDOG sends C08 with a null item stack while the target's hurtTime is above 2 and unblocks at exactly 2, riding the vanilla use-item state to keep the block animation alive. FAKE and NONE never send block packets. unblock() releases the key binding or sends C07PacketPlayerDigging RELEASE_USE_ITEM at BlockPos.ORIGIN with facing DOWN, and the packetOut listener cancels that same C07 for the VANILLA and WATCHDOG modes so the server never sees the release, while BASIC lets it through. The renderItemUse listener forces the held sword's action to BLOCK and cancels the event whenever blocking is true, so the client renders the blocking pose even though the packet stream only shows C08 placements. The module only blocks while holding a sword, and disable() tears down the block state when the module turns off.

source KillAuraModule.java (module logic)

KillAuraModule.java341 lines · JavaOriginal ↗
1
/* November.lol © 2023 */
2
package lol.november.feature.module.impl.combat;
3
4
import static lol.november.listener.bus.DefaultEventPriority.HIGH;
5
6
import java.util.Comparator;
7
import java.util.function.Function;
8
import lol.november.November;
9
import lol.november.feature.module.Category;
10
import lol.november.feature.module.Module;
11
import lol.november.feature.module.Register;
12
import lol.november.feature.setting.Setting;
13
import lol.november.listener.bus.Listener;
14
import lol.november.listener.bus.Subscribe;
15
import lol.november.listener.event.Stage;
16
import lol.november.listener.event.net.EventPacket;
17
import lol.november.listener.event.player.move.EventWalkingUpdate;
18
import lol.november.listener.event.render.EventRenderItemUse;
19
import lol.november.utility.math.MathUtils;
20
import lol.november.utility.math.RotationUtils;
21
import lol.november.utility.math.timer.Timer;
22
import net.minecraft.entity.Entity;
23
import net.minecraft.entity.EntityLivingBase;
24
import net.minecraft.entity.item.EntityArmorStand;
25
import net.minecraft.item.EnumAction;
26
import net.minecraft.item.ItemStack;
27
import net.minecraft.item.ItemSword;
28
import net.minecraft.network.play.client.C02PacketUseEntity;
29
import net.minecraft.network.play.client.C07PacketPlayerDigging;
30
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
31
import net.minecraft.util.BlockPos;
32
import net.minecraft.util.EnumFacing;
33
34
/**
35
 * @author Gavin
36
 * @since 2.0.0
37
 */
38
@Register(
39
  name = "KillAura",
40
  description = "Attacks entities around you",
41
  category = Category.COMBAT
42
)
43
public class KillAuraModule extends Module {
44
45
  private final Setting<Mode> mode = new Setting<>("Mode", Mode.SINGLE);
46
  private final Setting<Sort> sort = new Setting<>("Sort", Sort.DISTANCE);
47
48
  private final Setting<Click> clicking = new Setting<>(
49
    "Clicking",
50
    Click.BASIC
51
  );
52
  private final Setting<Integer> minCps = new Setting<>(
53
    () -> clicking.getValue() != Click.UPDATED,
54
    "Min CPS",
55
    12,
56
    1,
57
    0,
58
    20
59
  );
60
  private final Setting<Integer> maxCps = new Setting<>(
61
    () -> clicking.getValue() != Click.UPDATED,
62
    "Max CPS",
63
    16,
64
    1,
65
    0,
66
    20
67
  );
68
69
  private final Setting<Double> range = new Setting<>(
70
    "Range",
71
    4.0,
72
    0.01,
73
    1.0,
74
    6.0
75
  );
76
  private final Setting<Double> wallRange = new Setting<>(
77
    "Wall Range",
78
    3.0,
79
    0.01,
80
    1.0,
81
    6.0
82
  );
83
84
  private final Setting<AutoBlock> autoBlock = new Setting<>(
85
    "Auto Block",
86
    AutoBlock.VANILLA
87
  );
88
89
  private final Setting<Boolean> rotate = new Setting<>("Rotate", true);
90
91
  private final Setting<Boolean> keepSprint = new Setting<>(
92
    "Keep Sprint",
93
    false
94
  );
95
96
  private final Timer timer = new Timer();
97
  private EntityLivingBase attackTarget;
98
  private float[] rotations;
99
  private boolean blocking;
100
101
  @Override
102
  public void disable() {
103
    super.disable();
104
105
    attackTarget = null;
106
    rotations = null;
107
108
    if (blocking) unblock();
109
  }
110
111
  @Subscribe(ignoreCanceled = false)
112
  private final Listener<EventWalkingUpdate> walkingUpdate = event -> {
113
    if (!validTarget(attackTarget) || mode.getValue() == Mode.SWITCH) {
114
      attackTarget =
115
        (EntityLivingBase) mc.theWorld.loadedEntityList
116
          .stream()
117
          .filter(entity ->
118
            entity instanceof EntityLivingBase &&
119
            validTarget((EntityLivingBase) entity)
120
          )
121
          .min(
122
            Comparator.comparingDouble(entity ->
123
              sort.getValue().compare((EntityLivingBase) entity)
124
            )
125
          )
126
          .orElse(null);
127
    }
128
129
    if (attackTarget == null) {
130
      if (blocking && event.getStage() == Stage.PRE) unblock();
131
      return;
132
    }
133
134
    if (rotate.getValue()) {
135
      float[] rots = RotationUtils.entity(attackTarget);
136
      November.instance().rotations().spoof(HIGH, 5, rots);
137
      rotations = rots;
138
    }
139
140
    if (holdingSword()) {
141
      if (!blocking) {
142
        blocking = true;
143
        switch (autoBlock.getValue()) {
144
          case HOLD -> mc.gameSettings.keyBindInventory.pressed = true;
145
          case BASIC, VANILLA -> {
146
            mc.thePlayer.sendQueue.addToSendQueue(
147
              new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())
148
            );
149
150
            // don't attack after blocking - this could be another setting
151
            if (autoBlock.getValue() == AutoBlock.VANILLA) return;
152
          }
153
        }
154
      }
155
    } else {
156
      if (blocking) unblock();
157
    }
158
159
    if (event.getStage() == Stage.PRE) {
160
      // nov 1.0.0 has this in EventUpdate, this is pretty much the same
161
      if (autoBlock.getValue() == AutoBlock.WATCHDOG) {
162
        if (attackTarget.hurtTime > 2) {
163
          blocking = true;
164
          mc.thePlayer.sendQueue.addToSendQueue(
165
            new C08PacketPlayerBlockPlacement(null)
166
          );
167
        }
168
        if (attackTarget.hurtTime == 2) unblock();
169
      }
170
171
      if (timer.passed((long) attackTime())) {
172
        if (
173
          autoBlock.getValue() == AutoBlock.BASIC && blocking
174
        ) mc.thePlayer.sendQueue.addToSendQueue(
175
          new C07PacketPlayerDigging(
176
            C07PacketPlayerDigging.Action.RELEASE_USE_ITEM,
177
            BlockPos.ORIGIN,
178
            EnumFacing.DOWN
179
          )
180
        );
181
182
        mc.thePlayer.swingItem();
183
        if (keepSprint.getValue()) {
184
          mc.thePlayer.sendQueue.addToSendQueue(
185
            new C02PacketUseEntity(
186
              attackTarget,
187
              C02PacketUseEntity.Action.ATTACK
188
            )
189
          );
190
        } else {
191
          mc.playerController.attackEntity(mc.thePlayer, attackTarget);
192
        }
193
194
        timer.reset();
195
196
        if (
197
          autoBlock.getValue() == AutoBlock.BASIC && !blocking
198
        ) mc.thePlayer.sendQueue.addToSendQueue(
199
          new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())
200
        );
201
      }
202
    }
203
  };
204
205
  @Subscribe
206
  private final Listener<EventPacket.Out> packetOut = event -> {
207
    if (event.get() instanceof C02PacketUseEntity packet) {
208
      if (packet.getAction() != C02PacketUseEntity.Action.ATTACK) return;
209
210
      Entity entity = packet.getEntityFromWorld(mc.theWorld);
211
      if (!(entity instanceof EntityLivingBase livingBase)) return;
212
213
      if (
214
        autoBlock.getValue() == AutoBlock.WATCHDOG && livingBase.hurtTime > 2
215
      ) event.setCanceled(true);
216
    } else if (event.get() instanceof C07PacketPlayerDigging packet) {
217
      if (
218
        packet.getStatus() != C07PacketPlayerDigging.Action.RELEASE_USE_ITEM
219
      ) return;
220
221
      if (
222
        autoBlock.getValue() == AutoBlock.VANILLA ||
223
        autoBlock.getValue() == AutoBlock.WATCHDOG
224
      ) {
225
        event.setCanceled(true);
226
      } else {
227
        blocking = false;
228
      }
229
    }
230
  };
231
232
  @Subscribe
233
  private final Listener<EventRenderItemUse> renderItemUse = event -> {
234
    // event.getItemStack() should never be null because of where the event is hooked
235
    if (blocking && event.getItemStack().getItem() instanceof ItemSword) {
236
      event.setAction(EnumAction.BLOCK);
237
      event.setCanceled(true);
238
    }
239
  };
240
241
  private double attackTime() {
242
    return switch (clicking.getValue()) {
243
      case BASIC -> 1000.0 /
244
      MathUtils.random(minCps.getValue(), maxCps.getValue());
245
      default -> 0.0;
246
    };
247
  }
248
249
  private boolean validTarget(EntityLivingBase entity) {
250
    if (
251
      entity == null ||
252
      entity.equals(mc.thePlayer) ||
253
      entity.isDead ||
254
      entity.getHealth() <= 0.0f
255
    ) return false;
256
257
    if (entity instanceof EntityArmorStand) return false;
258
259
    AntiBotModule antiBot = November
260
      .instance()
261
      .modules()
262
      .get(AntiBotModule.class);
263
    if (
264
      antiBot != null && antiBot.toggled() && antiBot.bot(entity.getEntityId())
265
    ) return false;
266
267
    double r = mc.thePlayer.canEntityBeSeen(entity)
268
      ? range.getValue()
269
      : wallRange.getValue();
270
    return mc.thePlayer.getDistanceSqToEntity(entity) <= r * r;
271
  }
272
273
  private void unblock() {
274
    if (!holdingSword()) {
275
      blocking = false;
276
      return;
277
    }
278
279
    switch (autoBlock.getValue()) {
280
      case HOLD -> mc.gameSettings.keyBindInventory.pressed = false;
281
      case BASIC, VANILLA, WATCHDOG -> mc.thePlayer.sendQueue.addToSendQueue(
282
        new C07PacketPlayerDigging(
283
          C07PacketPlayerDigging.Action.RELEASE_USE_ITEM,
284
          BlockPos.ORIGIN,
285
          EnumFacing.DOWN
286
        )
287
      );
288
    }
289
290
    blocking = false;
291
  }
292
293
  private boolean holdingSword() {
294
    ItemStack itemStack = mc.thePlayer.getHeldItem();
295
    return itemStack != null && itemStack.getItem() instanceof ItemSword;
296
  }
297
298
  public EntityLivingBase getAttackTarget() {
299
    return attackTarget;
300
  }
301
302
  private enum Mode {
303
    SINGLE,
304
    SWITCH,
305
    HURT_TIME,
306
  }
307
308
  private enum Sort {
309
    DISTANCE(entity -> mc.thePlayer.getDistanceSqToEntity(entity)),
310
    HEALTH(entity ->
311
      (double) (entity.getHealth() + entity.getAbsorptionAmount())
312
    ),
313
    HURT_TIME(entity -> (double) entity.hurtTime),
314
    ARMOR(entity -> (double) entity.getTotalArmorValue());
315
316
    private final Function<EntityLivingBase, Double> comparator;
317
318
    Sort(Function<EntityLivingBase, Double> comparator) {
319
      this.comparator = comparator;
320
    }
321
322
    public double compare(EntityLivingBase entity) {
323
      return comparator.apply(entity);
324
    }
325
  }
326
327
  private enum Click {
328
    BASIC,
329
    ADVANCED,
330
    UPDATED,
331
  }
332
333
  private enum AutoBlock {
334
    NONE,
335
    FAKE,
336
    HOLD,
337
    BASIC,
338
    VANILLA,
339
    WATCHDOG,
340
  }
341
}

What this file does

The entire module is this one class: the Setting declarations for Mode, Sort, Clicking, CPS, Range, WallRange, AutoBlock, Rotate and KeepSprint, the walkingUpdate listener that selects targets and fires attacks, the packetOut listener that polices C02 and C07 traffic for the WATCHDOG and VANILLA autoblock modes, the renderItemUse listener that forces the blocking pose, and the validTarget, unblock, holdingSword and attackTime helpers. The Mode enum (SINGLE, SWITCH, HURT_TIME) and the Sort enum's comparators define the target selection surface, and the Click enum's BASIC/ADVANCED/UPDATED values control whether attacks are randomized or every tick. Everything a counter needs to know about what the module sends and when is in the two listeners plus attackTime.

source RotationUtils.java (target angle computation)

RotationUtils.java74 lines · JavaOriginal ↗
1
/* November.lol © 2023 */
2
package lol.november.utility.math;
3
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.entity.EntityLivingBase;
6
import net.minecraft.util.BlockPos;
7
import net.minecraft.util.EnumFacing;
8
9
/**
10
 * @author Gavin
11
 * @since 2.0.0
12
 */
13
public class RotationUtils {
14
15
  /**
16
   * The {@link Minecraft} game instance
17
   */
18
  private static final Minecraft mc = Minecraft.getMinecraft();
19
20
  /**
21
   * Calculates rotations to the {@link EntityLivingBase}
22
   *
23
   * @param entity the {@link EntityLivingBase} target
24
   * @return a float array of rotations
25
   */
26
  public static float[] entity(EntityLivingBase entity) {
27
    double diffX = mc.thePlayer.posX - entity.posX;
28
    double diffY =
29
      (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()) - entity.posY;
30
    double diffZ = mc.thePlayer.posZ - entity.posZ;
31
32
    float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) + 90.0f;
33
    float pitch = (float) Math.toDegrees(
34
      Math.atan2(diffY, Math.hypot(diffX, diffZ))
35
    );
36
37
    return new float[]{yaw, pitch};
38
  }
39
40
  public static float[] block(BlockPos pos, EnumFacing facing) {
41
    double diffX =
42
      mc.thePlayer.posX - (pos.getX() - (facing.getFrontOffsetX() / 2.0));
43
    double diffY =
44
      (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()) - (pos.getY() - (facing.getFrontOffsetY() / 2.0));
45
    double diffZ =
46
      mc.thePlayer.posZ - (pos.getZ() - (facing.getFrontOffsetZ() / 2.0));
47
48
    float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) + 90.0f;
49
    float pitch = (float) Math.toDegrees(
50
      Math.atan2(diffY, Math.hypot(diffX, diffZ))
51
    );
52
53
    return new float[]{yaw, pitch};
54
  }
55
56
  public static float[] middleBlock(BlockPos pos, EnumFacing facing) {
57
    double diffX =
58
      (Math.floor(mc.thePlayer.posX) + 0.5) -
59
        (pos.getX() - (facing.getFrontOffsetX() / 2.0));
60
    double diffY =
61
      (Math.floor(mc.thePlayer.posY) + 0.5) -
62
        (pos.getY() - (facing.getFrontOffsetY() / 2.0));
63
    double diffZ =
64
      (Math.floor(mc.thePlayer.posZ) + 0.5) -
65
        (pos.getZ() - (facing.getFrontOffsetZ() / 2.0));
66
67
    float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) + 90.0f;
68
    float pitch = (float) Math.toDegrees(
69
      Math.atan2(diffY, Math.hypot(diffX, diffZ))
70
    );
71
72
    return new float[]{yaw, pitch};
73
  }
74
}

What this file does

RotationUtils.entity computes the yaw and pitch that face an EntityLivingBase, which is the only rotation primitive the module uses; the returned float array is passed straight to the rotation manager's spoof call. The class also provides block and middleBlock helpers used by the client's other modules, but KillAura only consumes entity(). The separation matters for countering: the angle the server sees comes from this computation plus the rotation manager's spoof timing, so an aim-pattern check that analyzes the sent yaw/pitch stream is really analyzing the output of this utility, not human input.

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 KillAura (speed, multi, direction)

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's KillAura check is invoked from the FightListener on every use-entity attack and bundles direction, multi-target, no-swing, reach and speed sub-checks. The speed sub-check counts totalAttacks against max-attacks and attack packets against max-attack-packets, resetting both on a one-second boundary, and checkFrequency applies the packet ceiling so a burst of C02 packets inside a second trips a violation even when the entity-facing angles are clean. The multi sub-check compares the angles to the previously attacked entity and the current one, flagging when they differ by more than maxAngle while both targets are in reach. The direction sub-check measures the angle between the player's server-side look and the attacked entity, and the reach sub-check measures distance to the entity position minus its velocity so knockback does not mask an out-of-range hit.

anticheat EntityInteractReach (lag-compensated 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, attacks included, against a server-side distance measurement. The check builds the attacker position from the lag compensator's ping-based history location plus eye height, then computes the distance from that point to the victim's bounding box and punishes when it exceeds the configured reach. Because the attacker position is rewound by the player's ping, client-server desync does not inflate the measured distance in the attacker's favor, and because the distance is measured to the AABB, standing inside the box's footprint is what counts rather than any claimed range. The check is cancelless by design, so its role is flagging rather than packet blocking.

anticheat Reach (distance limit with precision and dynamic reduction)

Reach.java372 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
18
import org.bukkit.GameMode;
19
import org.bukkit.Location;
20
import org.bukkit.entity.EnderDragon;
21
import org.bukkit.entity.Entity;
22
import org.bukkit.entity.Giant;
23
import org.bukkit.entity.LivingEntity;
24
import org.bukkit.entity.Player;
25
import org.bukkit.util.Vector;
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.checks.combined.Improbable;
32
import fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace.ITraceEntry;
33
import fr.neatmonster.nocheatplus.permissions.Permissions;
34
import fr.neatmonster.nocheatplus.players.IPlayerData;
35
import fr.neatmonster.nocheatplus.utilities.StringUtil;
36
import fr.neatmonster.nocheatplus.utilities.TickTask;
37
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
38
39
/**
40
 * The Reach check will find out if a player interacts with something that's too far away.
41
 */
42
public class Reach extends Check {
43
44
    /** The maximum distance allowed to interact with an entity in creative mode. */
45
    public static final double CREATIVE_DISTANCE = 6D;
46
47
48
    /** Additum for distance, based on entity. */
49
    private static double getDistMod(final Entity damaged) {
50
        // Handle the EnderDragon differently.
51
        if (damaged instanceof EnderDragon)
52
            return 6.5D;
53
        else if (damaged instanceof Giant){
54
            return 1.5D;
55
        }
56
        else return 0;
57
    }
58
59
60
    /**
61
     * Instantiates a new reach check.
62
     */
63
    public Reach() {
64
        super(CheckType.FIGHT_REACH);
65
    }
66
67
68
    /**
69
     * "Classic" check.
70
     * 
71
     * @param player
72
     *            the player
73
     * @param damaged
74
     *            the damaged
75
     * @return true, if successful
76
     */
77
    public boolean check(final Player player, final Location pLoc, 
78
                         final Entity damaged, final boolean damagedIsFake, final Location dRef, 
79
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
80
81
        boolean cancel = false;
82
        // The maximum distance allowed to interact with an entity in survival mode.
83
        final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance; 
84
        // Amount which can be reduced by reach adaption.
85
        final double DYNAMIC_RANGE = cc.reachReduceDistance; 
86
        // Adaption amount for dynamic range.
87
        final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE; 
88
        final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
89
        final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
90
        final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
91
        final double width = damagedIsFake ? 0.6 : mcAccess.getHandle().getWidth(damaged);
92
        double centertoedge = 0.0;
93
        
94
        if (cc.reachPrecision) {
95
            centertoedge = getinset(pLoc, dRef, width / 2, 0.0);
96
        }
97
98
        // Refine y position.
99
        final double pY = pLoc.getY() + player.getEyeHeight();
100
        final double dY = dRef.getY();
101
        if (pY <= dY) {
102
            // Keep the foot level y.
103
        } 
104
        // Highest ref y
105
        else if (pY >= dY + height) {
106
             dRef.setY(dY + height);
107
        }
108
        // Level with damaged.
109
        else dRef.setY(pY);
110
111
        final Vector pRel = dRef.toVector().subtract(pLoc.toVector().setY(pY)); // TODO: Run calculations on numbers only :p.
112
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
113
        // than allowed, the difference will be assigned to "distance".
114
        final double lenpRel = pRel.length() - centertoedge;
115
        double violation = lenpRel - distanceLimit;
116
        final double reachMod = data.reachMod; 
117
118
119
        if (violation > 0) {
120
            if (TickTask.getLag(1000, true) < 1.5f){ // Do not increase the vl in case of server lag (1.5 is a magic value)
121
                data.reachVL += violation;
122
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
123
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
124
                // Execute whatever actions are associated with this check and the violation level and find out if we should
125
                // cancel the event.
126
                cancel = executeActions(vd).willCancel();
127
            }
128
129
            if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), "fight.reach", pData)){
130
                cancel = true;
131
            }
132
133
            if (cancel && cc.reachPenalty > 0){
134
                // Apply an attack penalty time.
135
                data.attackPenalty.applyPenalty(cc.reachPenalty);
136
            }
137
        }
138
        else if (lenpRel - distanceLimit * reachMod > 0){
139
            // Silent cancel.
140
            if (cc.reachPenalty > 0) {
141
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
142
            }
143
            cancel = true;
144
            Improbable.feed(player, (float) (lenpRel - distanceLimit * reachMod) / 4f, System.currentTimeMillis());
145
        }
146
        else data.reachVL *= 0.8D; // Player passed the check, reward them.
147
            
148
149
        if (!cc.reachReduce){
150
            data.reachMod = 1d;
151
        }
152
        else if (lenpRel > distanceLimit - DYNAMIC_RANGE){
153
            data.reachMod = Math.max(distanceMin, data.reachMod - DYNAMIC_STEP);
154
        }
155
        else data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
156
157
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
158
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod));
159
        }
160
161
        return cancel;
162
    }
163
164
    /**
165
     * Data context for iterating over ITraceEntry instances.
166
     * @param player
167
     * @param pLoc
168
     * @param damaged
169
     * @param damagedLoc
170
     * @param data
171
     * @param cc
172
     * @return
173
     */
174
    public ReachContext getContext(final Player player, final Location pLoc, 
175
                                   final Entity damaged, final Location damagedLoc, 
176
                                   final FightData data, final FightConfig cc) {
177
178
        final ReachContext context = new ReachContext();
179
        context.distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : cc.reachSurvivalDistance + getDistMod(damaged);
180
        context.distanceMin = (context.distanceLimit - cc.reachReduceDistance) / context.distanceLimit;
181
        //context.eyeHeight = player.getEyeHeight();
182
        context.pY = pLoc.getY() + player.getEyeHeight();
183
        return context;
184
    }
185
186
    /**
187
     * Check if the player fails the reach check, no change of FightData.
188
     * @param player
189
     * @param pLoc
190
     * @param damaged
191
     * @param dRef
192
     * @param context
193
     * @param data
194
     * @param cc
195
     * @return
196
     */
197
    public boolean loopCheck(final Player player, final Location pLoc, final Entity damaged, 
198
                             final ITraceEntry dRef, final ReachContext context, 
199
                             final FightData data, final FightConfig cc) {
200
201
        boolean cancel = false;
202
203
        // Refine y position.
204
        final double dY = dRef.getY();
205
        double y = dRef.getY();
206
207
        if (context.pY <= dY) {
208
            // Keep the foot level y.
209
        }
210
        else if (context.pY >= dY + dRef.getBoxMarginVertical()) {
211
            y = dY + dRef.getBoxMarginVertical(); // Highest ref y.
212
        }
213
        else {
214
            y = context.pY; // Level with damaged.
215
        }
216
217
        double centertoedge = 0.0;
218
        if (cc.reachPrecision) centertoedge = getinset(pLoc, new Location(null, dRef.getX(), dRef.getY(), dRef.getZ()), dRef.getBoxMarginHorizontal(), y - context.pY);
219
        
220
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
221
        // than allowed, the difference will be assigned to "distance".
222
        // TODO: Run check on squared distances (quite easy to change to stored boundary-sq values).
223
        final double lenpRel = TrigUtil.distance(dRef.getX(), y, dRef.getZ(), pLoc.getX(), context.pY, pLoc.getZ()) - centertoedge;
224
        double violation = lenpRel - context.distanceLimit;
225
226
        if (violation > 0 || lenpRel - context.distanceLimit * data.reachMod > 0){
227
            // TODO: The silent cancel parts should be sen as "no violation" ?
228
            // Set minimum violation in context
229
            context.minViolation = Math.min(context.minViolation, lenpRel);
230
            cancel = true;
231
        }
232
        context.minResult = Math.min(context.minResult, lenpRel);
233
234
        return cancel;
235
236
    }
237
238
    /**
239
     * Apply changes to FightData according to check results (context), trigger violations.
240
     * @param player
241
     * @param pLoc
242
     * @param damaged
243
     * @param context
244
     * @param forceViolation
245
     * @param data
246
     * @param cc
247
     * @return
248
     */
249
    public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged, 
250
                              final ReachContext context, final ITraceEntry traceEntry, final boolean forceViolation, 
251
                              final FightData data, final FightConfig cc, final IPlayerData pData) {
252
253
        final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
254
255
        if (lenpRel == Double.MAX_VALUE) {
256
            return false;
257
        }
258
259
        double violation = lenpRel - context.distanceLimit;
260
        boolean cancel = false;
261
262
        if (violation > 0) {    
263
            if (TickTask.getLag(1000, true) < 1.5f){
264
                data.reachVL += violation;
265
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
266
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
267
                // Execute whatever actions are associated with this check and the violation level and find out if we should
268
                // cancel the event.
269
                cancel = executeActions(vd).willCancel();
270
            }
271
            
272
            //if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), 
273
            //        "fight.reach", pData)){
274
            //    cancel = true;
275
            //}
276
            // TODO: New improbable weight calculations so that weight is not inverse to config weight
277
            if (cc.reachImprobableWeight > 0.0f) {
278
                if (!cc.reachImprobableFeedOnly && Improbable.check(player, (float) violation / cc.reachImprobableWeight, System.currentTimeMillis(), "fight.reach", pData)) {
279
                    cancel = true;
280
                }
281
            }
282
283
            if (cancel && cc.reachPenalty > 0){
284
                // Apply an attack penalty time.
285
                data.attackPenalty.applyPenalty(cc.reachPenalty);
286
            }
287
        }
288
        else if (lenpRel - context.distanceLimit * data.reachMod > 0){
289
            // Silent cancel.
290
            if (cc.reachPenalty > 0) {
291
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
292
            }
293
294
            cancel = true;
295
296
            if (cc.reachImprobableWeight > 0.0f) {
297
                Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / cc.reachImprobableWeight, System.currentTimeMillis());
298
            }
299
            // Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / 4f, System.currentTimeMillis());
300
        }
301
        else {
302
            // Player passed the check, reward them.
303
            data.reachVL *= 0.8D;
304
305
        }
306
307
        // Adaption amount for dynamic range.
308
        final double DYNAMIC_STEP = cc.reachReduceStep / cc.reachSurvivalDistance;
309
310
        if (!cc.reachReduce){
311
            data.reachMod = 1d;
312
        }
313
        else if (lenpRel > context.distanceLimit - cc.reachReduceDistance){
314
            data.reachMod = Math.max(context.distanceMin, data.reachMod - DYNAMIC_STEP);
315
        }
316
        else {
317
            data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
318
        }
319
320
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
321
            // TODO: Height: remember successful ITraceEntry
322
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ (traceEntry == null ? "" : (" height=" + traceEntry.getBoxMarginVertical())) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(data.reachMod));
323
        }
324
325
        return cancel;
326
    }
327
328
329
    private boolean isSameXZ(final Location loc1, final Location loc2) {
330
        return loc1.getX() == loc2.getX() && loc1.getZ() == loc2.getZ();
331
    }
332
333
334
    /**
335
     *
336
     * @param pLoc
337
     *            the player location
338
     * @param dRef
339
     *            the target location
340
     * @param damagedBoxMarginHorizontal
341
     *            the target Width / 2
342
     * @param diffY the Y different
343
     * @return the double represent for the distance from target location to the edge of target hitbox
344
     */
345
    private double getinset(final Location pLoc, final Location dRef, final double damagedBoxMarginHorizontal, final double diffY) {
346
347
        if (!isSameXZ(pLoc, dRef)) {
348
            final Location dRefc = dRef.clone();
349
            final Vector vec1 = new Vector(pLoc.getX() - dRef.getX(), diffY , pLoc.getZ() - dRef.getZ());
350
            if (vec1.length() < damagedBoxMarginHorizontal * Math.sqrt(2)) return 0.0;
351
            if (vec1.getZ() > 0.0) {
352
                dRefc.setZ(dRefc.getZ() + damagedBoxMarginHorizontal);
353
            } 
354
            else if (vec1.getZ() < 0.0) {
355
                dRefc.setZ(dRefc.getZ() - damagedBoxMarginHorizontal);
356
            } 
357
            else if (vec1.getX() > 0.0) {
358
                dRefc.setX(dRefc.getX() + damagedBoxMarginHorizontal);
359
            } 
360
            else dRefc.setX(dRefc.getX() - damagedBoxMarginHorizontal);
361
362
            final Vector vec2 = new Vector(dRefc.getX() - dRef.getX(), 0.0 , dRefc.getZ() - dRef.getZ());
363
            double angle = TrigUtil.angle(vec1, vec2);
364
            // Require < 45deg, if not 90deg-angel
365
            if (angle > Math.PI / 4) angle = Math.PI / 2 - angle;
366
            if (angle >= 0.0 && angle <= Math.PI / 4) { // TODO: Dose this one necessary?
367
                return damagedBoxMarginHorizontal / Math.cos(angle);
368
            }
369
        }
370
        return 0.0;
371
    }
372
}

How it counteracts this module

NCP's fight.Reach compares every attack's measured distance lenpRel against distanceLimit, which comes from reachSurvivalDistance or the 6.5 creative constant, and flags when the difference is positive, with reachPrecision tightening the comparison to the exact separation. Repeated violations accumulate reachVL and drive a dynamic reduction that lowers the effective limit via reachReduceDistance in steps of reachReduceStep, and cancelled hits apply reachPenalty to further suppress combat output. The measurement uses the server's own player and entity positions, so no client-side claim about range, facing or onGround changes the result. Improbable and the VL accumulator gate the actions so a single borderline hit does not immediately punish.

← Back to Analysis Hub