AutoShoot module

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

1 implementationCOMBAT

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)COMBATsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleAutoShoot.ktKotlin · 289 lines · 10.7 KB

Automatically throws eggs and snowballs at your targets or shoots in QuakeCraft.

SettingsGravityTypeAimOffThresholdSwingModeSelectSlotAutomaticallyTicksUntilSlotResetConsiderInventoryRequiresKillAuraNotDuringCombatConstantLagFilterItems
ModuleAutoShoot.ktKotlin · Minecraft 26.2 · 289 lines · 10.7 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
20
package net.ccbluex.liquidbounce.features.module.modules.combat
21
22
import net.ccbluex.liquidbounce.config.types.group.Mode
23
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
24
import net.ccbluex.liquidbounce.config.types.list.Tagged
25
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
26
import net.ccbluex.liquidbounce.event.handler
27
import net.ccbluex.liquidbounce.event.tickHandler
28
import net.ccbluex.liquidbounce.features.module.ClientModule
29
import net.ccbluex.liquidbounce.features.module.ModuleCategories
30
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura
31
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
32
import net.ccbluex.liquidbounce.utils.aiming.RotationsValueGroup
33
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation
34
import net.ccbluex.liquidbounce.utils.aiming.point.PointTracker
35
import net.ccbluex.liquidbounce.utils.aiming.projectiles.SituationalProjectileAngleCalculator
36
import net.ccbluex.liquidbounce.utils.block.SwingMode
37
import net.ccbluex.liquidbounce.utils.clicking.Clicker
38
import net.ccbluex.liquidbounce.utils.client.SilentHotbar
39
import net.ccbluex.liquidbounce.utils.collection.Filter
40
import net.ccbluex.liquidbounce.utils.collection.itemSortedSetOf
41
import net.ccbluex.liquidbounce.utils.combat.CombatManager
42
import net.ccbluex.liquidbounce.utils.combat.TargetPriority
43
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
44
import net.ccbluex.liquidbounce.utils.inventory.HotbarItemSlot
45
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager
46
import net.ccbluex.liquidbounce.utils.inventory.Slots
47
import net.ccbluex.liquidbounce.utils.inventory.findClosestSlot
48
import net.ccbluex.liquidbounce.utils.entity.useItem
49
import net.ccbluex.liquidbounce.utils.kotlin.Priority
50
import net.ccbluex.liquidbounce.utils.render.TargetRenderer
51
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfo
52
import net.minecraft.world.entity.LivingEntity
53
import net.minecraft.world.item.EggItem
54
import net.minecraft.world.item.Item
55
import net.minecraft.world.item.Items
56
import net.minecraft.world.item.SnowballItem
57
58
/**
59
 * A module that automatically shoots at the nearest enemy.
60
 *
61
 * Specifically designed for Hypixel QuakeCraft.
62
 * However, I mostly have tested them for other game modes such as Cytooxien Lasertag and Paintball.
63
 *
64
 * It also replaces our AutoBalls module as it is more accurate.
65
 *
66
 * @author 1zuna
67
 */
68
object ModuleAutoShoot : ClientModule("AutoShoot", ModuleCategories.COMBAT) {
69
70
    private val throwableType = choices(
71
        "ThrowableType",
72
        EggAndSnowball,
73
        arrayOf(EggAndSnowball, Custom),
74
    )
75
    private val gravityType by enumChoice("GravityType", GravityType.AUTO).apply { tagBy(this) }
76
77
    private val clicker = tree(Clicker(this, mc.options.keyUse, itemCooldown = null))
78
79
    /**
80
     * The target tracker to find the best enemy to attack.
81
     */
82
    internal val targetTracker = tree(TargetTracker(TargetPriority.DISTANCE, floatRange("Range", 3.0f..6f, 1f..256f)))
83
    private val pointTracker = tree(
84
        PointTracker(
85
            this
86
        )
87
    )
88
89
    /**
90
     * So far, I have never seen an anti-cheat which detects high turning speed for actions such as
91
     * shooting.
92
     */
93
    private val rotations = tree(RotationsValueGroup(this))
94
    private val aimOffThreshold by float("AimOffThreshold", 2f, 0.5f..10f)
95
96
    private val swingMode by enumChoice("SwingMode", SwingMode.DO_NOT_HIDE)
97
98
    /**
99
     * The target renderer to render the target, which we are currently aiming at.
100
     */
101
    init {
102
        tree(TargetRenderer(this, targetTracker))
103
    }
104
105
    private val selectSlotAutomatically by boolean("SelectSlotAutomatically", true)
106
    private val tickUntilReset by int("TicksUntilSlotReset", 1, 0..20)
107
    private val considerInventory by boolean("ConsiderInventory", true)
108
109
    private val requiresKillAura by boolean("RequiresKillAura", false)
110
    private val notDuringCombat by boolean("NotDuringCombat", false)
111
    val constantLag by boolean("ConstantLag", false)
112
113
    private val HotbarItemSlot.isSelectionNeeded: Boolean
114
        get() = hotbarIndex != null && hotbarIndex != SilentHotbar.serversideSlot
115
116
    private fun HotbarItemSlot.trySelect(silentHotbarRequester: Any?, select: Boolean, tickUntilReset: Int): Boolean {
117
        // Select the slot if we are not holding it.
118
        if (isSelectionNeeded) {
119
            if (!select) return false
120
            // If we are not holding the slot, we can't shoot.
121
            SilentHotbar.selectSlotSilently(silentHotbarRequester, this, tickUntilReset)
122
            if (isSelectionNeeded) return false
123
        }
124
        return true
125
    }
126
127
    private fun shouldPauseForKillAura(): Boolean {
128
        if (requiresKillAura && !ModuleKillAura.running) {
129
            targetTracker.reset()
130
            return true
131
        }
132
133
        return false
134
    }
135
136
    private fun getThrowableSlot(): HotbarItemSlot? {
137
        val slot = throwableType.activeMode.findSlot() ?: return null
138
139
        return slot.takeIf {
140
            it.trySelect(ModuleAutoShoot, selectSlotAutomatically, tickUntilReset)
141
        }
142
    }
143
144
    private fun getRotation(target: LivingEntity, slot: HotbarItemSlot): Rotation? {
145
        return GravityType.from(slot).rotationFor(target)
146
    }
147
148
    /**
149
     * Simulates the next tick, which we use to figure out the required rotation for the next tick to react
150
     * as fast possible. This means we already pre-aim before we peek around the corner.
151
     */
152
    @Suppress("unused")
153
    private val simulatedTickHandler = handler<RotationUpdateEvent> {
154
        if (shouldPauseForKillAura()) return@handler
155
156
        // Find the recommended target
157
        // Check if we can see the enemy
158
        val target = targetTracker.selectFirst(player::hasLineOfSight) ?: return@handler
159
160
        if (notDuringCombat && CombatManager.isInCombat) {
161
            return@handler
162
        }
163
164
        // Check if we have a throwable, if not we can't shoot.
165
        val slot = getThrowableSlot() ?: return@handler
166
        val rotation = getRotation(target, slot)
167
168
        // Set the rotation with the usage priority of 2.
169
        RotationManager.setRotationTarget(
170
            rotations.toRotationTarget(rotation ?: return@handler, considerInventory = considerInventory),
171
            Priority.IMPORTANT_FOR_USAGE_2, this
172
        )
173
    }
174
175
    override fun onDisabled() {
176
        targetTracker.reset()
177
        SilentHotbar.resetSlot(ModuleAutoShoot)
178
    }
179
180
    /**
181
     * Handles the auto shoot logic.
182
     */
183
    @Suppress("unused")
184
    private val handleAutoShoot = tickHandler {
185
        if (shouldPauseForKillAura()) return@tickHandler
186
187
        val target = targetTracker.target ?: return@tickHandler
188
189
        if (notDuringCombat && CombatManager.isInCombat) {
190
            return@tickHandler
191
        }
192
193
        // Check if we have a throwable, if not we can't shoot.
194
        val slot = getThrowableSlot() ?: return@tickHandler
195
        val rotation = getRotation(target, slot)
196
197
        // Check the difference between server and client rotation
198
        val rotationDifference = RotationManager.serverRotation.directionAngleTo(rotation ?: return@tickHandler)
199
200
        // Check if we are not aiming at the target yet
201
        if (rotationDifference > aimOffThreshold) {
202
            return@tickHandler
203
        }
204
205
        // Check if we are still aiming at the target
206
        clicker.click {
207
            if (player.isUsingItem || (considerInventory && InventoryManager.isInventoryOpen)) {
208
                return@click false
209
            }
210
211
            useItem(
212
                slot.useHand,
213
                swingMode = swingMode,
214
            ).consumesAction()
215
        }
216
    }
217
218
    private sealed class ThrowableTypeMode(
219
        name: String,
220
        aliases: List<String> = emptyList(),
221
    ) : Mode(name, aliases) {
222
        final override val parent: ModeValueGroup<*>
223
            get() = throwableType
224
225
        abstract fun findSlot(): HotbarItemSlot?
226
    }
227
228
    private object EggAndSnowball : ThrowableTypeMode("EggAndSnowball") {
229
        override fun findSlot(): HotbarItemSlot? = Slots.OffhandWithHotbar.findClosestSlot {
230
            it.item is EggItem || it.item is SnowballItem
231
        }
232
    }
233
234
    private object Custom : ThrowableTypeMode("Custom", aliases = listOf("Anything")) {
235
        private val filter by enumChoice("Filter", Filter.WHITELIST)
236
        private val items by items("Items", itemSortedSetOf(Items.EGG, Items.SNOWBALL))
237
238
        override fun findSlot(): HotbarItemSlot? = Slots.OffhandWithHotbar.findClosestSlot {
239
            !it.isEmpty && filter(it.item, items)
240
        }
241
    }
242
243
    private enum class GravityType(override val tag: String) : Tagged {
244
        AUTO("Auto") {
245
            override fun rotationFor(target: LivingEntity): Rotation? = null
246
        },
247
        LINEAR("Linear") {
248
            override fun rotationFor(target: LivingEntity): Rotation {
249
                // On linear we likely don't need to care about gravity,
250
                // but instead aim exactly at the hitbox of the target.
251
                val eyes = player.eyePosition
252
                val point = pointTracker.findPoint(eyes, target, 1)
253
                return Rotation.lookingAt(point.pos, eyes)
254
            }
255
        },
256
        PROJECTILE("Projectile") {
257
            override fun rotationFor(target: LivingEntity): Rotation? {
258
                return SituationalProjectileAngleCalculator.calculateAngleForEntity(
259
                    TrajectoryInfo.GENERIC,
260
                    target
261
                )
262
            }
263
        };
264
265
        abstract fun rotationFor(target: LivingEntity): Rotation?
266
267
        companion object {
268
            @JvmStatic
269
            fun from(slot: HotbarItemSlot): GravityType =
270
                from(slot.itemStack.item)
271
272
            @JvmStatic
273
            fun from(item: Item): GravityType {
274
                return when (gravityType) {
275
                    AUTO -> {
276
                        when (item) {
277
                            is EggItem, is SnowballItem -> PROJECTILE
278
                            else -> LINEAR
279
                        }
280
                    }
281
282
                    else -> gravityType
283
                }
284
            }
285
        }
286
    }
287
288
}
289