timer module

timer: Minecraft 26.3 cheat module, full source for every implementation (5 clients: Meteor Client, MelaHack (ThunderHack fork), OfflineClient, …).

5 implementationsWorldMOVEMENTMISCWORLD

Full module source: 5 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/Timer.javaJava · 41 lines · 1.3 KB

Changes the speed of everything in your game.

Settingsmultiplier
Timer.javaJava · Minecraft 26.2 · 41 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.world;
7
8
import meteordevelopment.meteorclient.settings.DoubleSetting;
9
import meteordevelopment.meteorclient.settings.Setting;
10
import meteordevelopment.meteorclient.settings.SettingGroup;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
14
public class Timer extends Module {
15
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
16
17
    private final Setting<Double> multiplier = sgGeneral.add(new DoubleSetting.Builder()
18
        .name("multiplier")
19
        .description("The timer multiplier amount.")
20
        .defaultValue(1)
21
        .min(0.1)
22
        .sliderMin(0.1)
23
        .build()
24
    );
25
26
    public static final double OFF = 1;
27
    private double override = 1;
28
29
    public Timer() {
30
        super(Categories.World, "timer", "Changes the speed of everything in your game.");
31
    }
32
33
    public double getMultiplier() {
34
        return override != OFF ? override : (isActive() ? multiplier.get() : OFF);
35
    }
36
37
    public void setOverride(double override) {
38
        this.override = override;
39
    }
40
}
41
MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/Timer.javaJava · 158 lines · 5.6 KB

Allows you to change tick rate of game.

SettingsModeOldSpeedShiftTicksBoostKeyOnFlag
Timer.javaJava · Minecraft 26.2 · 158 lines · 5.6 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.network.protocol.common.ClientboundPingPacket;
5
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
6
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
7
import net.minecraft.util.Mth;
8
import thunder.hack.ThunderHack;
9
import thunder.hack.events.impl.PacketEvent;
10
import thunder.hack.events.impl.PostPlayerUpdateEvent;
11
import thunder.hack.features.modules.Module;
12
import thunder.hack.setting.Setting;
13
import thunder.hack.setting.impl.Bind;
14
import thunder.hack.utility.player.MovementUtility;
15
16
import static thunder.hack.features.modules.client.ClientSettings.isRu;
17
18
public class Timer extends Module {
19
    public Timer() {
20
        super("Timer", Category.MOVEMENT);
21
    }
22
23
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Normal);
24
    private final Setting<Boolean> old = new Setting<>("Old", false, v -> mode.is(Mode.Matrix));
25
    public final Setting<Float> speed = new Setting<>("Speed", 2.0f, 0.1f, 10.0f, v -> mode.getValue() != Mode.Shift);
26
    private final Setting<Integer> shiftTicks = new Setting<>("ShiftTicks", 10, 1, 40, v -> mode.getValue() == Mode.Shift);
27
    private final Setting<Bind> boostKey = new Setting<>("BoostKey", new Bind(-1, false, false), v -> mode.getValue() == Mode.Grim);
28
    private final Setting<OnFlag> onFlag = new Setting<>("OnFlag", OnFlag.Reset);
29
30
    public static float energy, yaw, pitch;
31
    private static double prevPosX, prevPosY, prevPosZ;
32
    private long cancelTime;
33
34
    @Override
35
    public void onEnable() {
36
        ThunderHack.TICK_TIMER = 1f;
37
        if (!mode.is(Mode.Matrix))
38
            energy = 0f;
39
40
        if (mode.is(Mode.Grim))
41
            cancelTime = System.currentTimeMillis();
42
    }
43
44
    @Override
45
    public void onDisable() {
46
        ThunderHack.TICK_TIMER = 1f;
47
    }
48
49
    @Override
50
    public void onUpdate() {
51
        switch (mode.getValue()) {
52
            case Normal -> ThunderHack.TICK_TIMER = speed.getValue();
53
            case Matrix -> {
54
                if (!MovementUtility.isMoving()) {
55
                    ThunderHack.TICK_TIMER = 1f;
56
                    return;
57
                }
58
59
                ThunderHack.TICK_TIMER = Math.max(speed.getValue(), 1f);
60
61
                if (energy > 0) {
62
                    energy = Mth.clamp(energy - ((0.1f * speed.getValue()) - 0.1f), 0f, 1f);
63
                } else
64
                    disable(isRu() ? "Заряд таймера кончился! Отключаю.." : "Timer's out of charge! Disabling..");
65
            }
66
67
            case Grim -> {
68
                if (energy <= 0 || !isKeyPressed(boostKey) || ThunderHack.core.getSetBackTime() < 2000) {
69
                    ThunderHack.TICK_TIMER = 1f;
70
                    return;
71
                }
72
73
                ThunderHack.TICK_TIMER = Math.max(speed.getValue(), 1f);
74
                energy = Mth.clamp(energy - ((0.0025f * speed.getValue()) - 0.0025f), 0f, 1f);
75
            }
76
        }
77
    }
78
79
    @EventHandler
80
    public void onPacketReceive(PacketEvent.Receive e) {
81
        if (mode.is(Mode.Grim)) {
82
            if (e.getPacket() instanceof ClientboundPingPacket
83
                    && ThunderHack.core.getSetBackTime() > 2000) {
84
                if (System.currentTimeMillis() - cancelTime > 25000) {
85
                    cancelTime = System.currentTimeMillis();
86
                    energy = 0f;
87
                    return;
88
                }
89
90
                if (!MovementUtility.isMoving())
91
                    energy = Math.clamp(energy + 0.005f, 0f, 1f);
92
93
                e.cancel();
94
            }
95
        }
96
97
        if (e.getPacket() instanceof ClientboundPlayerPositionPacket) {
98
            switch (onFlag.getValue()) {
99
                case Reset -> {
100
                    ThunderHack.TICK_TIMER = 1f;
101
                    energy = 0;
102
                }
103
                case Disable -> {
104
                    energy = 0;
105
                    disable(isRu() ? "Отключён т.к. тебя флагнуло!" : "Disabled because you got flagged!");
106
                }
107
            }
108
        }
109
110
        if (e.getPacket() instanceof ClientboundSetEntityMotionPacket velo
111
                && velo.id() == mc.player.getId() && mode.is(Mode.Grim)) {
112
            ThunderHack.TICK_TIMER = 1f;
113
            energy = 0;
114
        }
115
    }
116
117
    @EventHandler
118
    public void onPostPlayerUpdate(PostPlayerUpdateEvent event) {
119
        if (mode.getValue() == Mode.Shift) {
120
            if (energy < 0.9f) {
121
                disable(isRu() ? "Перед повторным использованием необходимо постоять на месте!" : "Standing still is required before reuse!");
122
                return;
123
            }
124
            event.cancel();
125
            event.setIterations(shiftTicks.getValue());
126
            disable(isRu() ? "Тики пропущены! Отключаю.." : "Ticks shifted! Disabling..");
127
        }
128
    }
129
130
    public void onEntitySync() {
131
        if (mode.is(Mode.Matrix))
132
            energy = Math.clamp(notMoving() ? energy + 0.025f : energy - (old.getValue() ? 0.005f : 0), 0f, 1f);
133
134
        prevPosX = mc.player.getX();
135
        prevPosY = mc.player.getY();
136
        prevPosZ = mc.player.getZ();
137
        yaw = mc.player.getYRot();
138
        pitch = mc.player.getXRot();
139
    }
140
141
    private static boolean notMoving() {
142
        return prevPosX == mc.player.getX() && prevPosY == mc.player.getY() && prevPosZ == mc.player.getZ() && yaw == mc.player.getYRot() && pitch == mc.player.getXRot();
143
    }
144
145
    public enum Mode {
146
        Normal,
147
        Matrix,
148
        Shift,
149
        Grim
150
    }
151
152
    public enum OnFlag {
153
        Disable,
154
        None,
155
        Reset
156
    }
157
}
158
OfflineClientMISCsrc/main/java/com/jellypudding/offlineclient/modules/misc/Timer.javaJava · 65 lines · 2.1 KB

Speeds up or slows down the whole game client side.

SettingsSpeed
Timer.javaJava · Minecraft 26.2 · 65 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.misc;
2
3
import com.jellypudding.offlineclient.module.Category;
4
import com.jellypudding.offlineclient.module.Module;
5
import com.jellypudding.offlineclient.setting.NumberSetting;
6
import com.jellypudding.offlineclient.util.Modules;
7
8
import java.math.BigDecimal;
9
import java.util.concurrent.ConcurrentHashMap;
10
import java.util.Map;
11
12
// Behaviour lives in DeltaTrackerMixin. Other modules can push a temporary override.
13
public final class Timer extends Module {
14
15
    private final NumberSetting speed = new NumberSetting("Speed",
16
        "Game speed multiplier.", 2, 0.1, 10, 0.1, "x");
17
18
    private final Map<String, Float> overrides = new ConcurrentHashMap<>();
19
20
    public Timer() {
21
        super("Timer", "Speeds up or slows down the whole game client side.", Category.MISC);
22
        addSettings(speed);
23
    }
24
25
    @Override
26
    public String getSuffix() {
27
        float effective = getSpeed();
28
        if (effective == speed.getFloat()) {
29
            return speed.getValueString();
30
        }
31
        return new BigDecimal(Float.toString(effective)).stripTrailingZeros().toPlainString() + "x";
32
    }
33
34
    // The game speed in force right now. One when nothing is speeding it up.
35
    public static float current() {
36
        Timer timer = Modules.get(Timer.class);
37
        return timer == null ? 1f : timer.getSpeed();
38
    }
39
40
    // Pushes an override without the caller having to look the module up first.
41
    public static void override(String key, float multiplier) {
42
        Timer timer = Modules.get(Timer.class);
43
        if (timer != null) {
44
            timer.setOverride(key, multiplier);
45
        }
46
    }
47
48
    // A value of one or less clears that module's boost. The highest active source wins.
49
    private void setOverride(String key, float multiplier) {
50
        if (multiplier <= 1f) {
51
            overrides.remove(key);
52
        } else {
53
            overrides.put(key, multiplier);
54
        }
55
    }
56
57
    public float getSpeed() {
58
        float best = isEnabled() ? speed.getFloat() : 1f;
59
        for (float value : overrides.values()) {
60
            best = Math.max(best, value);
61
        }
62
        return best;
63
    }
64
}
65
CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/Timer.javaJava · 429 lines · 15.9 KB
Settingsmodeoldspeedshift_ticksboost_keygrim_fill_timegrim_consume_multon_flag
Timer.javaJava · Minecraft 26.2 · 429 lines · 15.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.features.module.modules.movement;
9
10
import combatant.client.config.values.*;
11
import combatant.client.util.time.TimerController;
12
import net.minecraft.client.Minecraft;
13
import net.minecraft.network.protocol.common.ClientboundPingPacket;
14
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
15
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
16
import net.minecraft.util.Mth;
17
import combatant.client.config.values.*;
18
import combatant.client.events.EventHandler;
19
import combatant.client.events.impl.EventSync;
20
import combatant.client.events.impl.PacketEvent;
21
import combatant.client.events.impl.PostPlayerUpdateEvent;
22
import combatant.client.features.module.Module;
23
import combatant.client.features.module.ModuleCategory;
24
import combatant.client.features.module.ModuleInfo;
25
import combatant.client.util.input.KeyManager;
26
import combatant.client.util.player.MovementUtil;
27
28
//todo Description
29
@ModuleInfo(
30
        id = "timer",
31
        displayName = "Timer",
32
        category = ModuleCategory.MOVEMENT
33
)
34
public class Timer extends Module {
35
36
    // ── Vulcan TimerA sliding-window model ───────────────────────────────────────
37
    //
38
    // TimerA uses a 50-sample sliding FIFO window (EvictingQueue).
39
    // Each add() evicts the OLDEST entry. The oldest entries are the SLOW packets
40
    // from before the boost, not the newly added fast packets:
41
    //
42
    //   After N fast packets, window = [S×(50-N), F×N]  (old slow | new fast)
43
    //   Slow send: evict the oldest slow entry, not a fast entry.
44
    //   Fast packets only leave after (50-N) slow packets flush the old slow first.
45
    //   REAL tail = 50 slow packets (not N or 14 as the broken counter model said).
46
    //
47
    // Correct approach: track the exact window state with a circular boolean buffer.
48
    //   canBoost = fastCount < kMax   where kMax = floor(2.5S / (1.05*(S-1)))
49
    //
50
    // For S=2.64: kMax=3.  With fastCount ≤ 2 (boost condition fastCount < kMax):
51
    //   avgDelay = (2×18.9 + 48×50)/50 = 48.76ms → speed = 1.025 << 1.05. SAFE.
52
    // For S=2.0:  kMax=4, fastCount ≤ 3. speed ≈ 1.031. SAFE.
53
    //
54
    // Energy bar = 1 - fastCount/kMax.  Full = all window slots slow. Empty = at kMax.
55
    private static final int VULCAN_WINDOW_SIZE = 50;
56
    private static final boolean[] vulcanWindow = new boolean[VULCAN_WINDOW_SIZE]; // true=fast
57
    @SuppressWarnings("unused")
58
    private static final float timerABuffer = 0f;
59
    @SuppressWarnings("unused")
60
    private static final float fastInWindow = 0f;
61
    @SuppressWarnings("unused")
62
    private static final boolean vulcanBoostPhase = false;
63
    public static float energy = 0f;
64
    public static float yaw;
65
    public static float pitch;
66
    private static int vulcanWindowHead = 0;   // next write position (circular)
67
    private static int vulcanWindowCount = 0;   // filled slots 0..50
68
    private static int vulcanFastCount = 0;   // # fast entries currently in window
69
    private static double prevPosX;
70
    private static double prevPosY;
71
    private static double prevPosZ;
72
    private static float tickTimer = 1f;
73
    private static float externalTickTimer = 1f;
74
    private final EnumValue<Mode> mode =
75
            enumMode("mode", Mode.NORMAL, Mode.values());
76
    private final BooleanValue old =
77
            visibleWhen(bool("old", false), () -> mode.get() == Mode.MATRIX);
78
    private final NumberValue<Double> speed =
79
            visibleWhen(num("speed", 2.0, 0.1, 10.0), () -> mode.get() != Mode.SHIFT);
80
    private final NumberValue<Integer> shiftTicks =
81
            visibleWhen(num("shift_ticks", 10, 1, 40), () -> mode.get() == Mode.SHIFT);
82
    private final KeyBindValue boostKey =
83
            visibleWhen(bind("boost_key", "NONE", BindMode.HOLD),
84
                    () -> mode.get() == Mode.GRIM || mode.get() == Mode.GRIM_CONCEPT || mode.get() == Mode.VULCAN);
85
    private final NumberValue<Double> grimFillTime =
86
            visibleWhen(num("grim_fill_time", 20.0, 1.0, 120.0), () -> mode.get() == Mode.GRIM_CONCEPT);
87
    private final NumberValue<Double> grimConsumeMult =
88
            visibleWhen(num("grim_consume_mult", 10.0, 1.0, 20.0), () -> mode.get() == Mode.GRIM_CONCEPT);
89
    private final EnumValue<OnFlag> onFlag =
90
            enumMode("on_flag", OnFlag.RESET, OnFlag.values());
91
    private long cancelTime;
92
    private long lastSetbackTime = 0L;
93
    private String lastBoostCombo = "NONE";
94
    private long lastPingTime = 0L;
95
96
    public static float getEnergy01() {
97
        return Mth.clamp(energy, 0f, 1f);
98
    }
99
100
    public static float getTickTimer() {
101
        float controllerTimer = TimerController.getTimerSpeed();
102
        if (tickTimer != 1f) return tickTimer;
103
        return externalTickTimer == 1f ? controllerTimer : externalTickTimer;
104
    }
105
106
    public static void setExternalTickTimer(float timer) {
107
        if (Float.isNaN(timer) || Float.isInfinite(timer)) {
108
            clearExternalTickTimer();
109
            return;
110
        }
111
        externalTickTimer = Mth.clamp(timer, 0.1f, 10.0f);
112
        TimerController.requestTimerSpeed(
113
                externalTickTimer,
114
                TimerController.IMPORTANT_FOR_USAGE_1,
115
                Timer.class
116
        );
117
    }
118
119
    public static void clearExternalTickTimer() {
120
        externalTickTimer = 1f;
121
        TimerController.clear(Timer.class);
122
    }
123
124
    @Override
125
    public void onEnable() {
126
        tickTimer = 1f;
127
        externalTickTimer = 1f;
128
        if (mode.get() == Mode.VULCAN) {
129
            vulcanWindowHead = 0;
130
            vulcanWindowCount = 0;
131
            vulcanFastCount = 0;
132
            java.util.Arrays.fill(vulcanWindow, false);
133
            energy = 1f;
134
        } else if (mode.get() != Mode.MATRIX) {
135
            energy = 0f;
136
        }
137
        if (mode.get() == Mode.GRIM || mode.get() == Mode.GRIM_CONCEPT) {
138
            cancelTime = System.currentTimeMillis();
139
            lastPingTime = 0L;
140
        }
141
        ensureBoostBind();
142
    }
143
144
    @Override
145
    public void onDisable() {
146
        tickTimer = 1f;
147
        externalTickTimer = 1f;
148
        vulcanWindowHead = 0;
149
        vulcanWindowCount = 0;
150
        vulcanFastCount = 0;
151
        java.util.Arrays.fill(vulcanWindow, false);
152
    }
153
154
    @Override
155
    public void onTick() {
156
        ensureBoostBind();
157
158
        switch (mode.get()) {
159
            case NORMAL -> tickTimer = speed.get().floatValue();
160
            case MATRIX -> {
161
                if (!MovementUtil.isMoving()) {
162
                    tickTimer = 1f;
163
                    return;
164
                }
165
166
                tickTimer = Math.max(speed.get().floatValue(), 1f);
167
168
                if (energy > 0f) {
169
                    float drain = (float) ((0.1f * speed.get()) - 0.1f);
170
                    energy = Mth.clamp(energy - drain, 0f, 1f);
171
                } else {
172
                    setEnabled(false);
173
                }
174
            }
175
            case GRIM -> {
176
                if (energy <= 0f || !isBoostHeld() || getSetbackAge() < 2000L) {
177
                    tickTimer = 1f;
178
                    return;
179
                }
180
181
                tickTimer = Math.max(speed.get().floatValue(), 1f);
182
                float drain = (float) ((0.0025f * speed.get()) - 0.0025f);
183
                energy = Mth.clamp(energy - drain, 0f, 1f);
184
            }
185
            case GRIM_CONCEPT -> {
186
                if (energy <= 0f || !isBoostHeld() || getSetbackAge() < 2000L) {
187
                    tickTimer = 1f;
188
                    return;
189
                }
190
191
                tickTimer = Math.max(speed.get().floatValue(), 1f);
192
                float drain = (float) ((0.0025f * speed.get()) - 0.0025f);
193
                float mult = grimConsumeMult.get().floatValue();
194
                if (mult < 0f) mult = 0f;
195
                energy = Mth.clamp(energy - drain * mult, 0f, 1f);
196
            }
197
            case SHIFT -> tickTimer = 1f;
198
            case VULCAN -> {
199
                // Correct model: circular buffer tracks exactly which of the last 50
200
                // packets were fast. Vulcan's EvictingQueue evicts the OLDEST entry —
201
                // after N fast packets the window is [S×(50-N), F×N], so slow packets
202
                // evict old SLOW first; fast packets only leave after (50-N) slow packets.
203
                //
204
                // Safe k_max = floor(2.5*S / (1.05*(S-1))):
205
                //   S=2.64 → kMax=3, avgDelay at k=2: 48.76ms, speed=1.025 < 1.05 ✓
206
                //   S=2.0  → kMax=4, avgDelay at k=3: 48.5ms,  speed=1.031 < 1.05 ✓
207
                //
208
                // Boost while fastCount < kMax. After boosting, fastCount rises
209
                // to kMax and boosting stops. Fast entries leave only after (50-kMax)
210
                // subsequent slow packets flush the initial slow buffer out.
211
212
                boolean held = isBoostHeld();
213
                boolean setbackRecent = getSetbackAge() < 500L;
214
                float s = speed.get().floatValue();
215
216
                // kMax: max fast packets allowed in 50-sample window at speed S
217
                int kMax = (s <= 1.001f) ? 0 : (int) (2.5f * s / (1.05f * (s - 1f)));
218
                if (kMax <= 0) kMax = 0;
219
220
                boolean canBoost = held && !setbackRecent && kMax > 0 && vulcanFastCount < kMax;
221
222
                if (canBoost) {
223
                    tickTimer = Math.max(s, 1f);
224
                    vulcanEvalWindow(true);
225
                } else {
226
                    tickTimer = 1f;
227
                    vulcanEvalWindow(false);
228
                }
229
230
                // Energy: 1.0 = window clean (fastCount=0), 0.0 = budget used (fastCount=kMax)
231
                energy = (kMax > 0)
232
                        ? Mth.clamp(1f - (float) vulcanFastCount / kMax, 0f, 1f)
233
                        : 0f;
234
            }
235
        }
236
    }
237
238
    @EventHandler
239
    public void onPacketReceive(PacketEvent.Receive e) {
240
        if (mode.get() == Mode.GRIM) {
241
            if (e.getPacket() instanceof ClientboundPingPacket && getSetbackAge() > 2000L) {
242
                if (System.currentTimeMillis() - cancelTime > 25000L) {
243
                    cancelTime = System.currentTimeMillis();
244
                    energy = 0f;
245
                    return;
246
                }
247
248
                if (!MovementUtil.isMoving()) {
249
                    energy = Mth.clamp(energy + 0.005f, 0f, 1f);
250
                }
251
252
                e.cancel();
253
            }
254
        }
255
        if (mode.get() == Mode.GRIM_CONCEPT) {
256
            if (e.getPacket() instanceof ClientboundPingPacket && getSetbackAge() > 2000L) {
257
                long now = System.currentTimeMillis();
258
                if (now - cancelTime > 25000L) {
259
                    cancelTime = now;
260
                    energy = 0f;
261
                    lastPingTime = now;
262
                    return;
263
                }
264
265
                if (lastPingTime <= 0L) {
266
                    lastPingTime = now;
267
                }
268
269
                if (!MovementUtil.isMoving()) {
270
                    double fillSeconds = grimFillTime.get();
271
                    if (fillSeconds < 1.0) fillSeconds = 1.0;
272
                    double delta = (now - lastPingTime) / (fillSeconds * 1000.0);
273
                    if (delta > 0.0) {
274
                        energy = Mth.clamp(energy + (float) delta, 0f, 1f);
275
                    }
276
                }
277
278
                lastPingTime = now;
279
                e.cancel();
280
            }
281
        }
282
283
        if (e.getPacket() instanceof ClientboundPlayerPositionPacket) {
284
            lastSetbackTime = System.currentTimeMillis();
285
            if (mode.get() == Mode.VULCAN) {
286
                // Server correction inserts a 150ms sample into Vulcan's window — helps.
287
                // Reset our circular buffer: assume server state is now clean.
288
                tickTimer = 1f;
289
                vulcanWindowHead = 0;
290
                vulcanWindowCount = 0;
291
                vulcanFastCount = 0;
292
                java.util.Arrays.fill(vulcanWindow, false);
293
                energy = 1f;
294
                if (onFlag.get() == OnFlag.DISABLE) {
295
                    setEnabled(false);
296
                }
297
            } else {
298
                switch (onFlag.get()) {
299
                    case RESET -> {
300
                        tickTimer = 1f;
301
                        energy = 0f;
302
                    }
303
                    case DISABLE -> {
304
                        energy = 0f;
305
                        setEnabled(false);
306
                    }
307
                    case NONE -> {
308
                    }
309
                }
310
            }
311
        }
312
313
        if (e.getPacket() instanceof ClientboundSetEntityMotionPacket velo
314
                && (mode.get() == Mode.GRIM || mode.get() == Mode.GRIM_CONCEPT)) {
315
            Minecraft mc = Minecraft.getInstance();
316
            if (mc != null && mc.player != null && velo.id() == mc.player.getId()) {
317
                tickTimer = 1f;
318
                energy = 0f;
319
                lastSetbackTime = System.currentTimeMillis();
320
            }
321
        }
322
    }
323
324
    @EventHandler
325
    public void onPostPlayerUpdate(PostPlayerUpdateEvent event) {
326
        if (mode.get() != Mode.SHIFT) return;
327
328
        if (energy < 0.9f) {
329
            setEnabled(false);
330
            return;
331
        }
332
333
        event.cancel();
334
        event.setIterations(shiftTicks.get());
335
        setEnabled(false);
336
    }
337
338
    @EventHandler
339
    public void onSync(EventSync e) {
340
        if (mode.get() == Mode.MATRIX) {
341
            float delta = notMoving() ? 0.025f : (old.get() ? -0.005f : 0f);
342
            energy = Mth.clamp(energy + delta, 0f, 1f);
343
        }
344
345
        Minecraft mc = Minecraft.getInstance();
346
        if (mc == null || mc.player == null) return;
347
348
        prevPosX = mc.player.getX();
349
        prevPosY = mc.player.getY();
350
        prevPosZ = mc.player.getZ();
351
        yaw = mc.player.getYRot();
352
        pitch = mc.player.getXRot();
353
    }
354
355
    /**
356
     * Update the circular window buffer with one packet (fast or slow).
357
     * Evicts the OLDEST entry, exactly mirroring Vulcan's EvictingQueue.add().
358
     * fastCount stays accurate: only changes when a fast entry is evicted or added.
359
     */
360
    private void vulcanEvalWindow(boolean fast) {
361
        if (vulcanWindowCount == VULCAN_WINDOW_SIZE) {
362
            // evict oldest
363
            if (vulcanWindow[vulcanWindowHead]) vulcanFastCount--;
364
        } else {
365
            vulcanWindowCount++;
366
        }
367
        vulcanWindow[vulcanWindowHead] = fast;
368
        if (fast) vulcanFastCount++;
369
        vulcanWindowHead = (vulcanWindowHead + 1) % VULCAN_WINDOW_SIZE;
370
    }
371
372
    public Mode getMode() {
373
        return mode.get();
374
    }
375
376
    private long getSetbackAge() {
377
        if (lastSetbackTime <= 0L) return Long.MAX_VALUE;
378
        return System.currentTimeMillis() - lastSetbackTime;
379
    }
380
381
    private boolean notMoving() {
382
        Minecraft mc = Minecraft.getInstance();
383
        if (mc == null || mc.player == null) return false;
384
        return prevPosX == mc.player.getX()
385
                && prevPosY == mc.player.getY()
386
                && prevPosZ == mc.player.getZ()
387
                && yaw == mc.player.getYRot()
388
                && pitch == mc.player.getXRot();
389
    }
390
391
    private String boostBindingName() {
392
        return name() + ":" + boostKey.getName();
393
    }
394
395
    private void ensureBoostBind() {
396
        String combo = boostKey.get();
397
        if (combo == null) combo = "NONE";
398
        if (combo.equalsIgnoreCase(lastBoostCombo)) return;
399
400
        String name = boostBindingName();
401
        KeyManager.unregisterAll(name);
402
        if (!boostKey.isNone()) {
403
            KeyManager.registerCombo(name, combo);
404
        }
405
        lastBoostCombo = combo;
406
    }
407
408
    private boolean isBoostHeld() {
409
        String combo = boostKey.get();
410
        if (combo == null || combo.equalsIgnoreCase("NONE")) return false;
411
        return KeyManager.isHeld(boostBindingName());
412
    }
413
414
    public enum Mode {
415
        NORMAL,
416
        MATRIX,
417
        SHIFT,
418
        GRIM,
419
        GRIM_CONCEPT,
420
        VULCAN
421
    }
422
423
    public enum OnFlag {
424
        DISABLE,
425
        NONE,
426
        RESET
427
    }
428
}
429
LiquidBounce (Kotlin)WORLDsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleTimer.ktKotlin · 194 lines · 6.8 KB

Changes the speed the game is running at.

SettingsSpeedNormalSpeedNormalSpeedTicksBoostSpeedBoostSpeedTicksOnMoveSlowSpeedTimeBoostTicksAccountTimerValuesNormalizeDuringCombatAllowNegative
ModuleTimer.ktKotlin · Minecraft 26.2 · 194 lines · 6.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.world
20
21
import net.ccbluex.liquidbounce.config.types.group.Mode
22
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
23
import net.ccbluex.liquidbounce.event.events.NotificationEvent
24
import net.ccbluex.liquidbounce.event.tickHandler
25
import net.ccbluex.liquidbounce.event.waitTicks
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold
29
import net.ccbluex.liquidbounce.utils.client.Timer
30
import net.ccbluex.liquidbounce.utils.client.notification
31
import net.ccbluex.liquidbounce.utils.combat.CombatManager
32
import net.ccbluex.liquidbounce.utils.entity.moving
33
import net.ccbluex.liquidbounce.utils.kotlin.Priority
34
import net.minecraft.client.gui.screens.inventory.ContainerScreen
35
import net.minecraft.client.gui.screens.inventory.InventoryScreen
36
import kotlin.math.abs
37
import kotlin.math.ceil
38
39
/**
40
 * Timer module
41
 *
42
 * Changes the speed of the entire game.
43
 */
44
object ModuleTimer : ClientModule("Timer", ModuleCategories.WORLD, disableOnQuit = true) {
45
46
    val modes = choices("Mode", Classic, arrayOf(Classic, Pulse, Boost)).apply { tagBy(this) }
47
48
    object Classic : Mode("Classic") {
49
50
        override val parent: ModeValueGroup<Mode>
51
            get() = modes
52
53
        private val speed by float("Speed", 2f, 0.1f..20f)
54
55
        val repeatable = tickHandler {
56
            Timer.requestTimerSpeed(speed, Priority.IMPORTANT_FOR_USAGE_1, ModuleTimer)
57
        }
58
59
    }
60
61
    object Pulse : Mode("Pulse") {
62
63
        override val parent: ModeValueGroup<Mode>
64
            get() = modes
65
66
        private val normalSpeed: Float by float("NormalSpeed", 0.5f, 0.1f..20f)
67
        private val normalSpeedTicks by int("NormalSpeedTicks", 20, 1..500, "ticks")
68
        private val boostSpeed by float("BoostSpeed", 2f, 0.1f..20f)
69
        private val boostSpeedTicks by int("BoostSpeedTicks", 20, 1..500, "ticks")
70
        private val onMove by boolean("OnMove", false)
71
        private var currentState: TimerState = TimerState.NORMAL_SPEED
72
73
        override fun enable() {
74
            currentState = TimerState.NORMAL_SPEED
75
        }
76
77
        val repeatable = tickHandler {
78
            if (onMove && !ModuleTimer.player.moving) {
79
                return@tickHandler
80
            }
81
82
            val (nextState, currentSpeed, expirationTicks) = when (currentState) {
83
                TimerState.NORMAL_SPEED -> Triple(TimerState.BOOST_SPEED, normalSpeed, normalSpeedTicks)
84
                TimerState.BOOST_SPEED -> Triple(TimerState.NORMAL_SPEED, boostSpeed, boostSpeedTicks)
85
            }
86
87
            currentState = nextState
88
89
            Timer.requestTimerSpeed(
90
                timerSpeed = currentSpeed,
91
                priority = Priority.IMPORTANT_FOR_USAGE_1,
92
                provider = ModuleTimer,
93
                resetAfterTicks = expirationTicks
94
            )
95
96
            waitTicks(expirationTicks)
97
98
            return@tickHandler
99
        }
100
101
        enum class TimerState {
102
            NORMAL_SPEED, BOOST_SPEED
103
        }
104
105
    }
106
107
    object Boost : Mode("Boost") {
108
109
        override val parent: ModeValueGroup<Mode>
110
            get() = modes
111
112
        private val boostSpeed by float("BoostSpeed", 1.3f, 0.1f..20f)
113
        private val slowSpeed by float("SlowSpeed", 0.6f, 0.1f..20f)
114
115
        private val timeBoostTicks by int("TimeBoostTicks", 12, 1..60, "ticks")
116
        private var boostCapable = 0
117
118
        // basically timer balance
119
        private val accountTimerValue by boolean("AccountTimerValues", true)
120
121
        private val normalizeDuringCombat by boolean("NormalizeDuringCombat", true)
122
        private val allowNegative by boolean("AllowNegative", false)
123
124
        val repeatable = tickHandler {
125
            if (normalizeDuringCombat && CombatManager.isInCombat) {
126
                Timer.requestTimerSpeed(1f, Priority.IMPORTANT_FOR_USAGE_1, ModuleTimer)
127
                return@tickHandler
128
            }
129
130
            if (boostCapable < 0) {
131
                val ticks = abs(boostCapable)
132
                Timer.requestTimerSpeed(
133
                    slowSpeed,
134
                    Priority.IMPORTANT_FOR_USAGE_1,
135
                    ModuleTimer,
136
                    resetAfterTicks = ticks
137
                )
138
139
                notification(
140
                    "Timer", "Slowing down for $ticks ticks",
141
                    NotificationEvent.Severity.INFO
142
                )
143
                boostCapable = 0
144
                waitTicks(ticks)
145
            }
146
147
            if (!player.moving) {
148
                if (mc.gui.screen() is InventoryScreen || mc.gui.screen() is ContainerScreen) {
149
                    boostCapable = 0
150
                    return@tickHandler
151
                }
152
153
                Timer.requestTimerSpeed(slowSpeed, Priority.IMPORTANT_FOR_USAGE_1, ModuleTimer)
154
155
                val addition = if (accountTimerValue) (1 / slowSpeed).toInt() else 1
156
                boostCapable = (boostCapable + addition).coerceAtMost(timeBoostTicks)
157
            } else {
158
                val speedUp = boostCapable > 0 ||
159
                        (allowNegative && (CombatManager.isInCombat || ModuleScaffold.running))
160
161
                if (!speedUp) {
162
                    return@tickHandler
163
                }
164
165
                val ticks = if (boostCapable > 0) boostCapable else timeBoostTicks
166
                val speedUpTicks = if (accountTimerValue) ceil(ticks / boostSpeed).toInt() else ticks
167
168
                if (speedUpTicks == 0) {
169
                    return@tickHandler
170
                }
171
172
                Timer.requestTimerSpeed(
173
                    boostSpeed,
174
                    Priority.IMPORTANT_FOR_USAGE_1,
175
                    ModuleTimer,
176
                    resetAfterTicks = speedUpTicks
177
                )
178
                notification(
179
                    "Timer", "Boosted for $speedUpTicks ticks",
180
                    NotificationEvent.Severity.INFO
181
                )
182
                boostCapable -= ticks
183
                waitTicks(speedUpTicks)
184
            }
185
        }
186
187
    }
188
189
    override fun onDisabled() {
190
        Timer.requestTimerSpeed(1f, Priority.NOT_IMPORTANT, this@ModuleTimer)
191
    }
192
193
}
194