1+ /*
2+ * Copyright 2025 Lambda
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+ package com.lambda.module.modules.player
19+
20+ import com.lambda.config.groups.BuildSettings
21+ import com.lambda.config.groups.HotbarSettings
22+ import com.lambda.config.groups.InteractionSettings
23+ import com.lambda.config.groups.InventorySettings
24+ import com.lambda.config.groups.RotationSettings
25+ import com.lambda.event.events.PlayerEvent
26+ import com.lambda.event.listener.SafeListener.Companion.listen
27+ import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure
28+ import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint
29+ import com.lambda.interaction.construction.context.BuildContext
30+ import com.lambda.interaction.construction.result.BreakResult
31+ import com.lambda.interaction.construction.simulation.BuildSimulator.simulate
32+ import com.lambda.interaction.construction.verify.TargetState
33+ import com.lambda.interaction.request.breaking.BreakRequest
34+ import com.lambda.module.Module
35+ import com.lambda.module.tag.ModuleTag
36+ import com.lambda.util.BlockUtils.blockState
37+ import com.lambda.util.world.raycast.InteractionMask
38+ import java.util.concurrent.ConcurrentLinkedQueue
39+
40+ object PacketMine : Module(
41+ " Packet Mine" ,
42+ " automatically breaks blocks, and does it faster" ,
43+ setOf(ModuleTag .PLAYER )
44+ ) {
45+ private val page by setting(" Page" , Page .Build )
46+
47+ private val build = BuildSettings (this ) { page == Page .Build }
48+ private val rotation = RotationSettings (this ) { page == Page .Rotation }
49+ private val interact = InteractionSettings (this , InteractionMask .Block ) { page == Page .Interaction }
50+ private val inventory = InventorySettings (this ) { page == Page .Inventory }
51+ private val hotbar = HotbarSettings (this ) { page == Page .Hotbar }
52+
53+ private val pendingInteractionsList = ConcurrentLinkedQueue <BuildContext >()
54+
55+ private var breaks = 0
56+ private var itemDrops = 0
57+
58+ init {
59+ listen<PlayerEvent .Attack .Block > { event ->
60+ event.cancel()
61+
62+ val blockState = blockState(event.pos)
63+ val buildResult = event.pos
64+ .toStructure(TargetState .State (blockState.fluidState.blockState))
65+ .toBlueprint()
66+ .simulate(
67+ player.eyePos,
68+ interact = interact,
69+ rotation = rotation,
70+ inventory = inventory,
71+ build = build
72+ )
73+ .minOrNull() ? : return @listen
74+
75+ if (buildResult !is BreakResult .Break ) return @listen
76+ val request = BreakRequest (
77+ listOf (buildResult.context), build, rotation, interact, inventory, hotbar,
78+ pendingInteractionsList = pendingInteractionsList,
79+ onBreak = { breaks++ }
80+ ) { _ -> itemDrops++ }
81+ build.breakSettings.request(request)
82+ }
83+ }
84+
85+ enum class Page {
86+ Build , Rotation , Interaction , Inventory , Hotbar
87+ }
88+ }
0 commit comments