MiddleClickAction module

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

1 implementationMISC

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)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleMiddleClickAction.ktKotlin · 163 lines · 5.5 KB

Allows you to perform actions with middle clicks.

SettingsSlotResetDelayStopOnSubmitPickUpRange
ModuleMiddleClickAction.ktKotlin · Minecraft 26.2 · 163 lines · 5.5 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.Mode
22
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
23
import net.ccbluex.liquidbounce.event.events.GameTickEvent
24
import net.ccbluex.liquidbounce.event.events.NotificationEvent
25
import net.ccbluex.liquidbounce.event.events.WorldChangeEvent
26
import net.ccbluex.liquidbounce.event.handler
27
import net.ccbluex.liquidbounce.features.misc.FriendManager
28
import net.ccbluex.liquidbounce.features.module.ClientModule
29
import net.ccbluex.liquidbounce.features.module.ModuleCategories
30
import net.ccbluex.liquidbounce.utils.client.SilentHotbar
31
import net.ccbluex.liquidbounce.utils.client.notification
32
import net.ccbluex.liquidbounce.utils.entity.rotation
33
import net.ccbluex.liquidbounce.utils.inventory.Slots
34
import net.ccbluex.liquidbounce.utils.inventory.useHotbarSlotOrOffhand
35
import net.ccbluex.liquidbounce.utils.raytracing.findEntityInCrosshair
36
import net.ccbluex.liquidbounce.utils.raytracing.isLookingAtEntity
37
import net.minecraft.world.entity.player.Player
38
import net.minecraft.world.item.Items
39
40
/**
41
 * MiddleClickAction module
42
 *
43
 * Allows you to perform actions with middle clicks.
44
 */
45
object ModuleMiddleClickAction : ClientModule(
46
    "MiddleClickAction",
47
    ModuleCategories.MISC,
48
    aliases = listOf("FriendClicker", "MiddleClickPearl")
49
) {
50
51
    init {
52
        doNotIncludeAlways()
53
    }
54
55
    private val mode = modes(this, "Mode", FriendClicker, arrayOf(FriendClicker, Pearl))
56
57
    override fun onDisabled() {
58
        SilentHotbar.resetSlot(Pearl)
59
        Pearl.disable()
60
    }
61
62
    object Pearl : Mode("Pearl") {
63
64
        private val slotResetDelay by int("SlotResetDelay", 1, 0..10, "ticks")
65
        private val stopOnSubmit by floatRange("StopOnSubmit", 85F..90F, 60F..90F, "Pitch")
66
        private var wasPressed = false
67
68
        val repeatable = handler<GameTickEvent> {
69
            if (mc.gui.screen() != null) {
70
                wasPressed = false
71
                return@handler
72
            }
73
74
            if (player.xRot in stopOnSubmit) {
75
                wasPressed = false
76
                return@handler
77
            }
78
79
            val pickup = mc.options.keyPickItem.isDown
80
81
            if (pickup) {
82
                // visually select the slot
83
                val slot = Slots.OffhandWithHotbar.findSlot(Items.ENDER_PEARL) ?: return@handler
84
                SilentHotbar.selectSlotSilently(this, slot, slotResetDelay)
85
                wasPressed = true
86
            } else if (wasPressed) { // the key was released
87
                Slots.OffhandWithHotbar.findSlot(Items.ENDER_PEARL)?.let {
88
                    useHotbarSlotOrOffhand(it, slotResetDelay)
89
                }
90
                wasPressed = false
91
            }
92
        }
93
94
        @Suppress("unused")
95
        private val handler = handler<WorldChangeEvent> {
96
            wasPressed = false
97
        }
98
99
        override fun disable() {
100
            wasPressed = false
101
        }
102
103
        fun cancelPick(): Boolean {
104
            return ModuleMiddleClickAction.running &&
105
                mode.activeMode == this &&
106
                Slots.OffhandWithHotbar.findSlot(Items.ENDER_PEARL) != null
107
        }
108
109
        override val parent: ModeValueGroup<*>
110
            get() = mode
111
112
    }
113
114
    object FriendClicker : Mode("FriendClicker") {
115
116
        private val pickUpRange by float("PickUpRange", 3.0f, 1f..100f)
117
118
        private var clicked = false
119
120
        val repeatable = handler<GameTickEvent> {
121
            val rotation = player.rotation
122
123
            val entity = (findEntityInCrosshair(pickUpRange.toDouble(), rotation) { it is Player }
124
                ?: return@handler).entity as Player
125
126
            val entityHitResult = isLookingAtEntity(
127
                toEntity = entity, rotation = rotation, range = pickUpRange.toDouble(),
128
                throughWallsRange = 0.0
129
            )
130
131
            val pickup = mc.options.keyPickItem.isDown
132
133
            if (entityHitResult != null && pickup && !clicked) {
134
                val name = entity.scoreboardName
135
136
                if (FriendManager.isFriend(name)) {
137
                    FriendManager.remove(name)
138
                    notification(
139
                        "FriendClicker",
140
                        message("removedFriend", name),
141
                        NotificationEvent.Severity.INFO
142
                    )
143
                } else {
144
                    FriendManager.add(FriendManager.Friend(name, null))
145
146
                    notification(
147
                        "FriendClicker",
148
                        message("addedFriend", name),
149
                        NotificationEvent.Severity.INFO
150
                    )
151
                }
152
            }
153
154
            clicked = pickup
155
        }
156
157
        override val parent: ModeValueGroup<*>
158
            get() = mode
159
160
    }
161
162
}
163