FastExp module

FastExp: Minecraft 26.3 cheat module, full source for every implementation (1 client: LiquidBounce (Kotlin)).

1 implementationPLAYER

Clients with this module

Full module source: 1 implementation

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

LiquidBounce (Kotlin)PLAYERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleFastExp.ktKotlin · 289 lines · 10.8 KB

Automatically repairs your armor.

SettingsMinDurabilityToStartRepairMaxDurabilityToContinueRepairTicksPerItemItemsPerTickCombatPauseTimeSlotResetDelay
ModuleFastExp.ktKotlin · Minecraft 26.2 · 289 lines · 10.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.player
20
21
import net.ccbluex.liquidbounce.config.types.group.Mode
22
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
23
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
24
import net.ccbluex.liquidbounce.event.tickConditional
25
import net.ccbluex.liquidbounce.event.tickHandler
26
import net.ccbluex.liquidbounce.event.tickUntil
27
import net.ccbluex.liquidbounce.features.module.ClientModule
28
import net.ccbluex.liquidbounce.features.module.ModuleCategories
29
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleFastExp.NoWaste.maxDurabilityToContinueRepair
30
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleFastExp.NoWaste.minDurabilityToStartRepair
31
import net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.MixinExperienceOrbAccessor
32
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
33
import net.ccbluex.liquidbounce.utils.aiming.RotationsValueGroup
34
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation
35
import net.ccbluex.liquidbounce.utils.combat.CombatManager
36
import net.ccbluex.liquidbounce.utils.input.InputBind
37
import net.ccbluex.liquidbounce.utils.inventory.HotbarItemSlot
38
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager
39
import net.ccbluex.liquidbounce.utils.inventory.Slots
40
import net.ccbluex.liquidbounce.utils.inventory.useHotbarSlotOrOffhand
41
import net.ccbluex.liquidbounce.utils.item.durability
42
import net.ccbluex.liquidbounce.utils.item.getEnchantment
43
import net.ccbluex.liquidbounce.utils.kotlin.Priority
44
import net.ccbluex.liquidbounce.utils.kotlin.random
45
import net.ccbluex.liquidbounce.utils.world.any
46
import net.ccbluex.liquidbounce.utils.world.entityGetter
47
import net.minecraft.world.entity.EntityTypes
48
import net.minecraft.world.entity.EquipmentSlot
49
import net.minecraft.world.item.Items
50
import net.minecraft.world.item.enchantment.Enchantments
51
52
/**
53
 * FastExp module
54
 *
55
 * Automatically repairs your armor.
56
 */
57
object ModuleFastExp : ClientModule(
58
    "FastExp",
59
    ModuleCategories.PLAYER,
60
    bindAction = InputBind.BindAction.HOLD,
61
    disableOnQuit = true
62
) {
63
    /**
64
     * Experience in the orb is deducted by one point for every two durability points repaired.
65
     * For example, one durability point repaired doesn't take any experience away from the orb.
66
     *
67
     * @see <a href=https://minecraft.fandom.com/wiki/Mending#Usage>Mending - Usage</a>
68
     */
69
    private const val REPAIR_RATE = 2
70
71
    /**
72
     * A bottle o' enchanting drops experience orbs worth 3–11 points (average 7.0).
73
     *
74
     * @see <a href=https://minecraft.fandom.com/wiki/Bottle_o%27_Enchanting#Usage>Bottle o' Enchanting - Usage</a>
75
     */
76
    private const val EXPERIENCE_PER_BOTTLE = 7
77
78
    private object Rotate : ToggleableValueGroup(this, "Rotate", true) {
79
        val rotations = tree(RotationsValueGroup(this))
80
    }
81
82
    private object NoWaste : ToggleableValueGroup(this, "NoWaste", true) {
83
        /**
84
         * If at least one of the items to repair has durability lower than or equal to [minDurabilityToStartRepair],
85
         * the module will start throwing experience bottles.
86
         */
87
        val minDurabilityToStartRepair by int("MinDurabilityToStartRepair", 64, 0..2048)
88
89
        /**
90
         * If some experience orbs have been destroyed by lava/fire,
91
         * or the player has switched to items with greater total damage,
92
         * or some experience orbs haven't reached the player due to movement, etc.,
93
         *
94
         * then the module can start throwing experience bottles again to complete the repair process,
95
         * but only if there is still at least one item
96
         * whose durability is lower than or equal to [maxDurabilityToContinueRepair]%.
97
         *
98
         * This should prevent the module from repairing armor after every 2 or 3 received hits.
99
         */
100
        val maxDurabilityToContinueRepair by int("MaxDurabilityToContinueRepair", 85, 1..100, "%")
101
    }
102
103
    init {
104
        tree(Rotate)
105
        tree(NoWaste)
106
    }
107
108
    private val throwMode = modes(this,
109
        "ThrowMode",
110
        Normal ,
111
        arrayOf(Normal, Fast)
112
    )
113
114
    private sealed class ThrowMode(name: String) : Mode(name) {
115
        final override val parent: ModeValueGroup<ThrowMode>
116
            get() = throwMode
117
118
        abstract fun nextTickItems(): Float
119
    }
120
121
    private object Normal : ThrowMode("Normal") {
122
        private val ticksPerItem by floatRange("TicksPerItem", 2f..3f, 0.5f..10f, "ticks")
123
        override fun nextTickItems(): Float = 1f / ticksPerItem.random()
124
    }
125
126
    private object Fast : ThrowMode("Fast") {
127
        private val itemsPerTick by floatRange("ItemsPerTick", 3f..5f, 0.5f..16f)
128
        override fun nextTickItems(): Float = itemsPerTick.random()
129
    }
130
131
    private val combatPauseTime by int("CombatPauseTime", 0, 0..40, "ticks")
132
    private val slotResetDelay by intRange("SlotResetDelay", 0..0, 0..40, "ticks")
133
134
    private var bottlesRequired = 0
135
    private var bottlesUsed = 0
136
    private var itemsToThrow = 0f
137
    private var repairing = false
138
139
    override fun onDisabled() {
140
        bottlesUsed = 0
141
        bottlesRequired = 0
142
        itemsToThrow = 0f
143
        repairing = false
144
        super.onDisabled()
145
    }
146
147
    @Suppress("unused")
148
    private val repeatable = tickHandler {
149
        if (InventoryManager.isHandledScreenOpen) {
150
            // doesn't throw exp bottles when an inventory is open
151
            // yet doesn't stop the repairing process either
152
            // allowing to refill the hotbar with exp bottles, if needed.
153
            return@tickHandler
154
        }
155
156
        val slot = Slots.OffhandWithHotbar.findSlot(Items.EXPERIENCE_BOTTLE)
157
        if (slot == null || player.isDeadOrDying) {
158
            bottlesUsed = 0
159
            bottlesRequired = 0
160
            repairing = false
161
            return@tickHandler
162
        }
163
164
        if (!NoWaste.enabled) {
165
            action(slot)
166
            return@tickHandler
167
        }
168
169
        val bottlesRequiredCurrently = getRequiredExperienceBottleCount(slot)
170
171
        if (bottlesRequiredCurrently < 1) {
172
            bottlesUsed = 0
173
            bottlesRequired = 0
174
            return@tickHandler
175
        }
176
177
        // waits for the orbs, in case there are any, to get absorbed before repairing items
178
        tickUntil {
179
            repairing || !anyExpOrbMovingToPlayer()
180
        }
181
182
        repairing = true
183
        bottlesRequired = bottlesRequired.coerceAtLeast(bottlesRequiredCurrently)
184
185
        action(slot)
186
187
        // after all experience bottles have been thrown
188
        if (bottlesUsed > 0 && bottlesUsed >= bottlesRequired) {
189
            waitForExperienceOrbs()
190
            bottlesUsed = 0
191
            bottlesRequired = 0
192
        }
193
    }
194
195
    private fun anyExpOrbMovingToPlayer(): Boolean =
196
        world.entityGetter.any(EntityTypes.EXPERIENCE_ORB) {
197
            (it as MixinExperienceOrbAccessor).followingPlayer === player
198
                && it.deltaMovement.lengthSqr() > player.deltaMovement.lengthSqr()
199
        }
200
201
    private suspend fun waitForExperienceOrbs() {
202
        // waits for experience orbs to appear
203
        // waits up to 10 ticks because the orbs might get absorbed instantly if they come only from a very few bottles
204
        tickConditional(10, ::anyExpOrbMovingToPlayer)
205
206
        // waits for the orbs to get absorbed
207
        tickUntil {
208
            !anyExpOrbMovingToPlayer()
209
        }
210
    }
211
212
    private suspend fun action(slot: HotbarItemSlot) {
213
        CombatManager.pauseCombatForAtLeast(combatPauseTime)
214
215
        if (Rotate.enabled) {
216
            tickUntil {
217
                val rotation = Rotation(player.yRot, 90f)
218
                RotationManager.setRotationTarget(
219
                    Rotate.rotations.toRotationTarget(rotation),
220
                    Priority.IMPORTANT_FOR_USAGE_3,
221
                    this@ModuleFastExp
222
                )
223
                RotationManager.serverRotation.pitch > 85f
224
            }
225
        }
226
227
        itemsToThrow += throwMode.activeMode.nextTickItems()
228
        val times = itemsToThrow.toInt()
229
        itemsToThrow -= times
230
231
        val pitch = if (Rotate.enabled) RotationManager.serverRotation.pitch else 90f
232
        repeat(times) {
233
            useHotbarSlotOrOffhand(
234
                slot,
235
                slotResetDelay.random(),
236
                xRot = pitch
237
            )
238
        }
239
240
        if (NoWaste.enabled) {
241
            bottlesUsed += times
242
        }
243
    }
244
245
    /**
246
     * Assuming how much one experience bottle can repair,
247
     * returns the experience bottle count needed to repair
248
     * all the player's armor and the item in their other hand.
249
     */
250
    private fun getRequiredExperienceBottleCount(slot: HotbarItemSlot): Int {
251
        if (!NoWaste.enabled) {
252
            return Int.MAX_VALUE
253
        }
254
255
        val itemsToRepair = arrayOf(
256
            player.getItemBySlot(EquipmentSlot.HEAD),
257
            player.getItemBySlot(EquipmentSlot.CHEST),
258
            player.getItemBySlot(EquipmentSlot.LEGS),
259
            player.getItemBySlot(EquipmentSlot.FEET),
260
            // an item in the other hand, not holding the exp bottle could also get repaired
261
            if (slot.isOffHand) {
262
                player.getItemBySlot(EquipmentSlot.MAINHAND)
263
            } else {
264
                player.getItemBySlot(EquipmentSlot.OFFHAND)
265
            },
266
        ).filter { it.getEnchantment(Enchantments.MENDING) != 0 }
267
268
        // doesn't let the module start repairing the items again
269
        // when the items have been repaired but not fully and are missing a just few more exp bottle
270
        if (bottlesUsed == 0 && repairing
271
            && itemsToRepair.none { 100f * it.durability / it.maxDamage <= maxDurabilityToContinueRepair } ) {
272
            repairing = false
273
            return 0
274
        }
275
276
        // doesn't let the module start repairing items if the durability threshold hasn't been reached
277
        if (bottlesUsed == 0 && !repairing
278
            && itemsToRepair.none { it.durability <= minDurabilityToStartRepair }) {
279
            return 0
280
        }
281
282
        val totalDamage = itemsToRepair.sumOf { it.damageValue }
283
        val experienceRequired = totalDamage / REPAIR_RATE
284
        val bottlesRequired = experienceRequired / EXPERIENCE_PER_BOTTLE
285
286
        return bottlesRequired.coerceAtMost(slot.itemStack.count)
287
    }
288
}
289