FakeLag module

FakeLag: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Combatant, LiquidBounce (Kotlin)).

2 implementationsPLAYERCOMBAT

Full module source: 2 implementations

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

CombatantPLAYERsrc/main/java/combatant/client/features/module/modules/player/FakeLag.javaJava · 157 lines · 4.6 KB
SettingsfakeLagMinRangefakeLagMaxRangefakeLagMinDelayfakeLagMaxDelayfakeLagRecoilTimefakeLagModefakeLagFlushOn
FakeLag.javaJava · Minecraft 26.2 · 157 lines · 4.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on LiquidBounce
6
 * (https://github.com/CCBlueX/LiquidBounce).
7
 * Copyright (c) 2015-2026 CCBlueX.
8
 *
9
 * LiquidBounce portions are licensed under GPLv3-or-later.
10
 * Combatant modifications are licensed under GPLv3.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.features.module.modules.player;
15
16
import combatant.client.config.common.CommonSettingSchemas;
17
import combatant.client.config.common.impl.FakeLagFlushOn;
18
import combatant.client.config.values.BooleanMapValue;
19
import combatant.client.config.values.EnumValue;
20
import combatant.client.config.values.NumberValue;
21
import combatant.client.features.module.Module;
22
import combatant.client.features.module.ModuleCategory;
23
import combatant.client.features.module.ModuleInfo;
24
import combatant.client.util.network.FakeLagController;
25
26
import java.util.EnumSet;
27
28
/**
29
 * FakeLag module front-end for the shared BlinkManager-backed controller.
30
 */
31
//todo Description
32
@ModuleInfo(
33
        id = "fakelag",
34
        displayName = "FakeLag",
35
        category = ModuleCategory.PLAYER
36
)
37
public final class FakeLag extends Module {
38
    private final NumberValue<Float> minRange = numCommon(
39
            "fakeLagMinRange",
40
            "min_range",
41
            CommonSettingSchemas.PLAYER_FAKELAG_RANGE_MIN,
42
            2.0f,
43
            0.0f,
44
            10.0f
45
    );
46
47
    private final NumberValue<Float> maxRange = numCommon(
48
            "fakeLagMaxRange",
49
            "max_range",
50
            CommonSettingSchemas.PLAYER_FAKELAG_RANGE_MAX,
51
            5.0f,
52
            0.0f,
53
            10.0f
54
    );
55
56
    private final NumberValue<Integer> minDelay = numCommon(
57
            "fakeLagMinDelay",
58
            "delay_min",
59
            CommonSettingSchemas.PLAYER_FAKELAG_DELAY_MIN,
60
            300,
61
            0,
62
            1000
63
    );
64
65
    private final NumberValue<Integer> maxDelay = numCommon(
66
            "fakeLagMaxDelay",
67
            "delay_max",
68
            CommonSettingSchemas.PLAYER_FAKELAG_DELAY_MAX,
69
            600,
70
            0,
71
            1000
72
    );
73
74
    private final NumberValue<Integer> recoilTime = numCommon(
75
            "fakeLagRecoilTime",
76
            "recoil_time",
77
            CommonSettingSchemas.PLAYER_FAKELAG_RECOIL_TIME,
78
            250,
79
            0,
80
            1000
81
    );
82
83
    private final EnumValue<FakeLagController.Mode> mode = enumCommon(
84
            "fakeLagMode",
85
            "mode",
86
            CommonSettingSchemas.PLAYER_FAKELAG_MODE,
87
            FakeLagController.Mode.DYNAMIC,
88
            FakeLagController.Mode.class
89
    );
90
91
    private final BooleanMapValue flushOn = groupCommon(
92
            "fakeLagFlushOn",
93
            "flush_on",
94
            CommonSettingSchemas.PLAYER_FAKELAG_FLUSH_ON
95
    );
96
97
    private FakeLagController.Config appliedConfig;
98
99
    @Override
100
    public void onEnable() {
101
        syncControllerConfig();
102
        FakeLagController.INSTANCE.setEnabled(true);
103
    }
104
105
    @Override
106
    public void onDisable() {
107
        FakeLagController.INSTANCE.setEnabled(false);
108
        appliedConfig = null;
109
    }
110
111
    @Override
112
    public void onTick() {
113
        if (!isEnabled()) {
114
            return;
115
        }
116
        syncControllerConfig();
117
    }
118
119
    private void syncControllerConfig() {
120
        FakeLagController.Config config = buildConfig();
121
        if (!config.equals(appliedConfig) || !config.equals(FakeLagController.INSTANCE.getConfig())) {
122
            FakeLagController.INSTANCE.configure(config);
123
            appliedConfig = config;
124
        }
125
    }
126
127
    private FakeLagController.Config buildConfig() {
128
        float min = minRange.get();
129
        float max = maxRange.get();
130
        int minMs = minDelay.get();
131
        int maxMs = maxDelay.get();
132
        return new FakeLagController.Config(
133
                Math.min(min, max),
134
                Math.max(min, max),
135
                Math.min(minMs, maxMs),
136
                Math.max(minMs, maxMs),
137
                recoilTime.get(),
138
                mode.get(),
139
                selectedFlushOn()
140
        );
141
    }
142
143
    private EnumSet<FakeLagController.FlushOn> selectedFlushOn() {
144
        EnumSet<FakeLagController.FlushOn> selected = EnumSet.noneOf(FakeLagController.FlushOn.class);
145
        if (flushOn.get(FakeLagFlushOn.ENTITY_INTERACT)) {
146
            selected.add(FakeLagController.FlushOn.ENTITY_INTERACT);
147
        }
148
        if (flushOn.get(FakeLagFlushOn.BLOCK_INTERACT)) {
149
            selected.add(FakeLagController.FlushOn.BLOCK_INTERACT);
150
        }
151
        if (flushOn.get(FakeLagFlushOn.ACTION)) {
152
            selected.add(FakeLagController.FlushOn.ACTION);
153
        }
154
        return selected;
155
    }
156
}
157
LiquidBounce (Kotlin)COMBATsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleFakeLag.ktKotlin · 257 lines · 9.8 KB

Holds back packets so as to prevent you from being hit by an enemy.

SettingsRangeDelayRecoilTimeModeFlushOn
ModuleFakeLag.ktKotlin · Minecraft 26.2 · 257 lines · 9.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.combat
20
21
import net.ccbluex.liquidbounce.config.types.list.Tagged
22
import net.ccbluex.liquidbounce.event.events.BlinkPacketEvent
23
import net.ccbluex.liquidbounce.event.events.GameTickEvent
24
import net.ccbluex.liquidbounce.event.events.NotificationEvent
25
import net.ccbluex.liquidbounce.event.events.TransferOrigin
26
import net.ccbluex.liquidbounce.event.handler
27
import net.ccbluex.liquidbounce.features.blink.BlinkManager
28
import net.ccbluex.liquidbounce.features.blink.BlinkManager.positions
29
import net.ccbluex.liquidbounce.features.module.ClientModule
30
import net.ccbluex.liquidbounce.features.module.ModuleCategories
31
import net.ccbluex.liquidbounce.features.module.modules.movement.autododge.ModuleAutoDodge
32
import net.ccbluex.liquidbounce.utils.client.Chronometer
33
import net.ccbluex.liquidbounce.utils.client.notification
34
import net.ccbluex.liquidbounce.utils.combat.findEnemy
35
import net.ccbluex.liquidbounce.utils.combat.getEntitiesBoxInRange
36
import net.ccbluex.liquidbounce.utils.combat.shouldBeAttacked
37
import net.ccbluex.liquidbounce.utils.entity.box
38
import net.ccbluex.liquidbounce.utils.item.isConsumable
39
import net.ccbluex.liquidbounce.utils.kotlin.matchesAny
40
import net.minecraft.network.protocol.Packet
41
import net.minecraft.network.protocol.common.ServerboundResourcePackPacket
42
import net.minecraft.network.protocol.game.ClientboundExplodePacket
43
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket
44
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket
45
import net.minecraft.network.protocol.game.ClientboundSetHealthPacket
46
import net.minecraft.network.protocol.game.ServerboundAttackPacket
47
import net.minecraft.network.protocol.game.ServerboundInteractPacket
48
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket
49
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket
50
import net.minecraft.network.protocol.game.ServerboundSpectatorActionPacket
51
import net.minecraft.network.protocol.game.ServerboundSwingPacket
52
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket
53
import net.minecraft.world.phys.Vec3
54
import java.util.function.Predicate
55
import kotlin.jvm.optionals.getOrNull
56
57
/**
58
 * FakeLag module
59
 *
60
 * Holds back packets to prevent you from being hit by an enemy.
61
 */
62
@Suppress("MagicNumber")
63
object ModuleFakeLag : ClientModule("FakeLag", ModuleCategories.COMBAT) {
64
    private val range by floatRange("Range", 2f..5f, 0f..10f)
65
    private val delay by intRange("Delay", 300..600, 0..1000, "ms")
66
    private val recoilTime by int("RecoilTime", 250, 0..1000, "ms")
67
    private val mode by enumChoice("Mode", Mode.DYNAMIC).apply { tagBy(this) }
68
69
    private val flushOn by multiEnumChoice("FlushOn", FlushOn.entries)
70
71
    private enum class FlushOn(
72
        override val tag: String,
73
        private val testPacket: Predicate<Packet<*>?>
74
    ) : Tagged, Predicate<Packet<*>?> by testPacket {
75
        ENTITY_INTERACT("EntityInteract", {
76
            it is ServerboundInteractPacket || it is ServerboundAttackPacket || it is ServerboundSpectatorActionPacket
77
            || it is ServerboundSwingPacket
78
        }),
79
        BLOCK_INTERACT("BlockInteract", {
80
            it is ServerboundUseItemOnPacket
81
            || it is ServerboundSignUpdatePacket
82
        }),
83
        ACTION("Action", {
84
            it is ServerboundPlayerActionPacket
85
        })
86
    }
87
88
    private enum class Mode(override val tag: String) : Tagged {
89
        CONSTANT("Constant"),
90
        DYNAMIC("Dynamic")
91
    }
92
93
    private var nextDelay = delay.random()
94
    private val chronometer = Chronometer()
95
96
    private var isEnemyNearby = false
97
98
    @Suppress("unused")
99
    private val gameTickHandler = handler<GameTickEvent> {
100
        isEnemyNearby = world.findEnemy(range) != null
101
102
        if (ModuleAutoDodge.enabled) {
103
            val position = positions.firstOrNull() ?: return@handler
104
105
            if (ModuleAutoDodge.getInflictedHit(position) == null) {
106
                return@handler
107
            }
108
109
            val evadingPacket = ModuleAutoDodge.findAvoidingArrowPosition()
110
111
            // We have found no packet that avoids getting hit? Then we default to blinking.
112
            // AutoDoge might save the situation...
113
            if (evadingPacket == null) {
114
                notification(
115
                    "FakeLag", "Unable to evade arrow. Blinking.",
116
                    NotificationEvent.Severity.INFO
117
                )
118
                BlinkManager.flush(TransferOrigin.OUTGOING)
119
            } else if (evadingPacket.ticksToImpact != null) {
120
                notification("FakeLag", "Trying to evade arrow...", NotificationEvent.Severity.INFO)
121
                BlinkManager.flush(evadingPacket.idx + 1)
122
            } else {
123
                notification("FakeLag", "Arrow evaded.", NotificationEvent.Severity.INFO)
124
                BlinkManager.flush(evadingPacket.idx + 1)
125
            }
126
        }
127
    }
128
129
    @Suppress("unused", "ComplexCondition")
130
    private val fakeLagHandler = handler<BlinkPacketEvent> { event ->
131
        if (event.origin != TransferOrigin.OUTGOING || player.isDeadOrDying || player.isInWater
132
            || mc.gui.screen() != null
133
        ) {
134
            return@handler
135
        }
136
137
        if (!chronometer.hasAtLeastElapsed(recoilTime.toLong())) {
138
            return@handler
139
        }
140
141
        if (BlinkManager.isAboveTime(nextDelay.toLong())) {
142
            nextDelay = delay.random()
143
            return@handler
144
        }
145
146
        if (flushOn.matchesAny(event.packet)) {
147
            chronometer.reset()
148
            return@handler
149
        }
150
151
        when (val packet = event.packet) {
152
153
            is ClientboundPlayerPositionPacket,
154
            is ServerboundResourcePackPacket -> {
155
                chronometer.reset()
156
                return@handler
157
            }
158
159
            is ServerboundInteractPacket,
160
            is ServerboundAttackPacket,
161
            is ServerboundSpectatorActionPacket,
162
            is ServerboundSwingPacket -> {
163
                if (FlushOn.ENTITY_INTERACT in flushOn) {
164
                    chronometer.reset()
165
                    return@handler
166
                }
167
            }
168
169
            // Flush on knockback
170
            is ClientboundSetEntityMotionPacket -> {
171
                if (packet.id == player.id && packet.movement != Vec3.ZERO) {
172
                    chronometer.reset()
173
                    return@handler
174
                }
175
            }
176
177
            // Flush on explosion
178
            is ClientboundExplodePacket -> {
179
                packet.playerKnockback.getOrNull()?.let { knockback ->
180
                    if (knockback != Vec3.ZERO) {
181
                        chronometer.reset()
182
                        return@handler
183
                    }
184
                }
185
            }
186
187
            // Flush on damage
188
            is ClientboundSetHealthPacket -> {
189
                chronometer.reset()
190
                return@handler
191
            }
192
        }
193
194
        // We don't want to lag when we are using an item that is not a food, milk bucket or potion.
195
        if (player.isUsingItem && player.useItem.isConsumable) {
196
            return@handler
197
        }
198
199
        // Support auto shoot with fake lag
200
        if (running && ModuleAutoShoot.constantLag && ModuleAutoShoot.targetTracker.target == null) {
201
            event.action = BlinkManager.Action.QUEUE
202
            return@handler
203
        }
204
205
        event.action = when (mode) {
206
            Mode.CONSTANT -> BlinkManager.Action.QUEUE
207
            Mode.DYNAMIC -> {
208
                // If there is an enemy in range, we want to lag.
209
                if (!isEnemyNearby) {
210
                    return@handler
211
                }
212
213
                val position = positions.firstOrNull() ?: run {
214
                    event.action = BlinkManager.Action.QUEUE
215
                    return@handler
216
                }
217
                val playerBox = player.dimensions.makeBoundingBox(position)
218
219
                // todo: implement if enemy is facing old player position
220
221
                val entities = world.getEntitiesBoxInRange(position, range.endInclusive.toDouble()) {
222
                    it != player && it.shouldBeAttacked()
223
                }
224
225
                // If there are no entities, we don't want to lag.
226
                if (entities.isEmpty()) {
227
                    return@handler
228
                }
229
230
                val intersects = entities.any {
231
                    it.box.intersects(playerBox)
232
                }
233
                val serverDistance = entities.minOfOrNull {
234
                    it.position().distanceTo(position)
235
                } ?: return@handler
236
                val clientDistance = entities.minOfOrNull {
237
                    it.position().distanceTo(player.position())
238
                } ?: return@handler
239
240
                // If the server position is not closer than the client position, we keep lagging.
241
                // Also, we don't want to lag if the player is intersecting with an entity.
242
                if (serverDistance < clientDistance || intersects) {
243
                    return@handler
244
                }
245
246
                BlinkManager.Action.QUEUE
247
            }
248
        }
249
    }
250
251
    override fun onDisabled() {
252
        isEnemyNearby = false
253
        super.onDisabled()
254
    }
255
256
}
257