LiquidSense Dev Timer module 2 files, 254 lines

LiquidSense Dev Timer: Full Source Analysis

Timer is a four-line world-category scaler that writes its Speed value (0.1 to 10, default 2) into mc.timer.timerSpeed on every UpdateEvent.

net/ccbluex/liquidbounce/features/module/modules/world/Timer.kt · GitHub source ↗

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

Analysis

Overview

Timer is a four-line world-category scaler that writes its Speed value (0.1 to 10, default 2) into mc.timer.timerSpeed on every UpdateEvent. The vanilla Timer accumulator consumes wall-clock milliseconds scaled by the speed value, so the effective game-tick rate scales linearly with the setting: the default 2 runs the client at roughly 40 ticks per second, doubling the emission rate of every serverbound stream the tick drives. onDisable restores the field to 1F, and a WorldEvent handler turns the module off whenever the client leaves a world, so the scalar cannot survive a respawn or a server transfer. The module constructs no packets; its fingerprint is entirely the accelerated ledger traffic, which is why the countering set lives in the C00 and C0F corpora.

The scalar write

The module is three handlers: onUpdate writes mc.timer.timerSpeed = speedValue.get() on every fired UpdateEvent, onDisable restores 1F when the player exists, and onWorld sets state = false when the incoming WorldEvent carries a null worldClient. UpdateEvent (Events.kt line 204) fires once per game tick, so the write is continuous, not a one-shot latch: the field is re-asserted every tick the module stays on. The Speed setting spans 0.1 to 10 with a default of 2, so the out-of-box behavior is a doubled client.

Wire reach

No packet object is constructed anywhere in the file; the scalar acts on the tick clock that drives the whole client. The vanilla Timer contract, described from stock 1.8 because the snapshot ships no net/minecraft tree, is a partial-tick accumulator scaled by timerSpeed, so the effective tick rate equals 20 times the setting: the default 2 produces about 40 C03 movement packets per second plus the accelerated C00 keepalive echoes and C0F transaction confirmations. MixinMinecraft in this client shadows fields such as rightClickDelayTimer but adds no timerSpeed hook, so the module's write reaches the vanilla field directly.

Detection profile

Windowed rate checks tolerate the transient spikes of a pulse timer but the sustained scalar is a steady doubling, which pushes the movement rate window permanently positive. Inter-delay checks measure the spacing between consecutive packets against the 50ms tick expectation and fail within a few packets of the speed-up. The module is symmetric while the checks are not: sub-1 settings (0.1 to 0.9) slow the client and pass the one-directional clock checks by design, and the onDisable restore is the only guard against a stuck field on toggle-off.

source Timer.kt

Timer.kt40 lines · JavaOriginal ↗
1
/*
2
 * LiquidBounce Hacked Client
3
 * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4
 * https://github.com/CCBlueX/LiquidBounce/
5
 */
6
package net.ccbluex.liquidbounce.features.module.modules.world
7
8
import net.ccbluex.liquidbounce.event.EventTarget
9
import net.ccbluex.liquidbounce.event.UpdateEvent
10
import net.ccbluex.liquidbounce.event.WorldEvent
11
import net.ccbluex.liquidbounce.features.module.Module
12
import net.ccbluex.liquidbounce.features.module.ModuleCategory
13
import net.ccbluex.liquidbounce.features.module.ModuleInfo
14
import net.ccbluex.liquidbounce.value.FloatValue
15
16
@ModuleInfo(name = "Timer", description = "Changes the speed of the entire game.", category = ModuleCategory.WORLD)
17
class Timer : Module() {
18
19
    private val speedValue = FloatValue("Speed", 2F, 0.1F, 10F)
20
21
    override fun onDisable() {
22
        if (mc.thePlayer == null)
23
            return
24
25
        mc.timer.timerSpeed = 1F
26
    }
27
28
    @EventTarget
29
    fun onUpdate(event: UpdateEvent) {
30
        mc.timer.timerSpeed = speedValue.get()
31
    }
32
33
    @EventTarget
34
    fun onWorld(event: WorldEvent) {
35
        if (event.worldClient != null)
36
            return
37
38
        state = false
39
    }
40
}

What this file does

The entire module: the timerSpeed write in onUpdate, the onDisable restore, and the world-unload disable. The brief pins C00 and C0F, which the module never constructs: those streams are the keepalive echoes and transaction confirmations that the accelerated tick clock emits at double rate, and the countering checks measure them.

source Events.kt (UpdateEvent tick hook)

Events.kt214 lines · JavaOriginal ↗
1
/*
2
 * LiquidBounce Hacked Client
3
 * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4
 * https://github.com/CCBlueX/LiquidBounce/
5
 */
6
package net.ccbluex.liquidbounce.event
7
8
import net.minecraft.block.Block
9
import net.minecraft.block.state.IBlockState
10
import net.minecraft.client.Minecraft
11
import net.minecraft.client.gui.GuiScreen
12
import net.minecraft.client.model.ModelPlayer
13
import net.minecraft.client.multiplayer.WorldClient
14
import net.minecraft.entity.Entity
15
import net.minecraft.entity.player.EntityPlayer
16
import net.minecraft.network.Packet
17
import net.minecraft.util.AxisAlignedBB
18
import net.minecraft.util.BlockPos
19
import net.minecraft.util.EnumFacing
20
import net.minecraft.world.IBlockAccess
21
22
/**
23
 * Called when player attacks other entity
24
 *
25
 * @param targetEntity Attacked entity
26
 */
27
28
29
class EventLivingUpdate(val entity: Entity) : CancellableEvent()
30
31
class AttackEvent(val targetEntity: Entity?) : Event()
32
33
/**
34
 * Called when minecraft get bounding box of block
35
 *
36
 * @param blockPos block position of block
37
 * @param block block itself
38
 * @param boundingBox vanilla bounding box
39
 */
40
class BlockBBEvent(blockPos: BlockPos, val block: Block, var boundingBox: AxisAlignedBB?) : Event() {
41
    val x = blockPos.x
42
    val y = blockPos.y
43
    val z = blockPos.z
44
}
45
class RenderHitting(var f : Float , var f1 : Float ) : Event()
46
/**
47
 * Called when player clicks a block
48
 */
49
class ClickBlockEvent(val clickedBlock: BlockPos?, val enumFacing: EnumFacing?) : Event()
50
51
/**
52
 * Called when client is shutting down
53
 */
54
class ClientShutdownEvent : Event()
55
56
/**
57
 * Called when an other entity moves
58
 */
59
data class EntityMovementEvent(val movedEntity: Entity) : Event()
60
61
/**
62
 * Called when player jumps
63
 *
64
 * @param motion jump motion (y motion)
65
 */
66
class JumpEvent(var motion: Float) : CancellableEvent()
67
68
/**
69
 * Called when user press a key once
70
 *
71
 * @param key Pressed key
72
 */
73
class KeyEvent(val key: Int) : Event()
74
75
/**
76
 * Called in "onUpdateWalkingPlayer"
77
 *
78
 * @param eventState PRE or POST
79
 */
80
class MotionEvent(val eventState: EventState) : Event()
81
82
/**
83
 * Called in "onLivingUpdate" when the player is using a use item.
84
 *
85
 * @param strafe the applied strafe slow down
86
 * @param forward the applied forward slow down
87
 */
88
class SlowDownEvent(var strafe: Float, var forward: Float) : Event()
89
90
/**
91
 * Called in "moveFlying"
92
 */
93
class StrafeEvent(val strafe: Float, val forward: Float, val friction: Float) : CancellableEvent()
94
95
/**
96
 * Called when player moves
97
 *
98
 * @param x motion
99
 * @param y motion
100
 * @param z motion
101
 */
102
class MoveEvent(var x: Double, var y: Double, var z: Double) : CancellableEvent() {
103
    var isSafeWalk = false
104
105
    fun zero() {
106
        x = 0.0
107
        y = 0.0
108
        z = 0.0
109
    }
110
111
    fun zeroXZ() {
112
        x = 0.0
113
        z = 0.0
114
    }
115
}
116
117
/**
118
 * ShaBi
119
 */
120
class SlientStealerEvent() : CancellableEvent()
121
122
/**
123
 * Called when receive or send a packet
124
 */
125
class PacketEvent(val packet: Packet<*>) : CancellableEvent()
126
127
class EventPacketReceive(val packet: Packet<*>) : CancellableEvent()
128
129
/**
130
 * Called when a block tries to push you
131
 */
132
class PushOutEvent : CancellableEvent()
133
134
/**
135
 * Called when screen is going to be rendered
136
 */
137
class Render2DEvent(val partialTicks: Float) : Event()
138
139
class RenderHUDEvent(val partialTicks: Float) : Event()
140
141
class EventRespawn(): CancellableEvent()
142
/**
143
 * shabi
144
 */
145
class BlockRenderSideEvent(val world: IBlockAccess, val pos: BlockPos, val side: EnumFacing, val maxX: Double, val minX: Double, val maxY: Double, val minY: Double, val maxZ: Double, val minZ: Double) : Event()
146
147
/**
148
 * Called when world is going to be rendered
149
 */
150
class Render3DEvent(val partialTicks: Float) : Event()
151
152
/**
153
 * shabi
154
 */
155
156
class UpdateModelEvent(val player: EntityPlayer, val model: ModelPlayer) : Event()
157
158
159
/**
160
 * Called when entity is going to be rendered
161
 */
162
class RenderEntityEvent(val entity: Entity, val x: Double, val y: Double, val z: Double, val entityYaw: Float,
163
                        val partialTicks: Float) : Event()
164
165
/**
166
 * Called when the screen changes
167
 */
168
class ScreenEvent(val guiScreen: GuiScreen?) : Event()
169
170
/**
171
 * Called when the session changes
172
 */
173
class SessionEvent : Event()
174
175
class PacketSenEvent(val packet: Packet<*>) : CancellableEvent()
176
177
/**
178
 * Ni kan ni ma ne?
179
 */
180
181
/**
182
 * Called when player is going to step
183
 */
184
class StepEvent(var stepHeight: Float) : Event()
185
186
/**
187
 * Called when player step is confirmed
188
 */
189
class StepConfirmEvent(var stepHeight: Float) : Event()
190
191
/**
192
 * Called when a text is going to be rendered
193
 */
194
class TextEvent(var text: String?) : Event()
195
196
/**
197
 * tick... tack... tick... tack
198
 */
199
class TickEvent : Event()
200
201
/**
202
 * Called when minecraft player will be updated
203
 */
204
class UpdateEvent : Event()
205
206
/**
207
 * Called when the world changes
208
 */
209
class WorldEvent(val worldClient: WorldClient?) : Event()
210
211
/**
212
 * Called when window clicked
213
 */
214
class ClickWindowEvent(val windowId: Int, val slotId: Int, val mouseButtonClicked: Int, val mode: Int) : CancellableEvent()

What this file does

UpdateEvent (line 204) is the per-tick carrier the module hooks to re-assert timerSpeed; it is the only verifiable wiring between the module and the tick clock because the snapshot ships no net/minecraft tree, so the vanilla Timer accumulator that consumes the value has to be described from the stock contract.

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 rate window)

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 processed move into an ActionFrequency with 500ms buckets against a 22 packet/s ceiling with 20 ideal, plus a half-second burst path (15 direct, 10 direct-violation). The default 2x setting sustains about 40 C03/s, so the window accumulator runs permanently positive and cancels at vl > 2 with a set-back seeded from SurvivalFly; settings below about 1.1 stay under the effective floor because idle windows burn the excess.

anticheat KeepAliveFrequency (keepalive 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

The ledger tracks S00 ids against C00 echoes and counts replies that arrive late, duplicated or with no pending request. The accelerated loop can drain a batched keepalive delivery into a single second-bucket, which is the one case that trips it; a steady 2x passes the ledger because the echo cadence stays tied to the server's S00 rate. Its structural role here is the gate: Frequency TimerA refuses to run without a recently accepted keepalive, so this check arms the timer layer.

anticheat TimerA (inter-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

TimerA measures the delay between consecutive C03s against the 50ms tick expectation through MovingStats(20) with a stddev gate of 7.07, accumulating allowance += 50 - delay and failing when the balance passes the floor. At 2x the delays collapse to about 25ms, so the check fails within two packets of the speed-up; sub-1 settings drain the allowance and pass by design, and the check is gated on a recently accepted keepalive and exempt ticks.

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 runs a 50ms balance per movement packet against a real-time clock whose baseline is anchored to the C0F stream: knownPlayerClockTime is refreshed only after a movement followed by a PONG or WINDOW_CONFIRMATION. The default clockDrift of 120ms is consumed within a few ticks at 2x, so the doubled C03 rate flags promptly; the check is one-directional, so sub-1 settings pass because limitFallBehind absorbs the slow phase, which matches the module's symmetric scalar against asymmetric checks.

← Back to Analysis Hub