BlockIn module

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

1 implementationWORLD

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)WORLDsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleBlockIn.ktKotlin · 217 lines · 7.8 KB

Builds blocks to cover yourself.

SettingsDisableOnAvoidBrokenBlocksBrokenBlockWindowPlaceOrderFilterBlocks
ModuleBlockIn.ktKotlin · Minecraft 26.2 · 217 lines · 7.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.world
20
21
import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap
22
import it.unimi.dsi.fastutil.objects.ObjectArraySet
23
import net.ccbluex.fastutil.enumSetAllOf
24
import net.ccbluex.liquidbounce.config.types.list.Tagged
25
import net.ccbluex.liquidbounce.event.events.NotificationEvent
26
import net.ccbluex.liquidbounce.event.events.PacketEvent
27
import net.ccbluex.liquidbounce.event.events.PlayerMovementTickEvent
28
import net.ccbluex.liquidbounce.event.events.TransferOrigin
29
import net.ccbluex.liquidbounce.event.handler
30
import net.ccbluex.liquidbounce.event.tickHandler
31
import net.ccbluex.liquidbounce.event.tickUntil
32
import net.ccbluex.liquidbounce.features.module.ClientModule
33
import net.ccbluex.liquidbounce.features.module.ModuleCategories
34
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug.debugParameter
35
import net.ccbluex.liquidbounce.utils.block.placer.BlockPlacer
36
import net.ccbluex.liquidbounce.utils.block.stateOrEmpty
37
import net.ccbluex.liquidbounce.utils.client.notification
38
import net.ccbluex.liquidbounce.utils.collection.Filter
39
import net.ccbluex.liquidbounce.utils.collection.blockSortedSetOf
40
import net.ccbluex.liquidbounce.utils.inventory.HotbarItemSlot
41
import net.ccbluex.liquidbounce.utils.inventory.Slots
42
import net.ccbluex.liquidbounce.utils.item.getBlock
43
import net.ccbluex.liquidbounce.utils.kotlin.Priority
44
import net.minecraft.core.BlockPos
45
import net.minecraft.core.Direction
46
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket
47
import net.minecraft.util.Mth
48
import kotlin.random.Random
49
50
/**
51
 * BlockIn module
52
 *
53
 * Builds blocks to cover yourself.
54
 */
55
object ModuleBlockIn : ClientModule("BlockIn", ModuleCategories.WORLD, disableOnQuit = true) {
56
57
    private val compareByY = Comparator.comparingInt<BlockPos>(BlockPos::getY)
58
59
    private val blockPlacer = tree(BlockPlacer("Placer", this, Priority.NORMAL, ::slotFinder))
60
    private val disableOn by multiEnumChoice("DisableOn", enumSetAllOf<DisableOn>())
61
    private val avoidBrokenBlocks by boolean("AvoidBrokenBlocks", true)
62
    private val brokenBlockWindow by int("BrokenBlockWindow", 1000, 0..10000, "ms")
63
    private val placeOrder by enumChoice("PlaceOrder", Order.Normal)
64
    private val filter by enumChoice("Filter", Filter.BLACKLIST)
65
    private val blocks by blocks("Blocks", blockSortedSetOf())
66
67
    private enum class DisableOn(override val tag: String) : Tagged {
68
        FINISH("Finish"),
69
        MOVE("Move"),
70
    }
71
72
    private enum class Order(override val tag: String) : Tagged {
73
74
        Normal("Normal") {
75
            override fun positions(): Array<BlockPos> {
76
                val playerHeight = Mth.ceil(player.bbHeight)
77
                val result = ObjectArraySet<BlockPos>(10)
78
                result += startPos.below()
79
                rotateSurroundings {
80
                    val value = startPos.relative(it)
81
                    repeat(playerHeight) { i ->
82
                        result += value.above(i)
83
                    }
84
                }
85
                result += startPos.above(playerHeight)
86
87
                return result.toTypedArray()
88
            }
89
        },
90
91
        Random("Random") {
92
            override fun positions(): Array<BlockPos> {
93
                val array = Normal.positions()
94
                array.shuffle()
95
                return array
96
            }
97
        },
98
99
        BottomTop("BottomTop") {
100
            override fun positions(): Array<BlockPos> {
101
                val array = Normal.positions()
102
                array.sortWith(compareByY)
103
                return array
104
            }
105
        },
106
107
        TopBottom("TopBottom") {
108
            private val comparator = compareByY.reversed()
109
            override fun positions(): Array<BlockPos> {
110
                val array = Normal.positions()
111
                array.sortWith(comparator)
112
                return array
113
            }
114
        };
115
116
        abstract fun positions(): Array<BlockPos>
117
    }
118
119
    private val startPos = BlockPos.MutableBlockPos()
120
    private var rotateClockwise = false
121
    private var blockList = emptyList<BlockPos>()
122
    private var moved = false
123
    private val recentlyBrokenBlocks = Long2LongOpenHashMap()
124
125
    override fun onDisabled() {
126
        startPos.set(BlockPos.ZERO)
127
        blockList = emptyList()
128
        moved = false
129
        recentlyBrokenBlocks.clear()
130
        blockPlacer.disable()
131
    }
132
133
    override fun onEnabled() {
134
        startPos.set(player.blockPosition())
135
        rotateClockwise = Random.nextBoolean()
136
        getPositions()
137
    }
138
139
    private inline fun rotateSurroundings(action: (Direction) -> Unit) {
140
        var direction = player.direction
141
        repeat(4) {
142
            action(direction)
143
            // Next direction
144
            direction = if (rotateClockwise) {
145
                direction.clockWise
146
            } else {
147
                direction.counterClockWise
148
            }
149
        }
150
    }
151
152
    private fun getPositions() {
153
        val now = System.currentTimeMillis()
154
        recentlyBrokenBlocks.long2LongEntrySet().removeIf { it.longValue + brokenBlockWindow <= now }
155
        blockList = placeOrder.positions().filter {
156
            it.stateOrEmpty.canBeReplaced() &&
157
                (!avoidBrokenBlocks || !recentlyBrokenBlocks.containsKey(it.asLong()))
158
        }
159
        debugParameter("Place Count") { blockList.size }
160
    }
161
162
    @Suppress("unused")
163
    private val packetHandler = handler<PacketEvent> {
164
        if (!avoidBrokenBlocks || it.origin != TransferOrigin.OUTGOING) {
165
            return@handler
166
        }
167
168
        val packet = it.packet
169
        if (packet is ServerboundPlayerActionPacket &&
170
            packet.action == ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK
171
        ) {
172
            val pos = packet.pos.asLong()
173
            mc.execute { recentlyBrokenBlocks.put(pos, System.currentTimeMillis()) }
174
        }
175
    }
176
177
    @Suppress("unused")
178
    private val tickHandler = tickHandler {
179
        blockPlacer.update(blockList)
180
        tickUntil { blockPlacer.isDone() || moved }
181
182
        if (disableOn.contains(DisableOn.FINISH)) {
183
            notification(name, message("filled"), NotificationEvent.Severity.SUCCESS)
184
            enabled = false
185
        }
186
        getPositions()
187
    }
188
189
    @Suppress("unused")
190
    private val movementHandler = handler<PlayerMovementTickEvent> {
191
        val currentPos = player.blockPosition()
192
193
        if (currentPos != startPos && currentPos != startPos.above()) {
194
            if (disableOn.contains(DisableOn.MOVE)) {
195
                notification(name, message("positionChanged"), NotificationEvent.Severity.ERROR)
196
                enabled = false
197
            } else {
198
                moved = true
199
            }
200
        }
201
    }
202
203
    @JvmStatic
204
    private fun slotFinder(pos: BlockPos?): HotbarItemSlot? {
205
        val blockSlots = Slots.OffhandWithHotbar.mapNotNull {
206
            it to (it.itemStack.getBlock()?.takeIf { b -> filter(b, blocks) } ?: return@mapNotNull null)
207
        }
208
209
        return if (pos in blockList) {
210
            blockSlots.maxByOrNull { (_, block) -> block.defaultDestroyTime() }
211
        } else {
212
            blockSlots.minByOrNull { (_, block) -> block.defaultDestroyTime() }
213
        }?.first
214
    }
215
216
}
217