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.combat
19+
20+ import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
21+ import com.lambda.config.applyEdits
22+ import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint
23+ import com.lambda.interaction.construction.verify.TargetState
24+ import com.lambda.interaction.managers.interacting.InteractConfig
25+ import com.lambda.module.Module
26+ import com.lambda.module.modules.combat.PlayerTrap.getTrapPositions
27+ import com.lambda.module.tag.ModuleTag
28+ import com.lambda.task.RootTask.run
29+ import com.lambda.task.Task
30+ import com.lambda.task.tasks.BuildTask.Companion.build
31+ import com.lambda.util.item.ItemUtils.block
32+ import com.lambda.util.player.SlotUtils.hotbarAndStorage
33+ import net.minecraft.block.Blocks
34+ import net.minecraft.item.BlockItem
35+
36+ object Surround : Module(
37+ name = " Surround" ,
38+ description = " Surrounds your players feet with any given block" ,
39+ tag = ModuleTag .COMBAT
40+ ) {
41+ private val blocks by setting(" Blocks" , setOf (Blocks .OBSIDIAN , Blocks .ENDER_CHEST , Blocks .CRYING_OBSIDIAN ))
42+
43+ private var task: Task <* >? = null
44+
45+ init {
46+ setDefaultAutomationConfig {
47+ applyEdits {
48+ buildConfig.apply {
49+ editTyped(
50+ ::pathing,
51+ ::stayInRange,
52+ ::spleefEntities,
53+ ::collectDrops
54+ ) { defaultValue(false ); hide() }
55+ ::checkSideVisibility.edit { defaultValue(false ) }
56+ }
57+ interactConfig.apply {
58+ ::airPlace.edit { defaultValue(InteractConfig .AirPlaceMode .Grim ) }
59+ }
60+ hideGroup(eatConfig)
61+ }
62+ }
63+
64+ onEnable {
65+ task = tickingBlueprint {
66+ val block = player.hotbarAndStorage.firstOrNull {
67+ it.item is BlockItem && blocks.contains(it.item.block)
68+ }?.item?.block ? : return @tickingBlueprint emptyMap()
69+ getTrapPositions(player)
70+ .filter { it.y <= player.blockPos.y }
71+ .associateWith { TargetState .Block (block) }
72+ }.build(finishOnDone = false ).run ()
73+ }
74+ onDisable { task?.cancel(); task = null }
75+ }
76+ }
0 commit comments