Tenacity 6.0 Phase module 2 files, 122 lines

Tenacity 6.0 Phase: Full Source Analysis

Tenacity's Phase is a no-move desync module with no settings and no packet construction of its own.

dev/tenacity/module/impl/player/PhaseModule.java · GitHub source ↗

Published 2026-08-13 · Updated 2026-10-14

Packets This Module Uses

Analysis

Overview

Tenacity's Phase is a no-move desync module with no settings and no packet construction of its own. While enabled it cancels every MotionEvent, so the vanilla movement path emits no C03 for the tick and the server's copy of the player freezes at the last reported position while the local player keeps moving. The client-side position drifts out of sync with the server entity, which is what lets the player pass through blocks on the server's model. Each tick also writes the truncated client x into the server-position tracker. A TimerUtil field and a player field are allocated but never used. The desynced position only reaches the server when the module is toggled off and the next movement packet reports it.

Architecture

The module registers a single IEventListener on MotionEvent and nothing else: no settings, no enable-time setup, no disable-time cleanup. The handler cancels the event and writes serverPosX, and the constructor allocates a TimerUtil and a player field that no code path ever touches, leftovers from an earlier revision. Because the class carries no state, toggling is stateless; the entire behavior is the per-tick cancellation.

Cancellation mechanics

MotionEvent is the pre-motion event whose x, y, z, yaw, pitch and onGround fields serialize into the outgoing C03. setCanceled(true) makes the vanilla send path skip that packet for the tick, so the server never learns the player's new position and keeps the entity at the last reported location. The serverPosX = (int) posX line writes the truncated client x into the client's server-position tracker, keeping that tracker aligned with the client while no packets flow, a one-line bookkeeping tweak that has no wire effect of its own.

Desync consequence

The gap between the client-side position and the server-tracked position grows for as long as the module stays on: the local player walks freely while the server entity stands still, so server-side collision and anticheat checks evaluate against a stale location. When the module is toggled off, the next tick's movement packet reports the phased position as a single move from the stale server location, and the server's own validation, or any anticheat positioned in between, sees a move that crossed solid geometry. The module itself never sends a packet; its entire fingerprint is the absence of movement traffic followed by one reconciling move.

source PhaseModule.java

PhaseModule.java31 lines · JavaOriginal ↗
1
package dev.tenacity.module.impl.player;
2
3
import dev.tenacity.event.IEventListener;
4
import dev.tenacity.event.impl.player.MotionEvent;
5
import dev.tenacity.module.Module;
6
import dev.tenacity.module.ModuleCategory;
7
import dev.tenacity.setting.impl.ModeSetting;
8
import dev.tenacity.util.misc.TimerUtil;
9
import net.minecraft.entity.player.EntityPlayer;
10
import net.minecraft.network.play.client.C03PacketPlayer;
11
import net.minecraft.util.AxisAlignedBB;
12
13
import static net.minecraft.command.CommandBase.getPlayer;
14
15
public final class PhaseModule extends Module {
16
17
    private final TimerUtil timerUtil = new TimerUtil();
18
19
    public PhaseModule() {
20
        super("Phase", "Phase through blocks", ModuleCategory.PLAYER);
21
    }
22
23
    private final IEventListener<MotionEvent> onMotionEvent = event -> {
24
        EntityPlayer player = event.getPlayer();
25
        if (this.isEnabled()) {
26
            event.setCanceled(true);
27
            mc.thePlayer.serverPosX = (int) (mc.thePlayer.posX);
28
        }
29
    };
30
    private EntityPlayer player;
31
}

What this file does

The whole module: the single MotionEvent listener that cancels every pre-motion event and re-aligns the server-position tracker, plus two dead fields (TimerUtil and an EntityPlayer) that are allocated and never referenced. The event listener is registered in the field initializer, so the behavior is active from construction. There is no settings object, no onEnable/onDisable logic and no packet construction anywhere in the class.

source MotionEvent.java (pre-motion carrier)

MotionEvent.java91 lines · JavaOriginal ↗
1
package dev.tenacity.event.impl.player;
2
3
import dev.tenacity.event.Event;
4
import net.minecraft.entity.player.EntityPlayer;
5
6
public final class MotionEvent extends Event {
7
    private boolean canceled = false;
8
9
    public void setCanceled(boolean canceled) {
10
        this.canceled = canceled;
11
    }
12
13
    public boolean isCanceled() {
14
        return canceled;
15
    }
16
    private double x, y, z;
17
    private float yaw, pitch;
18
    private boolean onGround;
19
20
    public MotionEvent(final double x, final double y, final double z, final float yaw, final float pitch, final boolean onGround) {
21
        this.x = x;
22
        this.y = y;
23
        this.z = z;
24
        this.yaw = yaw;
25
        this.pitch = pitch;
26
        this.onGround = onGround;
27
    }
28
29
    public double getX() {
30
        return x;
31
    }
32
33
    public double getY() {
34
        return y;
35
    }
36
37
    public double getZ() {
38
        return z;
39
    }
40
41
    public float getYaw() {
42
        return yaw;
43
    }
44
45
    public float getPitch() {
46
        return pitch;
47
    }
48
49
    public boolean isOnGround() {
50
        return onGround;
51
    }
52
53
    public void setX(final double x) {
54
        this.x = x;
55
    }
56
57
    public void setY(final double y) {
58
        this.y = y;
59
    }
60
61
    public void setZ(final double z) {
62
        this.z = z;
63
    }
64
65
    public void setYaw(final float yaw) {
66
        this.yaw = yaw;
67
    }
68
69
    public void setPitch(final float pitch) {
70
        this.pitch = pitch;
71
    }
72
73
    public void setOnGround(final boolean onGround) {
74
        this.onGround = onGround;
75
    }
76
    private EntityPlayer player;
77
78
    public MotionEvent(EntityPlayer player, double x, double y, double z, float yaw, float pitch, boolean onGround) {
79
        this.player = player;
80
        this.x = x;
81
        this.y = y;
82
        this.z = z;
83
        this.yaw = yaw;
84
        this.pitch = pitch;
85
        this.onGround = onGround;
86
    }
87
    public EntityPlayer getPlayer() {
88
        return this.player;
89
    }
90
}

What this file does

The pre-motion event the module cancels. Its x, y, z, yaw, pitch and onGround fields mirror the values the vanilla movement send path writes into the next C03PacketPlayer, and the cancel flag is the module's entire lever: a canceled event means no C03 leaves the client for that tick. The event also carries the player reference that PhaseModule's dead field mirrors, and its constructor is invoked by the client's movement pipeline once per tick, which is the cadence of the cancellation.

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-path 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

NoCheatPlus's Passable is the block-intersection check for movement. On every accepted move it ray-traces from the previous location to the new one with PassableAxisTracing, using margins derived from the player's box (box margin vertical times passableVerticalMargins, half the width times passableHorizontalMargins), and when the trace reports a collision it increments passableVL and returns a set-back location (the stored set-back if one exists, otherwise the from location), so the player is snapped back to the last valid position with the new rotation preserved. The optional BlockChangeTracker widens the path so recently changed blocks are considered.\n\nWhile the module is on, no moves arrive and nothing is checked; the check engages the moment the module is toggled off and the reconciling C03 reports the phased position. The ray from the stale server location to the reported one sweeps through whatever solid geometry the player crossed, the trace collides, and the player is set back to the pre-phase position. The margin configuration is the tolerance: small genuine clips into non-solid edges pass, but a wall crossed while the server entity stood still is a full collision.

anticheat Phase (swept-AABB geometry)

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 is pure geometry: it inscribes the previous and current player AABBs inside a bounding box and cuts the swept volume into a tesseract of collision planes, then tests every nearby block's collision box against it. The player box is shrunk by epsilon (0.1 sides, 0.4 bottom, 0.1 top) to avoid false positives, blocks below the sweep are included for fences, and the check bails on moves whose squared distance exceeds 65 (teleport-scale moves) or equals zero, on piston moving pieces, and on openable blocks when the move is small. Any solid block intersecting the swept volume punishes and rubber-bands the player.\n\nThe desync re-sync move is the trigger: when the module toggles off and the next move spans the wall the player crossed, the swept volume between the two AABB positions intersects the wall's collision box and the check punishes. The 65-block bail is the honest gap: a phase that drifts far enough that the reconciling move looks like a teleport is skipped, so the check reliably catches short phases through adjacent geometry and the module's own freeze-then-report pattern is exactly what feeds it.

anticheat Phase (post-prediction intersection)

Phase.java53 lines · Java
1
package ac.grim.grimac.checks.impl.prediction;
2
3
import ac.grim.grimac.checks.Check;
4
import ac.grim.grimac.checks.CheckData;
5
import ac.grim.grimac.checks.type.PostPredictionListener;
6
import ac.grim.grimac.player.GrimPlayer;
7
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
8
import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
9
import ac.grim.grimac.utils.nmsutil.Collisions;
10
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
11
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
12
import com.github.retrooper.packetevents.protocol.world.states.defaulttags.BlockTags;
13
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
14
15
import java.util.ArrayList;
16
import java.util.List;
17
18
@CheckData(name = "Phase", stableKey = "grim.prediction.phase", description = "Moved into a solid block during movement prediction", setback = 1, decay = 0.005)
19
public class Phase extends Check implements PostPredictionListener {
20
    private SimpleCollisionBox oldBB;
21
22
    public Phase(GrimPlayer player) {
23
        super(player);
24
        oldBB = player.boundingBox;
25
    }
26
27
    @Override
28
    public void onPredictionComplete(final PredictionComplete predictionComplete) {
29
        if (!player.getSetbackTeleportUtil().blockOffsets && !predictionComplete.getData().isTeleport() && predictionComplete.isChecked()) { // Not falling through world
30
            SimpleCollisionBox newBB = player.boundingBox;
31
32
            List<SimpleCollisionBox> boxes = new ArrayList<>();
33
            Collisions.getCollisionBoxes(player, newBB, boxes, false);
34
35
            for (SimpleCollisionBox box : boxes) {
36
                if (newBB.isIntersected(box) && !oldBB.isIntersected(box)) {
37
                    if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
38
                        // A bit of a hacky way to get the block state, but this is much faster to use the tuinity method for grabbing collision boxes
39
                        WrappedBlockState state = player.compensatedWorld.getBlock((box.minX + box.maxX) / 2, (box.minY + box.maxY) / 2, (box.minZ + box.maxZ) / 2);
40
                        if (BlockTags.ANVIL.contains(state.getType()) || state.getType() == StateTypes.CHEST || state.getType() == StateTypes.TRAPPED_CHEST) {
41
                            continue; // 1.8 glitchy block, ignore
42
                        }
43
                    }
44
                    flagWithSetback();
45
                    return;
46
                }
47
            }
48
        }
49
50
        oldBB = player.boundingBox;
51
        reward();
52
    }
53
}

How it counteracts this module

Grim's Phase runs as a PostPredictionListener after the movement prediction engine has simulated the tick. It keeps the previous tick's bounding box and, for every checked, non-teleport prediction, gathers the collision boxes under the new box and flags when the new box intersects one the old box did not, with a 1.8-only exemption for anvils, chests and trapped chests, whose glitchy collision in that version is known to false-positive. Flags carry a setback of 1 and a decay of 0.005, so the violation drains slowly.\n\nThe reconciling move after disable reports a position inside the geometry the client crossed; the prediction simulates that move, the new bounding box intersects a collision box the pre-move box did not, and the check flags with a setback. The exemption list is the tolerance: on 1.8.9 the check deliberately ignores the glitchy-block set, so phasing through an anvil or chest row passes where any other solid flags. Teleport-scale reconciles are skipped by the isTeleport guard, mirroring the same gap Hawk's 65-block bail leaves.

← Back to Analysis Hub