Skip to content

Commit 8be2cc1

Browse files
authored
Merge branch '1.21.5' into feature/hud-settings
2 parents 0270a21 + 642f448 commit 8be2cc1

File tree

10 files changed

+28
-138
lines changed

10 files changed

+28
-138
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ open class AutomationConfig(
7979
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug)
8080
val shrinkFactor by setting("Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.Debug)
8181
val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug)
82+
val managerDebugLogs by setting("Manager Debug Logs", false, "Prints debug logs from managers into chat").group(Group.Debug)
8283

8384
@Volatile
8485
var drawables = listOf<Drawable>()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ object SettingsWidget {
3939
if (config is Module) {
4040
with(config.keybindSetting) { buildLayout() }
4141
with(config.disableOnReleaseSetting) { buildLayout() }
42+
with(config.drawSetting) { buildLayout() }
4243
}
4344
smallButton("Reset") {
4445
config.settings.forEach { it.reset(silent = true) }
@@ -75,7 +76,7 @@ object SettingsWidget {
7576
}
7677
val toIgnoreSettings =
7778
when (config) {
78-
is Module -> setOf(config.keybindSetting, config.disableOnReleaseSetting)
79+
is Module -> setOf(config.keybindSetting, config.disableOnReleaseSetting, config.drawSetting)
7980
is UserAutomationConfig -> setOf(config.linkedModules)
8081
else -> emptySet()
8182
}

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.lambda.interaction.construction.simulation.checks
1919

2020
import com.lambda.context.AutomatedSafeContext
21+
import com.lambda.interaction.construction.simulation.BreakSimInfo
2122
import com.lambda.interaction.construction.simulation.Results
2223
import com.lambda.interaction.construction.simulation.SimDsl
2324
import com.lambda.interaction.construction.simulation.SimInfo
@@ -47,7 +48,7 @@ object BasicChecker : Results<PreSimResult> {
4748
}
4849

4950
// block should be ignored
50-
if (state.block in breakConfig.ignoredBlocks && targetState.isEmpty()) {
51+
if (state.block in breakConfig.ignoredBlocks && this@hasBasicRequirements is BreakSimInfo) {
5152
result(GenericResult.Ignored(pos))
5253
return false
5354
}
@@ -70,7 +71,7 @@ object BasicChecker : Results<PreSimResult> {
7071
return false
7172
}
7273

73-
// block is unbreakable, so it cant be broken or replaced
74+
// block is unbreakable, so it can't be broken or replaced
7475
if (state.getHardness(world, pos) < 0 && !gamemode.isCreative) {
7576
result(PreSimResult.Unbreakable(pos, state))
7677
return false

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,9 @@ object BreakManager : Manager<BreakRequest>(
425425
private fun SafeContext.canAccept(newCtx: BreakContext): Boolean {
426426
if (activeInfos.none { it.context.blockPos == newCtx.blockPos } && isPosBlocked(newCtx.blockPos)) return false
427427

428-
val blockState = blockState(newCtx.blockPos)
429428
val hardness = newCtx.cachedState.getHardness(world, newCtx.blockPos)
430429

431-
return blockState.isNotEmpty && hardness != 600f && hardness != -1f
430+
return newCtx.cachedState.isNotEmpty && (hardness != -1f || player.isCreative)
432431
}
433432

434433
/**

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

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

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21+
import com.lambda.config.AutomationConfig.Companion.DEFAULT.managerDebugLogs
2122
import com.lambda.context.SafeContext
2223
import com.lambda.event.events.EntityEvent
2324
import com.lambda.event.events.WorldEvent
@@ -60,11 +61,11 @@ object BrokenBlockHandler : PostActionHandler<BreakInfo>() {
6061
if (!info.broken) {
6162
val message = "${info.type} ${info::class.simpleName} at ${info.context.blockPos.toShortString()} timed out with cached state ${info.context.cachedState}"
6263
BreakManager.logger.error(message)
63-
warn(message)
64+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
6465
} else if (!DEFAULT.ignoreItemDropWarnings) {
6566
val message = "${info.type} ${info::class.simpleName}'s item drop at ${info.context.blockPos.toShortString()} timed out"
66-
BreakManager.logger.warn(message)
67-
warn(message)
67+
BreakManager.logger.warning(message)
68+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
6869
}
6970

7071
if (!info.broken && info.breakConfig.breakConfirmation != BreakConfirmationMode.AwaitThenBreak) {
@@ -97,7 +98,7 @@ object BrokenBlockHandler : PostActionHandler<BreakInfo>() {
9798
} else {
9899
val message = "Broken block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.cachedState.emptyState}"
99100
BreakManager.logger.error(message)
100-
this@BrokenBlockHandler.warn(message)
101+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
101102
pending.stopPending()
102103
}
103104
return@listen

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

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

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21+
import com.lambda.config.AutomationConfig.Companion.DEFAULT.managerDebugLogs
2122
import com.lambda.event.events.WorldEvent
2223
import com.lambda.event.listener.SafeListener.Companion.listen
2324
import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry
2425
import com.lambda.interaction.managers.PostActionHandler
2526
import com.lambda.interaction.managers.interacting.InteractManager.placeSound
2627
import com.lambda.threading.runSafe
2728
import com.lambda.util.BlockUtils.matches
28-
import com.lambda.util.Communication.info
2929
import com.lambda.util.Communication.warn
3030
import com.lambda.util.collections.LimitedDecayQueue
3131

@@ -34,7 +34,7 @@ object InteractedBlockHandler : PostActionHandler<InteractInfo>() {
3434
DEFAULT.buildConfig.maxPendingActions,
3535
DEFAULT.buildConfig.actionTimeout * 50L
3636
) {
37-
info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out")
37+
if (managerDebugLogs) warn("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out")
3838
if (it.interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenPlace) {
3939
runSafe {
4040
world.setBlockState(it.context.blockPos, it.context.cachedState)
@@ -60,7 +60,7 @@ object InteractedBlockHandler : PostActionHandler<InteractInfo>() {
6060

6161
pending.stopPending()
6262

63-
this@InteractedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}")
63+
if (managerDebugLogs) this@InteractedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}")
6464
return@listen
6565
}
6666

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ abstract class Module(
124124
private val isEnabledSetting = setting("Enabled", enabledByDefault) { false }
125125
val keybindSetting = setting("Keybind", defaultKeybind) { false }
126126
val disableOnReleaseSetting = setting("Disable On Release", false) { false }
127-
128-
open val isVisible: Boolean = true
127+
val drawSetting = setting("Draw", true, "Draws the module in the module list hud element")
129128

130129
var isEnabled by isEnabledSetting
131130
val isDisabled get() = !isEnabled
132131

133132
val keybind by keybindSetting
134133
val disableOnRelease by disableOnReleaseSetting
134+
val draw by drawSetting
135135

136136
override val isMuted: Boolean
137137
get() = !isEnabled && !alwaysListening

src/main/kotlin/com/lambda/module/hud/ModuleList.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,32 @@ import com.lambda.gui.dsl.ImGuiBuilder
2121
import com.lambda.module.HudModule
2222
import com.lambda.module.ModuleRegistry
2323
import com.lambda.module.tag.ModuleTag
24-
import com.lambda.util.KeyCode
2524
import imgui.flag.ImGuiCol
2625
import java.awt.Color
2726

2827
object ModuleList : HudModule(
2928
name = "ModuleList",
3029
tag = ModuleTag.HUD,
3130
) {
31+
val onlyBound by setting("Only Bound", false, "Only displays modules with a keybind")
3232
val showKeybind by setting("Show Keybind", true, "Display keybind next to a module")
3333

34-
override val isVisible: Boolean
35-
get() = false
34+
init {
35+
drawSetting.value = false
36+
}
3637

3738
override fun ImGuiBuilder.buildLayout() {
38-
val enabled = ModuleRegistry.modules
39-
.filter { it.isEnabled }
40-
.filter { it.isVisible }
39+
val enabled = ModuleRegistry.modules.filter { it.isEnabled && it.draw }
4140

4241
enabled.forEach {
43-
text(it.name)
42+
val bound = it.keybind.key != 0 || it.keybind.mouse != -1
43+
if (onlyBound && !bound) return@forEach
44+
text(it.name);
4445

4546
if (showKeybind) {
46-
val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN
47+
val color = if (!bound) Color.RED else Color.GREEN
4748

48-
sameLine()
49+
sameLine()
4950
withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") }
5051
}
5152
}

src/main/kotlin/com/lambda/module/modules/movement/Pitch40.kt

Lines changed: 0 additions & 109 deletions
This file was deleted.

src/main/kotlin/com/lambda/module/modules/player/HighwayTools.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.lambda.module.modules.player
1919

2020
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
21-
import com.lambda.config.applyEdits
2221
import com.lambda.interaction.BaritoneManager
2322
import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure
2423
import com.lambda.interaction.construction.blueprint.PropagatingBlueprint.Companion.propagatingBlueprint
@@ -89,11 +88,7 @@ object HighwayTools : Module(
8988
}
9089

9190
init {
92-
setDefaultAutomationConfig {
93-
applyEdits {
94-
hideGroup(interactConfig)
95-
}
96-
}
91+
setDefaultAutomationConfig()
9792

9893
onEnable {
9994
octant = player.octant

0 commit comments

Comments
 (0)