AutoPearl module

AutoPearl: 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/misc/ModuleAutoPearl.ktKotlin · 250 lines · 8.8 KB

Aims and throws a pearl at an enemies pearl trajectory.

SettingsModeAngleMinDistanceDestinationDistanceCombatPauseTimeSlotResetDelay
ModuleAutoPearl.ktKotlin · Minecraft 26.2 · 250 lines · 8.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.misc
20
21
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
22
import net.ccbluex.liquidbounce.config.types.list.Tagged
23
import net.ccbluex.liquidbounce.event.events.PacketEvent
24
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.event.sequenceHandler
27
import net.ccbluex.liquidbounce.event.tickConditional
28
import net.ccbluex.liquidbounce.event.tickHandler
29
import net.ccbluex.liquidbounce.features.module.ClientModule
30
import net.ccbluex.liquidbounce.features.module.ModuleCategories
31
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura
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.aiming.projectiles.SituationalProjectileAngleCalculator
36
import net.ccbluex.liquidbounce.utils.aiming.utils.RotationUtil
37
import net.ccbluex.liquidbounce.utils.combat.CombatManager
38
import net.ccbluex.liquidbounce.utils.combat.shouldBeAttacked
39
import net.ccbluex.liquidbounce.utils.inventory.Slots
40
import net.ccbluex.liquidbounce.utils.inventory.useHotbarSlotOrOffhand
41
import net.ccbluex.liquidbounce.utils.kotlin.Priority
42
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfo
43
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfoRenderer
44
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryType
45
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
46
import net.minecraft.world.entity.Entity
47
import net.minecraft.world.entity.EntityDimensions
48
import net.minecraft.world.entity.EntitySpawnReason
49
import net.minecraft.world.entity.EntityTypes
50
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl
51
import net.minecraft.world.item.Items
52
import net.minecraft.world.phys.HitResult
53
import net.minecraft.world.phys.Vec3
54
55
private const val MAX_SIMULATED_TICKS = 240
56
57
/**
58
 * Auto pearl module
59
 *
60
 * AutoPearl aims and throws a pearl at an enemies pearl trajectory
61
 *
62
 * @author sqlerrorthing
63
 */
64
object ModuleAutoPearl : ClientModule(
65
    "AutoPearl",
66
    ModuleCategories.COMBAT,
67
    aliases = listOf("PearlFollower", "PearlTarget")
68
) {
69
70
    private val mode by enumChoice("Mode", Modes.TRIGGER)
71
72
    private object Limits : ToggleableValueGroup(this, "Limits", true) {
73
        val angle by int("Angle", 180, 0..180, suffix = "°")
74
        val activationDistance by float("MinDistance", 8.0f, 0.0f..10.0f, suffix = "m")
75
        val destDistance by float("DestinationDistance", 8.0f, 0.0f..30.0f, suffix = "m")
76
    }
77
78
    private object Rotate : ToggleableValueGroup(this, "Rotate", true) {
79
        val rotations = tree(RotationsValueGroup(this))
80
    }
81
82
    init {
83
        treeAll(Rotate, Limits)
84
    }
85
86
    private val combatPauseTime by int("CombatPauseTime", 0, 0..40, "ticks")
87
    private val slotResetDelay by intRange("SlotResetDelay", 0..0, 0..40, "ticks")
88
89
    private val queue = ArrayDeque<Rotation>()
90
91
    @Suppress("unused")
92
    private val pearlSpawnHandler = handler<PacketEvent> { event ->
93
        if (event.packet !is ClientboundAddEntityPacket || event.packet.type != EntityTypes.ENDER_PEARL) {
94
            return@handler
95
        }
96
97
        Slots.OffhandWithHotbar.findSlot(Items.ENDER_PEARL) ?: return@handler
98
99
        val data = event.packet
100
        val entity = data.type.create(world, EntitySpawnReason.SPAWN_ITEM_USE) as ThrownEnderpearl
101
        entity.recreateFromPacket(data)
102
103
        proceedPearl(
104
            pearl = entity,
105
            // entity.velocity & entity.pos doesn't work, don't use it
106
            velocity = with(data) { Vec3(movement.x, movement.y, movement.z) },
107
            pearlPos = with(data) { Vec3(x, y, z) }
108
        )
109
    }
110
111
    @Suppress("unused")
112
    private val simulatedTickHandler = sequenceHandler<RotationUpdateEvent> {
113
        val rotation = queue.firstOrNull() ?: return@sequenceHandler
114
115
        CombatManager.pauseCombatForAtLeast(combatPauseTime)
116
        if (Rotate.enabled) {
117
            RotationManager.setRotationTarget(
118
                Rotate.rotations.toRotationTarget(rotation),
119
                Priority.IMPORTANT_FOR_USAGE_3,
120
                this@ModuleAutoPearl
121
            )
122
        }
123
    }
124
125
    @Suppress("unused")
126
    private val gameTickHandler = tickHandler {
127
        val rotation = queue.removeFirstOrNull() ?: return@tickHandler
128
        val itemSlot = Slots.OffhandWithHotbar.findSlot(Items.ENDER_PEARL) ?: return@tickHandler
129
130
        if (Rotate.enabled) {
131
            fun isRotationSufficient(): Boolean {
132
                return RotationManager.serverRotation.directionAngleTo(rotation) <= 1.0f
133
            }
134
135
            tickConditional(20) {
136
                RotationManager.setRotationTarget(
137
                    Rotate.rotations.toRotationTarget(rotation),
138
                    Priority.IMPORTANT_FOR_USAGE_3,
139
                    this@ModuleAutoPearl
140
                )
141
142
                isRotationSufficient()
143
            }
144
145
            if (!isRotationSufficient()) {
146
                return@tickHandler
147
            }
148
        }
149
150
        val (yaw, pitch) = rotation.normalize()
151
        useHotbarSlotOrOffhand(itemSlot, slotResetDelay.random(), yaw, pitch)
152
    }
153
154
    private fun proceedPearl(
155
        pearl: ThrownEnderpearl,
156
        velocity: Vec3,
157
        pearlPos: Vec3
158
    ) {
159
        if (!canTrigger(pearl)) {
160
            return
161
        }
162
163
        val destination = runSimulation(
164
            owner = pearl.owner ?: player,
165
            velocity = velocity,
166
            pos = pearlPos
167
        )?.location ?: return
168
169
        if (Limits.enabled && Limits.activationDistance > destination.distanceTo(player.position())) {
170
            return
171
        }
172
173
        val rotation = SituationalProjectileAngleCalculator.calculateAngleForStaticTarget(
174
            TrajectoryInfo.GENERIC,
175
            destination,
176
            EntityDimensions.fixed(1.0F, 0.0F)
177
        ) ?: return
178
179
        if (!canThrow(rotation, destination)) {
180
            return
181
        }
182
183
        if (queue.isEmpty()) {
184
            queue.add(rotation)
185
        }
186
    }
187
188
    private fun canTrigger(pearl: ThrownEnderpearl): Boolean {
189
        if (Limits.enabled && Limits.angle < RotationUtil.crosshairAngleToEntity(pearl)) {
190
            return false
191
        }
192
193
        if (pearl.owner == null) {
194
            return mode == Modes.TRIGGER
195
        }
196
197
        if (pearl.owner === player) {
198
            return false
199
        }
200
201
        return when(mode) {
202
            Modes.TRIGGER -> pearl.owner!!.shouldBeAttacked()
203
            Modes.TARGET -> ModuleKillAura.targetTracker.target === pearl.owner
204
        }
205
    }
206
207
    private fun canThrow(
208
        angles: Rotation,
209
        destination: Vec3
210
    ): Boolean {
211
        val simulatedDestination = TrajectoryInfoRenderer.getHypotheticalTrajectory(
212
            simulationOwner = player,
213
            trajectoryInfo = TrajectoryInfo.GENERIC,
214
            trajectoryType = TrajectoryType.EnderPearl,
215
            rotation = angles
216
        ).runSimulation(MAX_SIMULATED_TICKS).hitResult?.location ?: return false
217
218
        return !Limits.enabled || Limits.destDistance > destination.distanceTo(simulatedDestination)
219
    }
220
221
    private fun runSimulation(
222
        owner: Entity,
223
        velocity: Vec3,
224
        pos: Vec3,
225
        trajectoryInfo: TrajectoryInfo = TrajectoryInfo.GENERIC,
226
        renderOffset: Vec3 = Vec3.ZERO
227
    ): HitResult? =
228
        TrajectoryInfoRenderer(
229
            simulationOwner = owner,
230
            displayOwner = owner,
231
            icon = Items.ENDER_PEARL.defaultInstance,
232
            velocity = velocity,
233
            pos = pos,
234
            trajectoryInfo = trajectoryInfo,
235
            trajectoryType = TrajectoryType.EnderPearl,
236
            type = TrajectoryInfoRenderer.Type.REAL,
237
            renderOffset = renderOffset
238
        ).runSimulation(MAX_SIMULATED_TICKS).hitResult
239
240
    override fun onDisabled() {
241
        queue.clear()
242
    }
243
244
    private enum class Modes(override val tag: String) : Tagged {
245
        TRIGGER("Trigger"),
246
        TARGET("Target")
247
    }
248
249
}
250