Skip to content

Commit 9c79e0c

Browse files
committed
move Default config settings into Client module and add client sounds setting
1 parent c27f437 commit 9c79e0c

11 files changed

Lines changed: 89 additions & 55 deletions

File tree

src/main/kotlin/com/lambda/config/AutomationConfig.kt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import com.lambda.config.groups.InteractSettings
2626
import com.lambda.config.groups.InventorySettings
2727
import com.lambda.config.groups.RotationSettings
2828
import com.lambda.context.Automated
29-
import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer
30-
import com.lambda.interaction.construction.simulation.result.Drawable
3129
import com.lambda.module.Module
3230
import com.lambda.util.NamedEnum
3331

@@ -72,23 +70,6 @@ open class AutomationConfig(
7270
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
7371
}
7472

75-
object DEFAULT : AutomationConfig("Default") {
76-
val renders by setting("Render", false).group(Group.Render)
77-
val avoidDesync by setting("Avoid Desync", true, "Cancels incoming inventory update packets if they match previous actions").group(Group.Debug)
78-
val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidDesync }.group(Group.Debug)
79-
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug)
80-
val shrinkFactor by setting("Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.Debug)
81-
val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug)
82-
val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs").group(Group.Debug)
83-
84-
@Volatile
85-
var drawables = listOf<Drawable>()
86-
87-
init {
88-
tickedRenderer("Ticked Automation Config Renderer") {
89-
if (renders) drawables.forEach { with(it) { render() } }
90-
}
91-
}
92-
}
73+
object DEFAULT : AutomationConfig("Default")
9374
}
9475
}

src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.lambda.gui.snap.SnapManager.drawDragGrid
3636
import com.lambda.gui.snap.SnapManager.drawSnapLines
3737
import com.lambda.gui.snap.SnapManager.updateDragAndSnapping
3838
import com.lambda.module.ModuleRegistry
39+
import com.lambda.module.modules.client.Client
3940
import com.lambda.module.tag.ModuleTag
4041
import com.lambda.module.tag.ModuleTag.Companion.shownTags
4142
import com.lambda.sound.LambdaSound
@@ -362,7 +363,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
362363
LambdaScreen.close()
363364
} else {
364365
if (!mc.currentScreen.hasInput) {
365-
LambdaSound.ModuleOn.play()
366+
if (Client.clientSounds) LambdaSound.ModuleOn.play()
366367
mc.setScreen(LambdaScreen)
367368
open = true
368369
frameCount = 0
@@ -372,7 +373,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
372373
}
373374

374375
fun close() {
375-
LambdaSound.ModuleOff.play()
376+
if (Client.clientSounds) LambdaSound.ModuleOff.play()
376377
open = false
377378
}
378379

src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
package com.lambda.interaction.managers.breaking
1919

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21-
import com.lambda.config.AutomationConfig.Companion.DEFAULT.verboseDebug
21+
import com.lambda.module.modules.client.Client
22+
import com.lambda.module.modules.client.Client.verboseDebug
2223
import com.lambda.context.SafeContext
2324
import com.lambda.event.events.EntityEvent
2425
import com.lambda.event.events.WorldEvent
@@ -61,7 +62,7 @@ object BrokenBlockHandler : PostActionHandler<BreakInfo>() {
6162
if (!info.broken) {
6263
val message = "${info.type} ${info::class.simpleName} at ${info.context.blockPos.toShortString()} timed out with cached state ${info.context.cachedState}"
6364
if (verboseDebug) this@BrokenBlockHandler.warn(message)
64-
} else if (!DEFAULT.ignoreItemDropWarnings) {
65+
} else if (!Client.ignoreItemDropWarnings) {
6566
val message = "${info.type} ${info::class.simpleName}'s item drop at ${info.context.blockPos.toShortString()} timed out"
6667
if (verboseDebug) this@BrokenBlockHandler.warn(message)
6768
}

src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package com.lambda.interaction.managers.interacting
1919

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21-
import com.lambda.config.AutomationConfig.Companion.DEFAULT.verboseDebug
21+
import com.lambda.module.modules.client.Client.verboseDebug
2222
import com.lambda.event.events.WorldEvent
2323
import com.lambda.event.listener.SafeListener.Companion.listen
2424
import com.lambda.interaction.managers.PostActionHandler

src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package com.lambda.interaction.managers.inventory
1919

20-
import com.lambda.config.AutomationConfig.Companion.DEFAULT
2120
import com.lambda.context.AutomatedSafeContext
2221
import com.lambda.context.SafeContext
2322
import com.lambda.event.events.PacketEvent
@@ -30,6 +29,7 @@ import com.lambda.interaction.managers.inventory.InventoryManager.actions
3029
import com.lambda.interaction.managers.inventory.InventoryManager.activeRequest
3130
import com.lambda.interaction.managers.inventory.InventoryManager.alteredSlots
3231
import com.lambda.interaction.managers.inventory.InventoryManager.processActiveRequest
32+
import com.lambda.module.modules.client.Client
3333
import com.lambda.threading.runSafe
3434
import com.lambda.util.collections.LimitedDecayQueue
3535
import com.lambda.util.item.ItemStackUtils.equal
@@ -55,8 +55,8 @@ object InventoryManager : Manager<InventoryRequest>(
5555
private var actions = mutableListOf<InventoryAction>()
5656

5757
private var slots = listOf<ItemStack>()
58-
private var alteredSlots = LimitedDecayQueue<InventoryChange>(Int.MAX_VALUE, DEFAULT.desyncTimeout * 50L)
59-
private var alteredPlayerSlots = LimitedDecayQueue<InventoryChange>(Int.MAX_VALUE, DEFAULT.desyncTimeout * 50L)
58+
private var alteredSlots = LimitedDecayQueue<InventoryChange>(Int.MAX_VALUE, Client.desyncTimeout * 50L)
59+
private var alteredPlayerSlots = LimitedDecayQueue<InventoryChange>(Int.MAX_VALUE, Client.desyncTimeout * 50L)
6060

6161
var screenHandler: ScreenHandler? = null
6262
set(value) {
@@ -76,7 +76,7 @@ object InventoryManager : Manager<InventoryRequest>(
7676
super.load()
7777

7878
listen<TickEvent.Post>({ Int.MIN_VALUE }) {
79-
if (DEFAULT.avoidDesync) indexInventoryChanges()
79+
if (Client.avoidInventoryDesync) indexInventoryChanges()
8080
if (++secondCounter >= 20) {
8181
secondCounter = 0
8282
actionsThisSecond = 0
@@ -126,8 +126,8 @@ object InventoryManager : Manager<InventoryRequest>(
126126
activeRequest = request
127127
actions = request.actions.toMutableList()
128128
maxActionsThisSecond = request.inventoryConfig.actionsPerSecond
129-
alteredSlots.setDecayTime(DEFAULT.desyncTimeout * 50L)
130-
alteredPlayerSlots.setDecayTime(DEFAULT.desyncTimeout * 50L)
129+
alteredSlots.setDecayTime(Client.desyncTimeout * 50L)
130+
alteredPlayerSlots.setDecayTime(Client.desyncTimeout * 50L)
131131
}
132132

133133
/**
@@ -145,7 +145,7 @@ object InventoryManager : Manager<InventoryRequest>(
145145
break
146146
action.action(this)
147147
if (action is InventoryAction.Player) PacketLimitHandler.sentPackets(1, PacketType.PlayerAction)
148-
if (DEFAULT.avoidDesync) indexInventoryChanges()
148+
if (Client.avoidInventoryDesync) indexInventoryChanges()
149149
actionsThisTick++
150150
if (action is InventoryAction.Inventory) actionsThisSecond++
151151
iterator.remove()
@@ -188,7 +188,7 @@ object InventoryManager : Manager<InventoryRequest>(
188188
@JvmStatic
189189
fun onInventoryUpdate(packet: InventoryS2CPacket, original: Operation<Void>){
190190
runSafe {
191-
if (!mc.isOnThread || !DEFAULT.avoidDesync) {
191+
if (!mc.isOnThread || !Client.avoidInventoryDesync) {
192192
original.call(packet)
193193
return
194194
}
@@ -221,7 +221,7 @@ object InventoryManager : Manager<InventoryRequest>(
221221
@JvmStatic
222222
fun onSlotUpdate(packet: ScreenHandlerSlotUpdateS2CPacket, original: Operation<Void>) {
223223
runSafe {
224-
if (!mc.isOnThread || !DEFAULT.avoidDesync) {
224+
if (!mc.isOnThread || !Client.avoidInventoryDesync) {
225225
original.call(packet)
226226
return
227227
}

src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package com.lambda.interaction.managers.rotating.visibilty
1919

20-
import com.lambda.config.AutomationConfig.Companion.DEFAULT
2120
import com.lambda.context.Automated
2221
import com.lambda.context.AutomatedSafeContext
2322
import com.lambda.interaction.construction.simulation.processing.PreProcessingData
@@ -26,6 +25,7 @@ import com.lambda.interaction.construction.verify.SurfaceScan
2625
import com.lambda.interaction.managers.rotating.Rotation
2726
import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo
2827
import com.lambda.interaction.managers.rotating.RotationManager
28+
import com.lambda.module.modules.client.Client
2929
import com.lambda.util.BlockUtils.blockState
3030
import com.lambda.util.extension.component6
3131
import com.lambda.util.math.distSq
@@ -157,7 +157,7 @@ object VisibilityChecker {
157157
val (scanBox, invalidSides) = getScanBox(preProcessing, allowInsideBox) ?: return
158158
(visibleSides - invalidSides).forEach { side ->
159159
val (minX, minY, minZ, maxX, maxY, maxZ) = scanBox
160-
.offset(side.doubleVector.multiply(DEFAULT.shrinkFactor))
160+
.offset(side.doubleVector.multiply(Client.scanShrinkFactor))
161161
.bounds(side)
162162

163163
val stepX = (maxX - minX) / resolution
@@ -190,31 +190,31 @@ object VisibilityChecker {
190190
val pos = when (side) {
191191
Direction.DOWN -> Vec3d(
192192
pov.x.coerceIn(minX, maxX),
193-
minY + DEFAULT.shrinkFactor,
193+
minY + Client.scanShrinkFactor,
194194
pov.z.coerceIn(minZ, maxZ)
195195
)
196196
Direction.UP -> Vec3d(
197197
pov.x.coerceIn(minX, maxX),
198-
maxY + DEFAULT.shrinkFactor,
198+
maxY + Client.scanShrinkFactor,
199199
pov.z.coerceIn(minZ, maxZ)
200200
)
201201
Direction.NORTH -> Vec3d(
202202
pov.x.coerceIn(minX, maxX),
203203
pov.y.coerceIn(minY, maxY),
204-
minZ + DEFAULT.shrinkFactor
204+
minZ + Client.scanShrinkFactor
205205
)
206206
Direction.SOUTH -> Vec3d(
207207
pov.x.coerceIn(minX, maxX),
208208
pov.y.coerceIn(minY, maxY),
209-
maxZ + DEFAULT.shrinkFactor
209+
maxZ + Client.scanShrinkFactor
210210
)
211211
Direction.WEST -> Vec3d(
212-
minX + DEFAULT.shrinkFactor,
212+
minX + Client.scanShrinkFactor,
213213
pov.y.coerceIn(minY, maxY),
214214
pov.z.coerceIn(minZ, maxZ)
215215
)
216216
Direction.EAST -> Vec3d(
217-
maxX + DEFAULT.shrinkFactor,
217+
maxX + Client.scanShrinkFactor,
218218
pov.y.coerceIn(minY, maxY),
219219
pov.z.coerceIn(minZ, maxZ)
220220
)
@@ -240,7 +240,7 @@ object VisibilityChecker {
240240
preProcessing: PreProcessingData?,
241241
allowInsideBox: Boolean
242242
): Pair<Box, Set<Direction>>? =
243-
with(contract(DEFAULT.shrinkFactor)) {
243+
with(contract(Client.scanShrinkFactor)) {
244244
if (preProcessing == null || preProcessing.info.surfaceScan.mode == ScanMode.Full) return Pair(this, emptySet())
245245

246246
val (newXBounds, shrunkXSide) = toScanRange(minX, maxX, preProcessing.pos.x, Direction.Axis.X, preProcessing.info.surfaceScan)

src/main/kotlin/com/lambda/module/Module.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.lambda.event.listener.Listener
3737
import com.lambda.event.listener.SafeListener
3838
import com.lambda.event.listener.SafeListener.Companion.listen
3939
import com.lambda.event.listener.UnsafeListener
40+
import com.lambda.module.modules.client.Client
4041
import com.lambda.module.tag.ModuleTag
4142
import com.lambda.sound.LambdaSound
4243
import com.lambda.sound.SoundManager.play
@@ -150,11 +151,8 @@ abstract class Module(
150151
get() = !isEnabled && !alwaysListening
151152

152153
init {
153-
onEnable { LambdaSound.ModuleOn.play() }
154-
onDisable { LambdaSound.ModuleOff.play() }
155-
156-
onEnableUnsafe { LambdaSound.ModuleOn.play() }
157-
onDisableUnsafe { LambdaSound.ModuleOff.play() }
154+
onEnableUnsafe { if (Client.clientSounds) LambdaSound.ModuleOn.play() }
155+
onDisableUnsafe { if (Client.clientSounds) LambdaSound.ModuleOff.play() }
158156

159157
listen<ClientEvent.Shutdown> { if (autoDisable) disable() }
160158
listen<ClientEvent.Startup> { if (autoDisable) disable() }
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2026 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.client
19+
20+
import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer
21+
import com.lambda.interaction.construction.simulation.result.Drawable
22+
import com.lambda.module.Module
23+
import com.lambda.module.tag.ModuleTag
24+
import com.lambda.util.NamedEnum
25+
26+
object Client : Module(
27+
name = "Client",
28+
description = "Global settings for Lambda",
29+
tag = ModuleTag.CLIENT
30+
) {
31+
private enum class Group(override val displayName: String) : NamedEnum {
32+
General("General"),
33+
Debug("Debug")
34+
}
35+
36+
val clientSounds by setting("Client Sounds", true, "Plays sounds when certain actions are performed with lambda. Toggling modules, for example").group(Group.General)
37+
val buildTaskRenders by setting("Build Task Renders", false, "Displays renders from some build sim results generated from the build task").group(Group.General)
38+
val avoidInventoryDesync by setting("Avoid Inventory Desync", true, "Cancels incoming inventory update packets if they match previous actions").group(Group.General)
39+
val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidInventoryDesync }.group(Group.General)
40+
val scanShrinkFactor by setting("Scan Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.General)
41+
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug)
42+
val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug)
43+
val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs").group(Group.Debug)
44+
45+
@Volatile
46+
var drawables = listOf<Drawable>()
47+
48+
init {
49+
tickedRenderer("Client Ticked Renderer") {
50+
if (buildTaskRenders) drawables.forEach { with(it) { render() } }
51+
}
52+
}
53+
}

src/main/kotlin/com/lambda/module/modules/render/Search.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ object Search : Module(
103103

104104
private val tracerBlockPositions = ConcurrentMap<BlockPos, Pair<Vec3d, Pair<Color, Color>>>()
105105

106-
val chunkedRenderer = chunkedRenderer("Chunked Search") { world, position ->
106+
val chunkedRenderer = chunkedRenderer("Search Chunked Renderer") { world, position ->
107107
runSafe {
108108
val pos = position.toBlockPos()
109109
val state = world.getBlockState(pos)
@@ -143,7 +143,7 @@ object Search : Module(
143143
}
144144

145145
init {
146-
immediateRenderer("Immediate Search") { safeContext ->
146+
immediateRenderer("Search Immediate Renderer") { safeContext ->
147147
safeContext.world.entities.forEach { entity ->
148148
if (entity.entityGroup.nameToDisplayNameMap[entity::class.simpleName] in entities) {
149149
val entityColor = getEntityColor(entity)

src/main/kotlin/com/lambda/task/Task.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
package com.lambda.task
1919

2020
import com.lambda.Lambda.LOG
21-
import com.lambda.config.AutomationConfig.Companion.DEFAULT
22-
import com.lambda.config.AutomationConfig.Companion.DEFAULT.verboseDebug
21+
import com.lambda.module.modules.client.Client.verboseDebug
2322
import com.lambda.context.SafeContext
2423
import com.lambda.event.EventFlow.unsubscribe
2524
import com.lambda.event.Muteable
2625
import com.lambda.event.events.TickEvent
2726
import com.lambda.event.listener.SafeListener.Companion.listen
27+
import com.lambda.module.modules.client.Client
2828
import com.lambda.threading.runSafe
2929
import com.lambda.util.Communication.logError
3030
import com.lambda.util.Nameable
@@ -134,7 +134,7 @@ abstract class Task<Result> : Nameable, Muteable {
134134
fun success(result: Result) {
135135
unsubscribe()
136136
state = State.Completed
137-
if (!DEFAULT.showAllEntries) parent?.subTasks?.remove(this)
137+
if (!Client.showAllEntries) parent?.subTasks?.remove(this)
138138
runSafe { executeNextTask(result) }
139139
}
140140

0 commit comments

Comments
 (0)