November Recode 2.0 Phase module 2 files, 199 lines

November Recode 2.0 Phase: Full Source Analysis

November's Phase module is a cage-phase cheat with a single mode, CAGE_PHASE, and a server selector for GENERIC, BLOCKS_MC and HYPIXEL.

feature/module/impl/exploit/PhaseModule.java · GitHub source ↗

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

Packets This Module Uses

Analysis

Overview

November's Phase module is a cage-phase cheat with a single mode, CAGE_PHASE, and a server selector for GENERIC, BLOCKS_MC and HYPIXEL. While armed it edits the client's own world to remove the glass block under the player's feet, then suppresses every outgoing packet except chat for as long as the phase lasts, freezing the server-side position while the local player walks through the empty cell. An S08 setback resets the arming timer, BlocksMC cage messages arm and disarm the phase window, and disabling the module flushes the entire suppressed queue in one tick and restores the glass block.

Client-side world edit

The update handler bails for the first five ticks, then increments ticksSinceLastSetback. When at least 20 ticks have passed without a setback, the player is on the ground, and the module is allowed to phase, it reads the block state directly under the feet; if that block is BlockGlass it sets cagePhasing true, calls setBlockToAir on the cell, and records the position and state for later restoration. The edit is purely local: the server never learns the glass was removed, so server-side collision still treats the cell as solid.

Blink-style suppression

While cagePhasing is true, the packet-out listener cancels every outgoing packet except C01PacketChatMessage and queues the rest in a ConcurrentLinkedQueue. The client therefore sends no movement packets during the phase, and the server sees a frozen player at the pre-phase position while the local player walks through the glass cell. The packet-in listener resets ticksSinceLastSetback on every S08PacketPlayerPosLook, so a server teleport delays the next arming window, and on BLOCKS_MC the chat string 'Cages open in: 2 seconds!' arms canPhase while 'Cages opened! FIGHT!' disarms it.

Disable-time flush

disable() walks the queue and re-sends every suppressed packet through addToSendQueueSilent in a single tick, so a phase that lasted several seconds replays its entire movement history at once, then restores the glass via setBlockState and resets the state fields. The flush is the module's most visible wire signature: the server receives a burst of every movement packet that was withheld during the phase instead of the steady stream it expected.

source PhaseModule.java

PhaseModule.java163 lines · JavaOriginal ↗
1
/* November.lol © 2023 */
2
package lol.november.feature.module.impl.exploit;
3
4
import java.util.Queue;
5
import java.util.concurrent.ConcurrentLinkedQueue;
6
import lol.november.feature.module.Category;
7
import lol.november.feature.module.Module;
8
import lol.november.feature.module.Register;
9
import lol.november.feature.setting.Setting;
10
import lol.november.listener.bus.Listener;
11
import lol.november.listener.bus.Subscribe;
12
import lol.november.listener.event.net.EventPacket;
13
import lol.november.listener.event.player.EventUpdate;
14
import net.minecraft.block.BlockGlass;
15
import net.minecraft.block.state.IBlockState;
16
import net.minecraft.network.Packet;
17
import net.minecraft.network.play.client.C01PacketChatMessage;
18
import net.minecraft.network.play.server.S02PacketChat;
19
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
20
import net.minecraft.util.BlockPos;
21
22
/**
23
 * @author Gavin
24
 * @since 2.0.0
25
 */
26
@Register(
27
  name = "Phase",
28
  description = "Phases through blocks",
29
  category = Category.EXPLOIT
30
)
31
public class PhaseModule extends Module {
32
33
  private final Setting<Mode> mode = new Setting<>("Mode", Mode.CAGE_PHASE);
34
  private final Setting<Server> server = new Setting<>(
35
    "Server",
36
    Server.BLOCKS_MC
37
  );
38
39
  private final Queue<Packet<?>> packetQueue = new ConcurrentLinkedQueue<>();
40
  private int ticksSinceLastSetback = -1;
41
42
  private BlockPos phasePos;
43
  private IBlockState phaseState;
44
  private boolean cagePhasing, canPhase = true;
45
46
  @Override
47
  public void enable() {
48
    super.enable();
49
    canPhase = server.getValue() == Server.GENERIC;
50
  }
51
52
  @Override
53
  public void disable() {
54
    super.disable();
55
56
    if (mc.thePlayer != null && !packetQueue.isEmpty()) {
57
      while (!packetQueue.isEmpty()) {
58
        mc.thePlayer.sendQueue.addToSendQueueSilent(packetQueue.poll());
59
      }
60
    }
61
62
    packetQueue.clear();
63
    ticksSinceLastSetback = -1;
64
65
    if (cagePhasing) {
66
      if (phasePos != null && phaseState != null) {
67
        mc.theWorld.setBlockState(phasePos, phaseState);
68
      }
69
70
      cagePhasing = false;
71
      phasePos = null;
72
      phaseState = null;
73
    }
74
75
    canPhase = true;
76
  }
77
78
  @Subscribe
79
  private final Listener<EventUpdate> update = event -> {
80
    if (mc.thePlayer.ticksExisted < 5) {
81
      packetQueue.clear();
82
      ticksSinceLastSetback = 0;
83
      phaseState = null;
84
      phasePos = null;
85
      cagePhasing = false;
86
87
      canPhase = server.getValue() == Server.GENERIC;
88
89
      return;
90
    }
91
92
    ticksSinceLastSetback++;
93
94
    if (mode.getValue() == Mode.CAGE_PHASE) {
95
      if (
96
        ticksSinceLastSetback < 20 || !mc.thePlayer.onGround || !canPhase
97
      ) return;
98
99
      if (!cagePhasing) {
100
        BlockPos under = new BlockPos(mc.thePlayer.getPositionVector()).down();
101
        IBlockState state = mc.theWorld.getBlockState(under);
102
        if (state.getBlock() instanceof BlockGlass) {
103
          cagePhasing = true;
104
          mc.theWorld.setBlockToAir(under);
105
106
          // Printer.print("Phased through glass");
107
108
          phasePos = under;
109
          phaseState = state;
110
        }
111
      } else {
112
        if (phasePos != null && phaseState != null) {
113
          // Printer.print("Replaced glass to not desync");
114
          mc.theWorld.setBlockState(phasePos, phaseState);
115
          phaseState = null;
116
        }
117
      }
118
    }
119
  };
120
121
  @Subscribe
122
  private final Listener<EventPacket.Out> packetOut = event -> {
123
    if (mc.thePlayer == null || mc.thePlayer.ticksExisted < 10) return;
124
125
    if (cagePhasing) {
126
      if (event.get() instanceof C01PacketChatMessage) return;
127
      event.setCanceled(true);
128
      packetQueue.add(event.get());
129
    }
130
  };
131
132
  @Subscribe
133
  private final Listener<EventPacket.In> packetIn = event -> {
134
    if (event.get() instanceof S08PacketPlayerPosLook) {
135
      ticksSinceLastSetback = 0;
136
      // Printer.print("Setback");
137
    } else if (event.get() instanceof S02PacketChat packet) {
138
      if (mode.getValue() != Mode.CAGE_PHASE) return;
139
140
      String raw = packet.getChatComponent().getUnformattedText();
141
142
      if (server.getValue() == Server.HYPIXEL) {
143
        // TODO
144
      } else if (server.getValue() == Server.BLOCKS_MC) {
145
        if (raw.contains("Cages open in: 2 seconds!")) {
146
          canPhase = true;
147
        } else if (raw.contains("Cages opened! FIGHT!")) {
148
          setState(false);
149
        }
150
      }
151
    }
152
  };
153
154
  private enum Mode {
155
    CAGE_PHASE,
156
  }
157
158
  private enum Server {
159
    GENERIC,
160
    BLOCKS_MC,
161
    HYPIXEL,
162
  }
163
}

What this file does

The module file is the complete mechanism: the update listener performs the client-side setBlockToAir on the glass cell under the feet, the packet-out listener cancels and queues everything except chat while phasing, the packet-in listener resets the setback timer on S08 and gates the phase window on BlocksMC chat strings, and disable() flushes the whole queue and restores the block. The Setting constructor is the November (name, value, scale, min, max) layout; the mode Setting pins CAGE_PHASE and the server Setting defaults to BLOCKS_MC.

source EventPacket.java (cancel carrier)

EventPacket.java36 lines · JavaOriginal ↗
1
/* November.lol © 2023 */
2
package lol.november.listener.event.net;
3
4
import lol.november.listener.bus.Cancelable;
5
import net.minecraft.network.Packet;
6
7
/**
8
 * @author Gavin
9
 * @since 2.0.0
10
 */
11
public class EventPacket extends Cancelable {
12
13
  private final Packet<?> packet;
14
15
  public EventPacket(Packet<?> packet) {
16
    this.packet = packet;
17
  }
18
19
  public <T extends Packet<?>> T get() {
20
    return (T) packet;
21
  }
22
23
  public static class In extends EventPacket {
24
25
    public In(Packet<?> packet) {
26
      super(packet);
27
    }
28
  }
29
30
  public static class Out extends EventPacket {
31
32
    public Out(Packet<?> packet) {
33
      super(packet);
34
    }
35
  }
36
}

What this file does

EventPacket is the In/Out cancelable wrapper that the packet listeners receive. The Out variant carries the outgoing packet and supports setCanceled(true), which is what the phase suppression uses to stop packets reaching the wire, and the In variant wraps received packets for the S08 and S02 handling. November Recode 2.0's snapshot lays out its tree without the lol/november package prefix and ships no net/minecraft sources, so this wrapper is the only packet plumbing available to cite.

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 Passable (swept-box ray trace)

Passable.java266 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.moving.player;
16
17
import java.util.Arrays;
18
import java.util.Locale;
19
20
import org.bukkit.Location;
21
import org.bukkit.entity.Player;
22
23
import fr.neatmonster.nocheatplus.NCPAPIProvider;
24
import fr.neatmonster.nocheatplus.actions.ParameterName;
25
import fr.neatmonster.nocheatplus.checks.Check;
26
import fr.neatmonster.nocheatplus.checks.CheckType;
27
import fr.neatmonster.nocheatplus.checks.ViolationData;
28
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
29
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
30
import fr.neatmonster.nocheatplus.compat.blocks.changetracker.BlockChangeTracker;
31
import fr.neatmonster.nocheatplus.players.IPlayerData;
32
import fr.neatmonster.nocheatplus.utilities.collision.Axis;
33
import fr.neatmonster.nocheatplus.utilities.collision.tracing.axis.ICollidePassable;
34
import fr.neatmonster.nocheatplus.utilities.collision.tracing.axis.PassableAxisTracing;
35
import fr.neatmonster.nocheatplus.utilities.location.LocUtil;
36
import fr.neatmonster.nocheatplus.utilities.location.PlayerLocation;
37
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
38
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
39
40
public class Passable extends Check {
41
42
    /** TESTING RATHER. */
43
44
    // TODO: Configuration.
45
    // TODO: Test cases.
46
    // TODO: Should keep an eye on passable vs. on-ground, when checking with reduced margins.
47
    // rt_xzFactor = 1.0; // Problems: Doors, fences.
48
    //private static double rt_xzFactor = 0.99999999999;
49
    // rt_heightFactor = 1.0; // Since 10.2 (at some point) passable FP with 2-high ceiling.
50
    //private static double rt_heightFactor = 0.99999999999;
51
52
    /**
53
     * Convenience for player moving, to keep a better overview.
54
     * 
55
     * @param from
56
     * @param to
57
     * @return
58
     */
59
    public static boolean isPassable(Location from, Location to) {
60
        // TODO ... alternate axes ? Currently only used in a simple check (y-axis only).
61
        return BlockProperties.isPassableAxisWise(from, to);
62
    }
63
64
    private final ICollidePassable rayTracing = new PassableAxisTracing();
65
    private final BlockChangeTracker blockTracker;
66
67
    public Passable() {
68
        super(CheckType.MOVING_PASSABLE);
69
        // TODO: Configurable maxSteps?
70
        rayTracing.setMaxSteps(60);
71
        blockTracker = NCPAPIProvider.getNoCheatPlusAPI().getBlockChangeTracker();
72
    }
73
74
    public Location check(final Player player, final PlayerLocation from, final PlayerLocation to, 
75
                          final MovingData data, final MovingConfig cc, final IPlayerData pData, 
76
                          final int tick, final boolean useBlockChangeTracker) {
77
        return checkActual(player, from, to, data, cc, pData, tick, useBlockChangeTracker);
78
    }
79
80
    private Location checkActual(final Player player, final PlayerLocation from, final PlayerLocation to, 
81
                                 final MovingData data, final MovingConfig cc, final IPlayerData pData,
82
                                 final int tick, final boolean useBlockChangeTracker) {
83
84
        final boolean debug = pData.isDebugActive(type);
85
        // TODO: Distinguish feet vs. box.
86
        // Block distances (sum, max) for from-to (not for loc!).
87
        final int manhattan = from.manhattan(to);
88
89
        // Check default order first, then others.
90
        rayTracing.setAxisOrder(Axis.AXIS_ORDER_YXZ);
91
        String newTag = checkRayTracing(player, from, to, manhattan, data, cc, debug, tick, useBlockChangeTracker);
92
        if (newTag != null) {
93
            newTag = checkRayTracingAlernateOrder(player, from, to, manhattan, debug, data, cc, tick, useBlockChangeTracker, newTag);
94
        }
95
        // Finally handle violations.
96
        if (newTag == null) {
97
            // (Might consider if vl>=1: only decrease if from and loc are passable too, though micro...)
98
            data.passableVL *= 0.99;
99
            return null;
100
        }
101
        else {
102
            // Direct return.
103
            return potentialViolation(player, from, to, manhattan, debug, newTag, data, cc);
104
        }
105
    }
106
107
    private String checkRayTracingAlernateOrder(final Player player, final PlayerLocation from, final PlayerLocation to, 
108
                                                final int manhattan, final boolean debug,
109
                                                final MovingData data, final MovingConfig cc, 
110
                                                final int tick, final boolean useBlockChangeTracker,
111
                                                final String previousTag) {
112
        /*
113
         * General assumption for now: Not all combinations have to be checked.
114
         * If y-first works, only XZ and ZX need to be checked. There may be
115
         * more/less restrictions in vanilla client code (e.g. Z
116
         * collision = end).
117
         */
118
        Axis axis = rayTracing.getCollidingAxis();
119
        // (YXZ is the default order, for which ray-tracing collides.)
120
        // Test the horizontal alternative only.
121
        if (axis == Axis.X_AXIS || axis == Axis.Z_AXIS) {
122
            rayTracing.setAxisOrder(Axis.AXIS_ORDER_YZX);
123
            return checkRayTracing(player, from, to, manhattan, data, cc, debug, tick, useBlockChangeTracker);
124
        }
125
        // Test both horizontal options, each before vertical.
126
        else if (axis == Axis.Y_AXIS) {
127
            rayTracing.setAxisOrder(Axis.AXIS_ORDER_XZY);
128
            if (checkRayTracing(player, from, to, manhattan, data, cc, debug, tick, useBlockChangeTracker) == null) {
129
                return null;
130
            }
131
            rayTracing.setAxisOrder(Axis.AXIS_ORDER_ZXY);
132
            return checkRayTracing(player, from, to, manhattan, data, cc, debug, tick, useBlockChangeTracker);
133
        }
134
        else {
135
            return previousTag; // In case nothing could be done.
136
        }
137
    }
138
139
    private String checkRayTracing(final Player player, final PlayerLocation from, final PlayerLocation to, final int manhattan, 
140
                                   final MovingData data, final MovingConfig cc, final boolean debug,
141
                                   final int tick, final boolean useBlockChangeTracker) {
142
        String tags = null;
143
        // NOTE: axis order is set externally.
144
        setNormalMargins(rayTracing, from, cc);
145
        rayTracing.set(from, to);
146
        rayTracing.setIgnoreInitiallyColliding(true);
147
        if (useBlockChangeTracker) { // TODO: Extra flag for 'any' block changes.
148
            rayTracing.setBlockChangeTracker(blockTracker, data.blockChangeRef, tick, from.getWorld().getUID());
149
        }
150
        //rayTracing.setCutOppositeDirectionMargin(true);
151
        rayTracing.loop();
152
        //rayTracing.setCutOppositeDirectionMargin(false);
153
        if (rayTracing.collides()) {
154
            tags = "raytracing_collide_";
155
        }
156
        else if (rayTracing.getStepsDone() >= rayTracing.getMaxSteps()) {
157
            tags = "raytracing_maxsteps_";
158
        }
159
        if (debug) {
160
            debugExtraCollisionDetails(player, rayTracing, "std");
161
        }
162
        rayTracing.cleanup();
163
        return tags;
164
    }
165
166
    /**
167
     * Default/normal margins.
168
     * @param rayTracing
169
     * @param from
170
     */
171
    private void setNormalMargins(final ICollidePassable rayTracing, final PlayerLocation from, final MovingConfig cc) {
172
        rayTracing.setMargins(from.getBoxMarginVertical() * cc.passableVerticalMargins, from.getWidth() / 2.0 * cc.passableHorizontalMargins); // max from/to + resolution ?
173
    }
174
175
    /**
176
     * Axis-wise ray-tracing violation skipping conditions.
177
     * 
178
     * @param player
179
     * @param from
180
     * @param to
181
     * @param manhattan
182
     * @param tags
183
     * @param data
184
     * @param cc
185
     * @return
186
     */
187
    private Location potentialViolation(final Player player, 
188
            final PlayerLocation from, final PlayerLocation to, 
189
            final int manhattan, final boolean debug,
190
            String tags, final MovingData data, final MovingConfig cc) {
191
192
        // TODO: Might need the workaround for fences.
193
194
        return actualViolation(player, from, to, tags, debug, data, cc);
195
    }
196
197
    private Location actualViolation(final Player player, 
198
            final PlayerLocation from, final PlayerLocation to,
199
            final String tags, final boolean debug,
200
            final MovingData data, final MovingConfig cc) {
201
        Location setBackLoc = null; // Alternative to from.getLocation().
202
203
        // Prefer the set back location from the data.
204
        if (data.hasSetBack()) {
205
            /*
206
             * TODO: Harmonize with MovingUtil.getApplicableSetBackLocation
207
             * (somehow include the desired set back type / loc / context).
208
             */
209
            setBackLoc = data.getSetBack(to); // TODO
210
            if (debug) {
211
                debug(player, "Using set back location for passable.");
212
            }
213
        }
214
215
        // Return the reset position.
216
        data.passableVL += 1d;
217
        final ViolationData vd = new ViolationData(this, player, data.passableVL, 1, cc.passableActions);
218
        if (debug || vd.needsParameters()) {
219
            vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
220
            vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
221
            vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", TrigUtil.distance(from, to)));
222
            if (!tags.isEmpty()) {
223
                vd.setParameter(ParameterName.TAGS, tags);
224
            }
225
        }
226
        if (executeActions(vd).willCancel()) {
227
            // TODO: Consider another set back position for this, also keeping track of players moving around in blocks.
228
            final Location newTo;
229
            if (setBackLoc != null) {
230
                // Ensure the given location is cloned.
231
                newTo = LocUtil.clone(setBackLoc);
232
            } else {
233
                newTo = from.getLocation();
234
                if (debug) {
235
                    debug(player, "Using from location for passable.");
236
                }
237
            }
238
            newTo.setYaw(to.getYaw());
239
            newTo.setPitch(to.getPitch());
240
            return newTo;
241
        }
242
        else{
243
            // No cancel action set.
244
            return null;
245
        }
246
    }
247
248
    /**
249
     * Debug only if colliding.
250
     * 
251
     * @param player
252
     * @param rayTracing
253
     * @param tag
254
     */
255
    private void debugExtraCollisionDetails(Player player, ICollidePassable rayTracing, String tag) {
256
        if (rayTracing.collides()) {
257
            debug(player, "Raytracing collision with order " + Arrays.toString(rayTracing.getAxisOrder()) 
258
            + " (" + tag + "): " + rayTracing.getCollidingAxis());
259
        }
260
        else if (rayTracing.getStepsDone() >= rayTracing.getMaxSteps()) {
261
            debug(player, "Raytracing max steps exceeded (" + tag + "): "+ rayTracing.getCollidingAxis());
262
        }
263
        // TODO: Detect having used past block changes and log or set a tag.
264
    }
265
266
}

How it counteracts this module

Passable ray-traces the player's swept collision volume between consecutive positions against the server's block cache and flags any transit whose box intersects a solid block's collision box, retrying alternate axis orders (YXZ, then YZX or XZY/ZXY) before giving up; a hit raises passableVL by 1 with 0.99 decay per clean move and returns a set-back location. The server's cache still contains the glass the client removed locally, so the phase move into that cell is a swept box crossing a solid face, which the ray trace collides on.

The initial-inside-block position is ignored (setIgnoreInitiallyColliding), so standing still inside the cell at rest is not flagged; the transit is what trips the check, which matches the module's behavior of walking through the removed cell. Every phase step that crosses the glass face accrues a violation until the set-back moves the player back out.

anticheat Phase (tesseract swept AABB)

Phase.java180 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.movement.position;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.MovementCheck;
23
import me.islandscout.hawk.event.MoveEvent;
24
import me.islandscout.hawk.util.*;
25
import me.islandscout.hawk.wrap.block.WrappedBlock;
26
import me.islandscout.hawk.wrap.entity.WrappedEntity;
27
import org.bukkit.GameMode;
28
import org.bukkit.Location;
29
import org.bukkit.Material;
30
import org.bukkit.block.Block;
31
import org.bukkit.entity.Player;
32
import org.bukkit.material.Openable;
33
import org.bukkit.util.Vector;
34
35
import java.util.*;
36
37
/**
38
 * The Phase check tests collision with blocks between players'
39
 * moves. Theoretically, this will effectively detect and block
40
 * any sort of phase, including v-clip. The bounding box of the
41
 * player is shrunk to reduce false positives, of course.
42
 */
43
public class Phase extends MovementCheck {
44
45
    //The way that this works is by geometry. Two AABBs represent the previous
46
    //and current position. They are inscribed within a new AABB. Then, planes
47
    //will cut through this AABB along the inscribed AABBs to form a tesseract.
48
    //This tesseract will then test against nearby blocks' collision boxes for
49
    //intersection.
50
51
    //decrease bounding box size if there are false positives.
52
    //(these values shrink the bounding box)
53
    private static final double TOP_EPSILON = 0.1;
54
    private static final double BOTTOM_EPSILON = 0.4;
55
    private static final double SIDE_EPSILON = 0.1;
56
57
    //Maximum distance per move for ignoring whitelisted blocks
58
    //too big, and you may have a gap for bypasses
59
    //too small, and you may have false positives
60
    //optimal threshold < (block depth + 0.6) - (2 * NMS_SIDE_EPSILON)
61
    private static final double HORIZONTAL_DISTANCE_THRESHOLD = Math.pow(0.4, 2);
62
    private static final double VERTICAL_DISTANCE_THRESHOLD = 1;
63
64
    public Phase() {
65
        super("phase", true, 0, 10, 0.995, 5000, "%player% failed phase. Moved through %block%. VL: %vl%", null);
66
    }
67
68
    @Override
69
    protected void check(MoveEvent event) {
70
        Location locTo = event.getTo();
71
        Location locFrom = event.getFrom();
72
        Player p = event.getPlayer();
73
        HawkPlayer pp = event.getHawkPlayer();
74
        if(!locFrom.getWorld().equals(locTo.getWorld()))
75
            return;
76
77
        //this stops both an NPE and crash
78
        double distanceSquared = locFrom.distanceSquared(locTo);
79
        if (distanceSquared == 0 || distanceSquared > 65)
80
            return;
81
82
        double horizDistanceSquared = Math.pow(locTo.getX() - locFrom.getX(), 2) + Math.pow(locTo.getZ() - locFrom.getZ(), 2);
83
        double vertDistance = Math.abs(locTo.getY() - locFrom.getY());
84
85
        Vector moveDirection = new Vector(locTo.getX() - locFrom.getX(), locTo.getY() - locFrom.getY(), locTo.getZ() - locFrom.getZ());
86
87
        AABB playerFrom = WrappedEntity.getWrappedEntity(p).getCollisionBox(locFrom.toVector());
88
        playerFrom.shrink(SIDE_EPSILON, 0, SIDE_EPSILON);
89
        playerFrom.getMin().setY(playerFrom.getMin().getY() + BOTTOM_EPSILON);
90
        playerFrom.getMax().setY(playerFrom.getMax().getY() - TOP_EPSILON);
91
        AABB playerTo = playerFrom.clone();
92
        playerTo.translate(moveDirection);
93
94
        Vector minBigBox = new Vector(Math.min(playerFrom.getMin().getX(), playerTo.getMin().getX()), Math.min(playerFrom.getMin().getY(), playerTo.getMin().getY()), Math.min(playerFrom.getMin().getZ(), playerTo.getMin().getZ()));
95
        Vector maxBigBox = new Vector(Math.max(playerFrom.getMax().getX(), playerTo.getMax().getX()), Math.max(playerFrom.getMax().getY(), playerTo.getMax().getY()), Math.max(playerFrom.getMax().getZ(), playerTo.getMax().getZ()));
96
        AABB bigBox = new AABB(minBigBox, maxBigBox);
97
98
        AABB selection = bigBox.clone();
99
        selection.getMin().setY(selection.getMin().getY() - 0.6); //we need to grab blocks below us too, such as fences
100
101
        Set<Location> ignored = pp.getIgnoredBlockCollisions();
102
103
        GameMode gm = p.getGameMode();
104
        if(gm == GameMode.SURVIVAL || gm == GameMode.ADVENTURE || gm == GameMode.CREATIVE) {
105
            for (int x = selection.getMin().getBlockX(); x <= selection.getMax().getBlockX(); x++) {
106
                for (int y = selection.getMin().getBlockY(); y <= selection.getMax().getBlockY(); y++) {
107
                    for (int z = selection.getMin().getBlockZ(); z <= selection.getMax().getBlockZ(); z++) {
108
109
                        Location blockLoc = new Location(locTo.getWorld(), x, y, z);
110
111
                        //Skip block if it updated within player AABB (only if they move slowly)
112
                        if(ignored.contains(blockLoc) && horizDistanceSquared <= HORIZONTAL_DISTANCE_THRESHOLD && vertDistance <= VERTICAL_DISTANCE_THRESHOLD)
113
                            continue;
114
115
                        Block bukkitBlock = ServerUtils.getBlockAsync(blockLoc);
116
117
                        if (bukkitBlock == null)
118
                            continue;
119
120
                        WrappedBlock block = WrappedBlock.getWrappedBlock(bukkitBlock, pp.getClientVersion());
121
                        if (!block.isSolid())
122
                            continue;
123
124
                        //Prevent falses with pistons
125
                        if(bukkitBlock.getType() == Material.PISTON_MOVING_PIECE) {
126
                            continue;
127
                        }
128
129
                        //Prevent common falses with openables
130
                        if (bukkitBlock.getState().getData() instanceof Openable && horizDistanceSquared <= HORIZONTAL_DISTANCE_THRESHOLD && vertDistance <= VERTICAL_DISTANCE_THRESHOLD) {
131
                            continue;
132
                        }
133
134
                        for (AABB test : block.getCollisionBoxes()) {
135
                            //check if "test" box is even in "bigBox"
136
                            if (!test.isColliding(bigBox))
137
                                continue;
138
139
                            boolean xCollide = collides2d(test.getMin().getZ(), test.getMax().getZ(), test.getMin().getY(), test.getMax().getY(), playerFrom.getMin().getZ(), playerFrom.getMax().getZ(), playerFrom.getMin().getY(), playerFrom.getMax().getY(), moveDirection.getZ(), moveDirection.getY());
140
                            boolean yCollide = collides2d(test.getMin().getX(), test.getMax().getX(), test.getMin().getZ(), test.getMax().getZ(), playerFrom.getMin().getX(), playerFrom.getMax().getX(), playerFrom.getMin().getZ(), playerFrom.getMax().getZ(), moveDirection.getX(), moveDirection.getZ());
141
                            boolean zCollide = collides2d(test.getMin().getX(), test.getMax().getX(), test.getMin().getY(), test.getMax().getY(), playerFrom.getMin().getX(), playerFrom.getMax().getX(), playerFrom.getMin().getY(), playerFrom.getMax().getY(), moveDirection.getX(), moveDirection.getY());
142
                            if (xCollide && yCollide && zCollide) {
143
                                punish(pp, false, event, new Placeholder("block", bukkitBlock.getType()));
144
                                tryRubberband(event);
145
                                return;
146
                            }
147
                        }
148
                    }
149
                }
150
            }
151
        }
152
153
        reward(pp);
154
    }
155
156
    //2d collision test. check if hexagon collides with rectangle
157
    private boolean collides2d(double testMinX, double testMaxX, double testMinY, double testMaxY, double otherMinX, double otherMaxX, double otherMinY, double otherMaxY, double otherExtrudeX, double otherExtrudeY) {
158
        if (otherExtrudeX == 0)
159
            return true; //prevent division by 0
160
        double slope = otherExtrudeY / otherExtrudeX;
161
        double height;
162
        double height2;
163
        Coordinate2D lowerPoint;
164
        Coordinate2D upperPoint;
165
        if (otherExtrudeX > 0) { //extruding to the right
166
            height = -(slope * (otherExtrudeY > 0 ? otherMaxX : otherMinX)) + otherMinY;
167
            height2 = -(slope * (otherExtrudeY > 0 ? otherMinX : otherMaxX)) + otherMaxY;
168
            lowerPoint = new Coordinate2D((otherExtrudeY > 0 ? testMaxX : testMinX), testMinY);
169
            upperPoint = new Coordinate2D((otherExtrudeY > 0 ? testMinX : testMaxX), testMaxY);
170
        } else { //extruding to the left
171
            height = -(slope * (otherExtrudeY <= 0 ? otherMaxX : otherMinX)) + otherMinY;
172
            height2 = -(slope * (otherExtrudeY <= 0 ? otherMinX : otherMaxX)) + otherMaxY;
173
            lowerPoint = new Coordinate2D((otherExtrudeY <= 0 ? testMaxX : testMinX), testMinY);
174
            upperPoint = new Coordinate2D((otherExtrudeY <= 0 ? testMinX : testMaxX), testMaxY);
175
        }
176
        Line lowerLine = new Line(height, slope);
177
        Line upperLine = new Line(height2, slope);
178
        return (lowerPoint.getY() <= upperLine.getYatX(lowerPoint.getX()) && upperPoint.getY() >= lowerLine.getYatX(upperPoint.getX()));
179
    }
180
}

How it counteracts this module

Hawk's Phase check builds the swept volume between the previous and current player boxes, shrunk by side 0.1, bottom 0.4 and top 0.1 epsilons to cut false positives, tests it as a tesseract against every nearby solid block's collision boxes from the server's world, and on a three-axis hit calls punish with a rubber-band. Walking into the glass cell that the client un-rendered is a direct hit: the server world still has the solid glass, and the swept box intersects it on every move.

The whitelist carve-outs (blocks updated within the player AABB, openable blocks) do not cover a block the client merely removed locally, because no update ever reached the server. The module's setBlockToAir only changes local rendering and collision, which is exactly the discrepancy the check is built to measure.

anticheat MorePackets (flush burst)

MorePackets.java127 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.moving.player;
16
17
import java.util.ArrayList;
18
import java.util.List;
19
20
import org.bukkit.Location;
21
import org.bukkit.entity.Player;
22
23
import fr.neatmonster.nocheatplus.actions.ParameterName;
24
import fr.neatmonster.nocheatplus.checks.Check;
25
import fr.neatmonster.nocheatplus.checks.CheckType;
26
import fr.neatmonster.nocheatplus.checks.ViolationData;
27
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
28
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
29
import fr.neatmonster.nocheatplus.checks.net.NetStatic;
30
import fr.neatmonster.nocheatplus.players.IPlayerData;
31
import fr.neatmonster.nocheatplus.utilities.StringUtil;
32
import fr.neatmonster.nocheatplus.utilities.location.PlayerLocation;
33
34
/**
35
 * The MorePackets check will try to identify players that send more than the usual
36
 * amount of move-packets to the server to be able to move faster than normal, without getting caught by the other
37
 * checks (flying/running).
38
 */
39
public class MorePackets extends Check {
40
41
    private final List<String> tags = new ArrayList<String>();
42
43
    /**
44
     * Instantiates a new more packets check.
45
     */
46
    public MorePackets() {
47
        super(CheckType.MOVING_MOREPACKETS);
48
    }
49
50
    /**
51
     * Check for speeding by sending too many packets. We assume 22 packets per
52
     * second to be legitimate, while 20 would be ideal. See
53
     * PlayerData.morePacketsFreq for the monitored amount of time and the
54
     * resolution. See NetStatic for the actual check code.
55
     * 
56
     * @param player
57
     * @param from
58
     * @param to
59
     * @param allowSetSetBack
60
     *            If to allow setting the set back location.
61
     * @param data
62
     * @param cc
63
     * @return
64
     */
65
    public Location check(final Player player, final PlayerLocation from, final PlayerLocation to, 
66
            final boolean allowSetSetBack, final MovingData data, final MovingConfig cc,
67
            final IPlayerData pData) {
68
        // Take time once, first:
69
        final long time = System.currentTimeMillis();
70
        final boolean debug = pData.isDebugActive(type);
71
72
        //    	if (from.isSamePos(to)) {
73
        //    		// Ignore moves with "just look" for now.
74
        //    		// TODO: Extra ActionFrequency for "just look" + use to burn, maybe also check individually.
75
        //    		return null;
76
        //    	}
77
78
        // Ensure we have a set back location.
79
        if (allowSetSetBack && !data.hasMorePacketsSetBack()){
80
            // TODO: Check if other set back is appropriate or if to set/reset on other events.
81
            if (data.hasSetBack()) {
82
                data.setMorePacketsSetBackFromSurvivalfly();
83
            }
84
            else {
85
                data.setMorePacketsSetBack(from);
86
            }
87
        }
88
89
        // Check for a violation of the set limits.
90
        tags.clear();
91
        final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstDirect, cc.morePacketsBurstEPM, tags);
92
93
        // Process violation result.
94
        if (violation > 0.0) {
95
            // Increment violation level.
96
            data.morePacketsVL = violation; // TODO: Accumulate somehow [e.g. always += 1, decrease with continuous moving without violation]?
97
98
            // Violation handling.
99
            final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, violation, cc.morePacketsActions);
100
            if (debug || vd.needsParameters()) {
101
                vd.setParameter(ParameterName.PACKETS, Integer.toString(new Double(violation).intValue()));
102
                vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
103
            }
104
            if (executeActions(vd).willCancel()) {
105
                // Set to cancel the move.
106
                /*
107
                 * TODO: Harmonize with MovingUtil.getApplicableSetBackLocation
108
                 * (somehow include the desired set back type / loc / context).
109
                 */
110
                return data.hasMorePacketsSetBack() ? data.getMorePacketsSetBack() : data.getSetBack(to); // TODO
111
            }
112
        } 
113
        else if (allowSetSetBack && data.getMorePacketsSetBackAge() > cc.morePacketsSetBackAge) {
114
            // Update the set back location. (CHANGED to only update, if not a violation.)
115
            // (Might update whenever newTo == null)
116
            data.setMorePacketsSetBack(from);
117
            if (debug) {
118
                debug(player, "Update set back (morepackets) to from.");
119
            }
120
        }
121
122
        // No set back.
123
        return null;
124
125
    }
126
127
}

How it counteracts this module

MorePackets counts every serverbound move packet into an ActionFrequency with 500ms buckets and scores the window against cc.morePacketsEPSMax (22 per second, 20 ideal), with a burst path on the newest half-second bucket (15 packets, 10 direct-violation). The disable-time flush replays every queued C03 in one tick: a phase held for two to three seconds withholds 40 to 60 movement packets, and the flush lands them all in a single burst that exceeds the direct-violation threshold immediately.

The suppression itself is the other half of the exposure: while phasing, the server sees a player who stops sending movement packets entirely, a blink-like signature that the burst check then punctuates when the queue drains. The flush cannot be spread out because disable() runs synchronously in one tick.

← Back to Analysis Hub