Tenacity 6.0 FastBow module 2 files, 145 lines

Tenacity 6.0 FastBow: Full Source Analysis

Tenacity's FastBow is a two-mode bow-spam module driven by the pre-motion event.

dev/tenacity/module/impl/combat/FastBow.java · GitHub source ↗

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

Packets This Module Uses

Analysis

Overview

Tenacity's FastBow is a two-mode bow-spam module driven by the pre-motion event. While right-click is held with a bow equipped, the Vanilla mode pushes forty C03-family packets per tick (twenty C05 look packets and twenty C06 position-look packets, all claiming onGround), resets the right-click delay timer to zero so the bow re-charges instantly, closes the flood with a flag-only C03(true), and walks the vanilla release path, so the server fires an arrow every tick. The Ghostly mode drops the position pairs and spams twenty flag-only C03(true) packets before the same release call. The module constructs C03 subclasses exclusively; C02PacketUseEntity is the attack-registration companion of the instant-fire flow. onDisable restores the right-click delay to its vanilla value of 4.

Architecture

The module registers one IEventListener on MotionEvent, the pre-motion event that fires once per client tick, and switches on a two-option ModeSetting with Vanilla as the default and Ghostly as the only alternative. The handler early-returns when nothing is equipped, then checks Mouse.isButtonDown(1) and ItemBow instanceof against the equipped item, so the spam only runs while the player is actually holding right-click with a bow. The constructor registers only the mode setting, and onDisable writes rightClickDelayTimer = 4, restoring the vanilla four-tick gate between item uses that the flood had been zeroing.

The Vanilla flood

The Vanilla branch runs a 20-iteration loop, and each iteration pushes two packets: C05PacketPlayerLook with the current yaw and pitch and onGround true, then C06PacketPlayerPosLook with the player's real posX, the bounding-box minY (feet level), posZ, yaw, pitch and onGround true, followed by rightClickDelayTimer = 0. After the loop it pushes a plain flag-only C03(true) and calls onStoppedUsingItem. That is 41 C03-family packets per motion tick, roughly 820 per second at 20 TPS. Because every C06 re-asserts the true position, the server's tracked location never drifts, while the onGround-true claims on all 41 packets reset the server-side fall-distance accounting and keep the movement validators lenient across the burst.

The release chain

The zeroed rightClickDelayTimer lets the next right-click begin charging the bow immediately, and onStoppedUsingItem walks the vanilla release path (stopUsingItem plus the release packet through the send queue), so each tick starts a charge and instantly releases it. The server fires one arrow per tick with whatever charge the client reports, which is the entire point of the flood: the position and ground noise keeps the rapid release inside the server's movement validation while the bow cycles at 20 shots per second. The Ghostly branch is the same cycle without the position noise: twenty flag-only C03(true) packets per tick, then the release. Both modes therefore produce a flat, featureless C03 rate far above what the movement path alone can generate.

Wire shape

Every packet the module builds is a C03PacketPlayer subclass: C05 (look only), C06 (position and look) and the plain flag-only C03. The packets list also carries C02PacketUseEntity as the attack-path companion: the instant-release stream is what lets arrow hits land inside the spam window, and anticheats that count entity-attack rate see the bow burst and the C02 attacks that follow it as one combined combat spike.

source FastBow.java

FastBow.java54 lines · JavaOriginal ↗
1
package dev.tenacity.module.impl.combat;
2
3
import dev.tenacity.module.ModuleCategory;
4
import dev.tenacity.module.Module;
5
import dev.tenacity.event.IEventListener;
6
import dev.tenacity.event.impl.player.MotionEvent;
7
import dev.tenacity.setting.impl.ModeSetting;
8
import net.minecraft.item.ItemBow;
9
import net.minecraft.network.play.client.C03PacketPlayer;
10
import org.lwjgl.input.Mouse;
11
12
13
public final class FastBow extends Module {
14
15
    private final ModeSetting mode = new ModeSetting("Mode", "Vanilla", "Ghostly");
16
17
    private final IEventListener<MotionEvent> motionEventEventListener = event -> {
18
        if(mc.thePlayer.getCurrentEquippedItem() == null) return;
19
        switch (mode.getCurrentMode()) {
20
            case "Vanilla":
21
                if (Mouse.isButtonDown(1) && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBow) {
22
                    for (int i = 0; i < 20; ++i) {
23
                        mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true));
24
                        mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(mc.thePlayer.posX, mc.thePlayer.getEntityBoundingBox().minY, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true));
25
                        mc.rightClickDelayTimer = 0;
26
                    }
27
                    mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
28
                    mc.playerController.onStoppedUsingItem(mc.thePlayer);
29
                }
30
                break;
31
            case "Ghostly":
32
                if(Mouse.isButtonDown(1) && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBow){
33
                    for(int i = 0; i < 20; i++){
34
35
                        mc.rightClickDelayTimer = 0;
36
                       mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
37
                    }
38
                    mc.playerController.onStoppedUsingItem(mc.thePlayer);
39
                }
40
                break;
41
        }
42
    };
43
44
    @Override
45
    public void onDisable(){
46
        mc.rightClickDelayTimer = 4;
47
        super.onDisable();
48
    }
49
50
    public FastBow() {
51
        super("Fastbow", "shoot bows faster", ModuleCategory.COMBAT);
52
        initializeSettings(mode);
53
    }
54
}

What this file does

The whole module: the two-option ModeSetting, the single MotionEvent listener, and the two spam loops. The Vanilla branch's 20-iteration C05/C06 pair loop plus the closing C03(true) and the release call is the full 41-packets-per-tick flood; the Ghostly branch drops to 20 flag-only C03(true) packets. Mouse.isButtonDown(1) is polled rather than listened to, so the burst starts the instant right-click is held. The onDisable override restores rightClickDelayTimer to 4, which is the vanilla item-use gate the flood had been suppressing.

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 flood hooks. Its x, y, z, yaw, pitch and onGround fields mirror the values the vanilla movement send path writes into the next C03PacketPlayer, and its constructor is invoked by the client's movement pipeline once per tick, the exact cadence the 41-packet burst follows. The event also carries a cancel flag and a player reference, though FastBow uses neither; the listener simply runs once per dispatch and pushes its packets straight into the send queue.

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 MorePackets (movement packet rate)

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

NoCheatPlus's MorePackets counts the raw rate of serverbound move packets, content-blind. MovingListener invokes it on every processed move, scoring each into data.morePacketsFreq, an ActionFrequency with 500ms buckets over the configured window, and NetStatic.morePacketsCheck accumulates the window against cc.morePacketsEPSMax (default 22 packets per second, ideal 20) with a separate half-second burst path (default 15 packets, direct-violation 10, 95 burst events per minute) and lag adaption. A violation returns the morePacketsSetBack location, seeded from the SurvivalFly set-back when one exists, so the player is snapped back on top of the movement check.\n\nThe flood is the direct target: 41 C03-family packets per motion tick is roughly 820/s sustained, thirty-seven times the 22/s ceiling, so vEPSAcc stays positive for the whole window and the set-back fires immediately. The half-second burst path also trips on the very first tick's 41 packets. Because the check scores every C03 subclass the module sends (including the C06 packets that re-assert the true position), the flood cannot shed its rate by keeping the position stable, and because the check never inspects position, the onGround-true noise buys nothing.

anticheat InstantBow (bow pull duration)

InstantBow.java99 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.inventory;
16
17
import org.bukkit.ChatColor;
18
import org.bukkit.entity.Player;
19
20
import fr.neatmonster.nocheatplus.checks.Check;
21
import fr.neatmonster.nocheatplus.checks.CheckType;
22
import fr.neatmonster.nocheatplus.permissions.Permissions;
23
import fr.neatmonster.nocheatplus.players.DataManager;
24
import fr.neatmonster.nocheatplus.players.IPlayerData;
25
import fr.neatmonster.nocheatplus.utilities.TickTask;
26
27
/**
28
 * Legacy check. It will find out if a player pulled the string of their bow too fast. <br>
29
 * Will be disabled on 1.8 and later.
30
 */
31
public class InstantBow extends Check {
32
33
    private static final float maxTime = 800f;
34
35
    /**
36
     * Instantiates a new instant bow check.
37
     */
38
    public InstantBow() {
39
        super(CheckType.INVENTORY_INSTANTBOW);
40
    }
41
42
    /**
43
     * Checks a player.
44
     * 
45
     * @param player
46
     *            the player
47
     * @param force
48
     *            the force
49
     * @param now
50
     * @return true, if successful
51
     */
52
    public boolean check(final Player player, final float force, final long now) {
53
        final IPlayerData pData = DataManager.getPlayerData(player);
54
        final InventoryData data = pData.getGenericInstance(InventoryData.class);
55
        final InventoryConfig cc = pData.getGenericInstance(InventoryConfig.class);
56
        boolean cancel = false;
57
        /** Rough estimation of how long pulling the string should've taken */
58
        final long expectedPullDuration = (long) (maxTime - maxTime * (1f - force) * (1f - force)) - cc.instantBowDelay;
59
        /** Time taken to pull the string */
60
        final long pullDuration;
61
        final boolean valid;
62
        // The interact time is invalid, if set to 0.
63
        valid = cc.instantBowStrict ? data.instantBowInteract != 0 : true;
64
        pullDuration = cc.instantBowStrict ? (valid ? (now - data.instantBowInteract) : 0L) : (now - data.instantBowShoot);
65
66
        if (valid && (!cc.instantBowStrict || data.instantBowInteract > 0L) && pullDuration >= expectedPullDuration) {
67
            // The player was slow enough, reward them by lowering their violation level.
68
            data.instantBowVL *= 0.9D;
69
        }
70
        else if (valid && data.instantBowInteract > now) {
71
            // Security check if time ran backwards.
72
            // TODO: Maybe this can be removed, though TickTask does not reset at the exact moment.
73
        }
74
        else {
75
            // Account for server side lag.
76
            // (Do not apply correction to invalid pulling.)
77
            final long correctedPullduration = valid ? 
78
                                               (pData.getCurrentWorldData().shouldAdjustToLag(type) ? (long) (TickTask.getLag(expectedPullDuration, true) * pullDuration) : pullDuration) 
79
                                                : 0;
80
            if (correctedPullduration < expectedPullDuration) {
81
                // TODO: Consider: Allow one time but set yawrate penalty time ?
82
                final double difference = (expectedPullDuration - pullDuration) / 100D;
83
                // Player was too fast, increase their violation level.
84
                data.instantBowVL += difference;
85
                // Execute whatever actions are associated with this check and the violation level and find out if we should cancel the event
86
                cancel = executeActions(player, data.instantBowVL, difference, cc.instantBowActions).willCancel();
87
            }
88
        }
89
90
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
91
            player.sendMessage(ChatColor.YELLOW + "NCP: " + ChatColor.GRAY + "Bow shot - force: " + force +", " + (cc.instantBowStrict || pullDuration < 2 * expectedPullDuration ? ("pull time: " + pullDuration) : "") + "(" + expectedPullDuration +")");
92
        }
93
94
        // Reset data here.
95
        data.instantBowInteract = 0;
96
        data.instantBowShoot = now;
97
        return cancel;
98
    }
99
}

How it counteracts this module

NoCheatPlus's InstantBow is the archetypal bow-rapidity check. It estimates the expected pull duration from the released arrow's force with the parabola maxTime - maxTime * (1 - force)^2 minus the configured delay (maxTime 800ms), and compares it against the measured time between the previous shot (or, in strict mode, the item interact) and the current one. A pull that finishes before the expected duration adds (expected - pull) / 100 to instantBowVL and runs the configured actions; a pull at or above the expectation decays the VL by 0.9. Server lag is folded in through TickTask, and a debug message reports force and pull time.\n\nThe per-tick release cycle is exactly the shape the check measures: each onStoppedUsingItem arrives a few tens of milliseconds after the previous one, far under the 800ms parabola even for near-zero force, so every shot adds to instantBowVL. The honest caveat is the class's own comment: the check is legacy and disabled on 1.8 and later, so on 1.8.9 servers the pull-timing path is off and the flood falls entirely to the rate checks (MorePackets), which is why those are the primary counters and InstantBow remains the reference design every modern bow check descends from.

anticheat MorePackets (per-second packet rate)

MorePackets.java49 lines · Java
1
package me.vrekt.arc.check.moving;
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.moving.MovingData;
7
import org.bukkit.Bukkit;
8
import org.bukkit.ChatColor;
9
import org.bukkit.entity.Player;
10
11
public class MorePackets extends Check {
12
13
    private int maxPackets, kickThreshold = 0;
14
15
    public MorePackets() {
16
        super(CheckType.MOREPACKETS);
17
18
        maxPackets = Arc.getCheckManager().getValueInt(CheckType.MOREPACKETS, "max-packets");
19
        kickThreshold = Arc.getCheckManager().getValueInt(CheckType.MOREPACKETS, "max-packets-kick");
20
    }
21
22
    public boolean check(Player player, MovingData data) {
23
24
        int flyingPackets = data.getFlyingPackets();
25
        int movingPackets = data.getPositionPackets();
26
27
        // check if we are sending more packets then allowed.
28
        if (flyingPackets > maxPackets || movingPackets > maxPackets) {
29
            checkViolation(player, "sending too many packets");
30
            if (flyingPackets > kickThreshold || movingPackets > kickThreshold) {
31
                // we are sending over the limit, kick.
32
                Bukkit.getScheduler().runTaskLater(Arc.getPlugin(), () -> {
33
                    // broadcast to staff.
34
                    Bukkit.broadcast(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Arc" + ChatColor.DARK_GRAY + "] " + ChatColor.BLUE
35
                            + player.getName() + ChatColor.WHITE + " was kicked for sending too many packets. ", "arc.violations");
36
                    // prevent async player kick.
37
                    player.kickPlayer("You are sending too many packets.");
38
                }, 5);
39
                return false;
40
            }
41
            data.setCancelMovingPackets(true);
42
            return true;
43
        }
44
45
        data.setCancelMovingPackets(false);
46
        return false;
47
    }
48
49
}

How it counteracts this module

Vrekt's MorePackets counts flying packets and position packets per second separately against two thresholds read from config: max-packets 30 and max-packets-kick 70. When either counter exceeds maxPackets it calls checkViolation("sending too many packets"), cancels incoming movement packets via setCancelMovingPackets(true), and returns; when either exceeds the kick threshold it schedules a broadcast and a kick through the Bukkit scheduler instead.\n\nThe fastbow burst presents 41 flying packets (the C05 look packets and the flag-only C03) and 20 position packets (the C06 poslook packets) in a single tick, so both counters blow past the 30/s violation threshold on the first tick and past the 70/s kick threshold within two. The check is per-second and content-blind, so the onGround-true noise and the stable re-asserted position are irrelevant; the only mitigation would be spreading the burst, which is exactly what the module's per-tick loop cannot do.

anticheat Timer (player-clock balance)

Timer.java113 lines · Java
1
package ac.grim.grimac.checks.impl.timer;
2
3
import ac.grim.grimac.api.config.ConfigManager;
4
import ac.grim.grimac.checks.Check;
5
import ac.grim.grimac.checks.CheckData;
6
import ac.grim.grimac.checks.type.PrePredictionPacketReceiveListener;
7
import ac.grim.grimac.player.GrimPlayer;
8
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
9
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
10
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
11
import org.jetbrains.annotations.NotNull;
12
13
@CheckData(name = "Timer", stableKey = "grim.timer.timer", configName = "TimerA", description = "The players game is running faster than normal", setback = 10)
14
public class Timer extends Check implements PrePredictionPacketReceiveListener {
15
    protected long timerBalanceRealTime = 0;
16
17
    // Default value is real time minus max keep-alive time
18
    protected long knownPlayerClockTime = (long) (System.nanoTime() - 6e10);
19
    protected long lastMovementPlayerClock = (long) (System.nanoTime() - 6e10);
20
21
    // How long should the player be able to fall back behind their ping? (nanos)
22
    // Default: 120 milliseconds
23
    protected long clockDrift;
24
25
    protected boolean hasGottenMovementAfterTransaction = false;
26
27
    // Proof for this timer check
28
    // https://i.imgur.com/Hk2Wb6c.png
29
    //
30
    // The largest gap will always be the transaction ping (server -> client -> server)
31
    // Proof lies that client -> server ping will always be lower
32
    //
33
    // The largest gap is the floor for movements
34
    // If the smaller gap surpasses the larger gap, the player is cheating
35
    //
36
    // This usually flags 1.01 on low ping extremely quickly
37
    // Higher ping/low fps scales proportionately, and will flag less quickly but will still always flag 1.01
38
    // Players standing still will reset this amount of time
39
    //
40
    // This is better than traditional timer checks because ping fluctuations will never affect this check
41
    // As we are tying this check to the player's ping, rather than real time.
42
    //
43
    // Tested 10/20/30 fps and f3 + t spamming for lag spikes at 0 ping localhost/200 ping clumsy, no falses
44
    // Also didn't false when going from 0 -> 2000 ms ping, and 2000 ms -> 0 ms ping
45
    // it's a very nice check, in my opinion.  I guess I will find out if netty lag can false it
46
47
    // You might notice that we deviate a bit from this to handle lag
48
    // We take the FIRST transaction after each movement, to avoid issues with this packet order at low FPS:
49
    // TRANSACTION TRANSACTION TRANSACTION MOVEMENT MOVEMENT MOVEMENT
50
    // TRANSACTION TRANSACTION TRANSACTION MOVEMENT MOVEMENT MOVEMENT
51
    //
52
    // We then take the last transaction before this to increase stability with these lag spikes and
53
    // to guarantee that we are at least 50 ms back before adding the time
54
    public Timer(GrimPlayer player) {
55
        super(player);
56
    }
57
58
    @Override
59
    public void onPrePredictionPacketReceive(final PacketReceiveEvent event) {
60
        if (hasGottenMovementAfterTransaction && checkForTransaction(event.getPacketType())) {
61
            knownPlayerClockTime = lastMovementPlayerClock;
62
            lastMovementPlayerClock = player.getPlayerClockAtLeast();
63
            hasGottenMovementAfterTransaction = false;
64
        }
65
66
        if (!shouldCountPacketForTimer(event.getPacketType())) return;
67
68
        hasGottenMovementAfterTransaction = true;
69
        timerBalanceRealTime += 50e6;
70
71
        doCheck(event);
72
    }
73
74
    public void doCheck(final PacketReceiveEvent event) {
75
        if (timerBalanceRealTime > System.nanoTime()) {
76
            if (flag()) {
77
                // Cancel the packet
78
                if (shouldModifyPackets()) {
79
                    event.setCancelled(true);
80
                    player.onPacketCancel();
81
                }
82
83
                if (shouldSetback()) {
84
                    player.getSetbackTeleportUtil().executeNonSimulatingSetback();
85
                }
86
            }
87
88
            // Reset the violation by 1 movement
89
            timerBalanceRealTime -= 50e6;
90
        }
91
92
        limitFallBehind();
93
    }
94
95
    protected void limitFallBehind() {
96
        timerBalanceRealTime = Math.max(timerBalanceRealTime, lastMovementPlayerClock - clockDrift);
97
    }
98
99
    public boolean checkForTransaction(PacketTypeCommon packetType) {
100
        return packetType == PacketType.Play.Client.PONG ||
101
                packetType == PacketType.Play.Client.WINDOW_CONFIRMATION;
102
    }
103
104
    public boolean shouldCountPacketForTimer(PacketTypeCommon packetType) {
105
        // If not flying, or this was a teleport, or this was a duplicate 1.17 mojang stupidity packet
106
        return isTickPacket(packetType);
107
    }
108
109
    @Override
110
    public void onReload(@NotNull ConfigManager config) {
111
        clockDrift = (long) (config.getDoubleElse(getConfigName() + ".drift", 120.0) * 1e6);
112
    }
113
}

How it counteracts this module

Grim's Timer check builds a per-player clock from the packets themselves. Every counted tick packet (all flying packets) adds 50 milliseconds of balance to timerBalanceRealTime, and the check flags whenever that balance outruns System.nanoTime, which on a legitimate client can never happen because one tick packet arrives per 50ms of real time. The clock is anchored to the player's ping through transactions (C0F window confirmations) and PONG packets: the largest gap is always the transaction round-trip, so the smaller movement gap must never exceed it, and a 1.01 multiplier is flagged almost immediately on low ping. On flag the packet is cancelled and a non-simulating setback executes.\n\nThe 41-packet burst adds 41 * 50ms = 2050ms of balance in a single real tick, so the balance jumps roughly two seconds ahead of the clock on the first tick and the check flags, cancels and setbacks on the spot. The Ghostly branch's 20 flag-only C03s add a full second per tick, the same outcome. The content-blind accounting means the flood cannot hide by re-asserting stable positions or claiming ground; the only safe stream is the vanilla one-packet-per-tick cadence the module exists to break.

← Back to Analysis Hub