Nekoware v1 private Timer module 2 files, 127 lines

Nekoware v1 private Timer: Full Source Analysis

Nekoware v1's Timer is a line-for-line port of the Memeware module: the same constructor shape, the same Timer double setting from 0.1 to 10, and the same LWJEB handler consumer that writes the value…

me/nekoWare/client/module/misc/Timer.java · GitHub source ↗

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

Analysis

Overview

Nekoware v1's Timer is a line-for-line port of the Memeware module: the same constructor shape, the same Timer double setting from 0.1 to 10, and the same LWJEB handler consumer that writes the value into mc.timer.timerSpeed on every UpdateEvent. Only the package root differs (me.nekoWare instead of me.memewaredevs). The mechanics, the wire fingerprint and the countering checks are identical to the Memeware build, so the interesting content of this analysis is the port identity and the consequences of shipping a byte-identical scaler.

Port identity

The two files differ only in package and class references. Both register the setting as addDouble("Timer", 1, 0.1, 10), both use the identical handler field pattern (a public Consumer field bound through the LWJEB bus), and both restore 1F in onDisable. The Nekoware build's util tree also ships a byte-identical copy of the vanilla net.minecraft.util.Timer clock class, so the same updateTimer() accumulation applies. There is no Nekoware-specific adjustment to the tick math.

Wire fingerprint

Every tick the pre UpdateEvent fires from EntityPlayerSP.func_175161_p and one C03 variant goes out with the player's position or look deltas. Because timerSpeed multiplies the tick advance, a speed of 2 doubles the movement packet rate to roughly 40 per second, and the player entity advances twice per server tick. The keepalive and transaction streams stay tied to the server's own cadence, so the C03 rate is the observable fingerprint of the speed-up.

Detection surface

The same C00 and C0F corpus checks that counter the Memeware build apply unchanged: NCP MorePackets caps the movement rate, NCP KeepAliveFrequency runs the keepalive ledger, Frequency TimerA measures inter-movement delay against the 50ms tick expectation gated on an accepted keepalive, and Grim Timer compares a per-movement balance against a C0F-transaction-anchored clock. None of the checks inspect the client build, so the port gains nothing against them.

source Timer.java

Timer.java25 lines · JavaOriginal ↗
1
package me.nekoWare.client.module.misc;
2
3
import me.hippo.api.lwjeb.annotation.Handler;
4
import me.nekoWare.client.event.events.UpdateEvent;
5
import me.nekoWare.client.module.Module;
6
7
import java.util.function.Consumer;
8
9
public class Timer extends Module {
10
11
    public Timer() {
12
        super("Timer", 0, Category.MISC);
13
        this.addDouble("Timer", 1, 0.1, 10);
14
    }
15
16
    @Handler
17
    public Consumer<UpdateEvent> eventConsumer0 = (event) -> {
18
        mc.timer.timerSpeed = this.getDouble("Timer");
19
    };
20
21
    @Override
22
    public void onDisable() {
23
        mc.timer.timerSpeed = 1F;
24
    }
25
}

What this file does

The module is the file: a setting registration, one handler consumer, and the disable reset. The handler re-asserts mc.timer.timerSpeed from the setting on every UpdateEvent, so the value is reapplied each tick and survives any external reset of the field. The 0.1 to 10 range spans slow-motion to full speed-up, and the default 1 keeps the module inert until the user moves the slider.

Because the port kept the Memeware constructor and handler shape exactly, the same interaction rules hold: values above 1 raise the movement packet rate linearly, values below 1 stretch the tick clock, and onDisable restores the vanilla 1F so the scale does not persist after a toggle.

source Timer.java (vanilla tick clock)

Timer.java102 lines · JavaOriginal ↗
1
package net.minecraft.util;
2
3
import net.minecraft.client.Minecraft;
4
5
public class Timer {
6
    /**
7
     * The number of timer ticks per second of real time
8
     */
9
    float ticksPerSecond;
10
11
    /**
12
     * The time reported by the high-resolution clock at the last call of updateTimer(), in seconds
13
     */
14
    private double lastHRTime;
15
16
    /**
17
     * How many full ticks have turned over since the last call to updateTimer(), capped at 10.
18
     */
19
    public int elapsedTicks;
20
21
    /**
22
     * How much time has elapsed since the last tick, in ticks, for use by display rendering routines (range: 0.0 -
23
     * 1.0).  This field is frozen if the display is paused to eliminate jitter.
24
     */
25
    public float renderPartialTicks;
26
27
    /**
28
     * A multiplier to make the timer (and therefore the game) go faster or slower.  0.5 makes the game run at half-
29
     * speed.
30
     */
31
    public double timerSpeed = 1.0F;
32
33
    /**
34
     * How much time has elapsed since the last tick, in ticks (range: 0.0 - 1.0).
35
     */
36
    public float elapsedPartialTicks;
37
38
    /**
39
     * The time reported by the system clock at the last sync, in milliseconds
40
     */
41
    private long lastSyncSysClock;
42
43
    /**
44
     * The time reported by the high-resolution clock at the last sync, in milliseconds
45
     */
46
    private long lastSyncHRClock;
47
    private long field_74285_i;
48
49
    /**
50
     * A ratio used to sync the high-resolution clock to the system clock, updated once per second
51
     */
52
    private double timeSyncAdjustment = 1.0D;
53
    private static final String __OBFID = "CL_00000658";
54
55
    public Timer(float p_i1018_1_) {
56
        this.ticksPerSecond = p_i1018_1_;
57
        this.lastSyncSysClock = Minecraft.getSystemTime();
58
        this.lastSyncHRClock = System.nanoTime() / 1000000L;
59
    }
60
61
    /**
62
     * Updates all fields of the Timer using the current time
63
     */
64
    public void updateTimer() {
65
        long var1 = Minecraft.getSystemTime();
66
        long var3 = var1 - this.lastSyncSysClock;
67
        long var5 = System.nanoTime() / 1000000L;
68
        double var7 = (double) var5 / 1000.0D;
69
70
        if (var3 <= 1000L && var3 >= 0L) {
71
            this.field_74285_i += var3;
72
73
            if (this.field_74285_i > 1000L) {
74
                long var9 = var5 - this.lastSyncHRClock;
75
                double var11 = (double) this.field_74285_i / (double) var9;
76
                this.timeSyncAdjustment += (var11 - this.timeSyncAdjustment) * 0.20000000298023224D;
77
                this.lastSyncHRClock = var5;
78
                this.field_74285_i = 0L;
79
            }
80
81
            if (this.field_74285_i < 0L) {
82
                this.lastSyncHRClock = var5;
83
            }
84
        } else {
85
            this.lastHRTime = var7;
86
        }
87
88
        this.lastSyncSysClock = var1;
89
        double var13 = (var7 - this.lastHRTime) * this.timeSyncAdjustment;
90
        this.lastHRTime = var7;
91
        var13 = MathHelper.clamp_double(var13, 0.0D, 1.0D);
92
        this.elapsedPartialTicks = (float) ((double) this.elapsedPartialTicks + var13 * (double) this.timerSpeed * (double) this.ticksPerSecond);
93
        this.elapsedTicks = (int) this.elapsedPartialTicks;
94
        this.elapsedPartialTicks -= (float) this.elapsedTicks;
95
96
        if (this.elapsedTicks > 10) {
97
            this.elapsedTicks = 10;
98
        }
99
100
        this.renderPartialTicks = this.elapsedPartialTicks;
101
    }
102
}

What this file does

The Nekoware tree carries the same vanilla Timer clock as the Memeware build (byte-identical file). updateTimer() accumulates elapsedPartialTicks from the clamped frame delta times timerSpeed times the 20 ticksPerSecond, and the integer part becomes elapsedTicks for the game loop. The module's write to timerSpeed is the only mutation, so the whole tick rate scales with the setting.

Embedding this file makes the multiplier explicit: the module does not send packets or touch the network stack; it only changes how many game ticks the client executes per real second, and every per-tick packet emission scales from there.

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

MorePackets scores every serverbound movement packet into an ActionFrequency with 500ms buckets (MovingData line 321) against a 22 per second ceiling with 20 ideal (DefaultConfig lines 458-459), plus a half-second burst path with defaults 15 packets, 10 direct-burst events, 95 per minute (DefaultConfig lines 460-462). The set-back location comes from SurvivalFly when one exists.

The port's 2x setting produces about 40 C03 packets per second, which runs the window accumulator at nearly double the ceiling, so the default cancel actions fire at vl > 2. Speeds near 1.1 sit inside the tolerance because empty buckets burn the excess, so the effective detection floor is sustained use above roughly 1.1, not a hard edge at 1.0.

anticheat KeepAliveFrequency (keepalive echo ledger)

KeepAliveFrequency.java101 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.net;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.checks.Check;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.players.IPlayerData;
22
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
23
24
public class KeepAliveFrequency extends Check {
25
26
    public KeepAliveFrequency() {
27
        super(CheckType.NET_KEEPALIVEFREQUENCY);
28
    }
29
    
30
    /**
31
     * Checks hasBypass on violation only.
32
     * @param player
33
     * @param time
34
     * @param data
35
     * @param cc
36
     * @return If to cancel.
37
     */
38
    public boolean check(final Player player, final long time, final NetData data, final NetConfig cc, final IPlayerData pData) {
39
        final long now = System.currentTimeMillis();
40
        final long joinTime = pData.getLastJoinTime();
41
        if (joinTime > 0L && now < joinTime + cc.keepAliveFrequencyStartupDelay) {
42
            return false;
43
        }
44
        if (data.keepAliveExpectedResponse && !data.keepAliveDuplicateId) {
45
            return false;
46
        }
47
        data.keepAliveFreq.add(time, 1f);
48
        final float first = data.keepAliveFreq.bucketScore(0);
49
        
50
        if (first > 1f) {
51
            // Trigger a violation.
52
            final float fullScore = data.keepAliveFreq.score(1f);
53
            if (isModeledBoundaryBurst(data, fullScore, first)) {
54
                return false;
55
            }
56
            final double vl = Math.max(first - getFirstBucketViolationLimit(data), fullScore - data.keepAliveFreq.numberOfBuckets());
57
            final boolean cancel = executeActions(player, vl, 1.0, cc.keepAliveFrequencyActions).willCancel();
58
            return cancel;
59
        }
60
        return false;
61
    }
62
63
    private boolean isModeledBoundaryBurst(final NetData data, final float fullScore, final float first) {
64
        // KeepAlive model: if outgoing tracking is unavailable, only treat small monotonic id bursts as timing leftovers.
65
        if (data.keepAliveDuplicateId || fullScore > data.keepAliveFreq.numberOfBuckets() + 2f) {
66
            return false;
67
        }
68
        // Folia/netty can timestamp two adjacent valid replies in the same millisecond; do not cancel a single pair.
69
        return first <= 2f || isUntrackedMonotonicBurst(data, fullScore, first);
70
    }
71
72
    private boolean isUntrackedMonotonicBurst(final NetData data, final float fullScore, final float first) {
73
        if (data.keepAliveOutgoingSeen || fullScore > data.keepAliveFreq.numberOfBuckets()) {
74
            return false;
75
        }
76
        if (!data.keepAlivePacketIdAvailable || !data.keepAlivePreviousPacketIdAvailable) {
77
            return false;
78
        }
79
        if (data.keepAlivePacketId <= data.keepAlivePreviousPacketId) {
80
            return false;
81
        }
82
        return first <= getFallbackFirstBucketLimit(data);
83
    }
84
85
    private float getFirstBucketViolationLimit(final NetData data) {
86
        if (data.keepAliveDuplicateId) {
87
            return 1f;
88
        }
89
        if (!data.keepAliveOutgoingSeen
90
                && data.keepAlivePacketIdAvailable
91
                && data.keepAlivePreviousPacketIdAvailable
92
                && data.keepAlivePacketId > data.keepAlivePreviousPacketId) {
93
            return getFallbackFirstBucketLimit(data);
94
        }
95
        return 2f;
96
    }
97
98
    private float getFallbackFirstBucketLimit(final NetData data) {
99
        return Math.max(3f, Math.min(6f, data.keepAliveFreq.numberOfBuckets() / 4f));
100
    }
101
}

How it counteracts this module

KeepAliveFrequency timestamps every incoming C00 echo into an ActionFrequency with 20 one-second buckets, bails while an expected reply is pending unless the id is a duplicate (lines 44-46), and flags when the newest bucket scores above 1 (lines 48-58), with modeled-boundary-burst forgiveness for small monotonic bursts (lines 63-83).

For the ported timer the ledger is mostly a gate: the accelerated loop does not raise the echo rate because the server issues S00 at its own cadence, and the check fires mainly when the fast loop drains a batched keepalive delivery into one bucket or when duplicate or aged-out replies arrive. Its structural role is that Frequency TimerA refuses to run without a recently accepted keepalive, so a flooded or starved echo stream disables the transaction-clock checks.

anticheat TimerA (movement delay deviation)

TimerA.java84 lines · Java
1
package xyz.elevated.frequency.check.impl.timer;
2
3
import xyz.elevated.frequency.Frequency;
4
import xyz.elevated.frequency.check.CheckData;
5
import xyz.elevated.frequency.check.type.PacketCheck;
6
import xyz.elevated.frequency.data.PlayerData;
7
import xyz.elevated.frequency.exempt.type.ExemptType;
8
import xyz.elevated.frequency.util.MovingStats;
9
import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
10
11
@CheckData(name = "Timer (A)")
12
public final class TimerA extends PacketCheck {
13
    private final MovingStats movingStats = new MovingStats(20);
14
15
    private long lastFlying = 0L;
16
    private long allowance = 0;
17
18
    public TimerA(final PlayerData playerData) {
19
        super(playerData);
20
    }
21
22
    @Override
23
    public void process(final Object object) {
24
        final boolean flying = object instanceof WrappedPlayInFlying;
25
26
        if (flying) {
27
            // Get the server ticks and the current time for the check processing
28
            final int serverTicks = Frequency.INSTANCE.getTickManager().getTicks();
29
            final long now = System.currentTimeMillis();
30
31
            /*
32
            * We want to make sure the player is not exempt from any of the actions below.
33
            * Additionally, we want to ensure that the player is not lagged out and accepted a keepalive.
34
            * Thankfully, we shouldn't have any bypasses because of this because of PingSpoof.
35
             */
36
            final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORTING, ExemptType.LAGGING);
37
            final boolean accepted = playerData.getConnectionManager().getKeepAliveTime(serverTicks).isPresent();
38
39
            /*
40
            * Basic theory is that the player is going to deviate through 50ms without many changes to that
41
            * basic range of [48, 50]. So we're running a deviation check to check how much the player has deviated
42
            * from the basic limit of 50ms (square-root of 50 is 7.07). We're also making sure the player is actually
43
            * increasing speed through an allowance that accounts for the tick expected versus the tick received.
44
             */
45
            handle: {
46
                if (exempt || !accepted) break handle;
47
48
                // Get the delay from the current and the last flying packet
49
                final long delay = now - lastFlying;
50
51
                // Add the delay to the MovingStats to analyze our input
52
                movingStats.add(delay);
53
54
                /*
55
                * As mentioned above, the basic threshold of the player is the square-root of 50. Because
56
                * the expected tick should always be 50ms. To check how much the player has deviated from that
57
                * single point, we're using it as a threshold value in the deviation check below.
58
                 */
59
                final double threshold = 7.07;
60
                final double deviation = movingStats.getStdDev(threshold);
61
62
                // We're making sure the deviation check processed and the deviation is smaller than the threshold.
63
                if (deviation < threshold && !Double.isNaN(deviation)) {
64
                    /*
65
                    * I am sure many of you have seen this before, and it's essentially the most basic version of
66
                    * a balance / allowance check. We're increasing the allowance with the expected amount of 50,
67
                    * and we're subtracting from it the actual delay received. This will act as our "buffer" system.
68
                     */
69
                    allowance += 50;
70
                    allowance -= delay;
71
72
                    // Our previous threshold can act as one here too.
73
                    if (allowance > Math.floor(threshold)) fail();
74
                }
75
76
                else {
77
                    allowance = 0;
78
                }
79
            }
80
81
            this.lastFlying = now;
82
        }
83
    }
84
}

How it counteracts this module

Frequency TimerA feeds the inter-C03 delay into a MovingStats(20) window, runs only when a keepalive was accepted for the current server tick (lines 36-37), and requires the delay standard deviation to stay under 7.07 before an allowance of 50ms per packet minus the measured delay can accumulate; a fail fires when the allowance crosses the threshold (lines 59-74).

The port at 2x sends movements 25ms apart, so each packet adds 25ms to the allowance and the fail fires within two packets. At 1.1x the 45ms delays still add the residual 5ms per packet. The sub-1x range stretches delays past 50ms and drains the allowance, so slow-motion passes, and the keepalive gate makes the check dormant when the echo stream is broken.

anticheat Timer (transaction-anchored 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 Timer adds 50ms of balance per movement packet and flags once the balance passes real time (lines 74-90), canceling the packet and executing a setback. The baseline is the player's transaction-anchored clock, refreshed only after a movement followed by a C0F-style transaction (lines 60-64, 99-102), with a 120ms default drift allowance (line 111).

At 2x the balance gains 50ms per packet while 25ms of real time passes, which crosses the drift allowance within a few packets and flags immediately. The one-directional design means the port's sub-1x range is invisible (the balance falls behind and the drift clamp absorbs it), and idle periods before the speed-up do not accumulate because the movement stream is what accrues.

← Back to Analysis Hub