From 011fecf34294de9ad14c899ee37d8cfb772ebc58 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:43:29 +0100 Subject: [PATCH 1/4] Add button to BlockPosSetting to set coordinates to the current block under the cursor --- src/main/kotlin/com/lambda/config/Setting.kt | 6 +-- .../settings/complex/BlockPosSetting.kt | 49 +++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index eef00628e..03a2dfa93 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -230,13 +230,13 @@ class Setting, R>( buttonMenu = menu } - fun trySetValue(newValue: R) { + fun trySetValue(newValue: R, logResponse: Boolean = true) { if (newValue == value) { - ConfigCommand.info(notChangedMessage()) + if (logResponse) ConfigCommand.info(notChangedMessage()) } else { val previous = value value = newValue - ConfigCommand.info(setMessage(previous, newValue)) + if (logResponse) ConfigCommand.info(setMessage(previous, newValue)) } } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 907b74d96..9b41661d5 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -22,11 +22,15 @@ import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.command.commands.ConfigCommand import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockPos +import com.lambda.util.Communication.info import com.lambda.util.extension.CommandBuilder +import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.BlockPos @@ -38,21 +42,36 @@ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( TypeToken.get(BlockPos::class.java).type ) { context(setting: Setting<*, BlockPos>) - override fun ImGuiBuilder.buildLayout() { - inputVec3i(setting.name, value) { value = it.blockPos } - lambdaTooltip(setting.description) - } + override fun ImGuiBuilder.buildLayout() { + treeNode("Coordinates", id = setting.name) { + inputVec3i(setting.name, value) { value = it.blockPos } + } + lambdaTooltip(setting.description) + sameLine() + button("Set") { + runSafe { + mc.crosshairTarget?.blockResult?.blockPos?.let { + setting.trySetValue(it, logResponse = false) + ConfigCommand.info("Coordinates updated") + } ?: let { + info("No block under cursor") + return@runSafe + } + } + } + lambdaTooltip("Set the coordinates to the block you are currently looking at") + } context(setting: Setting<*, BlockPos>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(integer("X", -30000000, 30000000)) { x -> - required(integer("Y", -64, 255)) { y -> - required(integer("Z", -30000000, 30000000)) { z -> - execute { - setting.trySetValue(BlockPos(x().value(), y().value(), z().value())) - } - } - } - } - } + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(integer("X", -30000000, 30000000)) { x -> + required(integer("Y", -64, 255)) { y -> + required(integer("Z", -30000000, 30000000)) { z -> + execute { + setting.trySetValue(BlockPos(x().value(), y().value(), z().value())) + } + } + } + } + } } From 3881d2b4c54880ef76b5a3a3be91d19e05e978a0 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:33:07 +0100 Subject: [PATCH 2/4] Code cleanup --- .../config/settings/complex/BlockPosSetting.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 9b41661d5..28bb66f7e 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -26,11 +26,11 @@ import com.lambda.command.commands.ConfigCommand import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockPos import com.lambda.util.Communication.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.world.raycast.RayCastUtils.blockResult +import net.minecraft.client.MinecraftClient import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.BlockPos @@ -43,21 +43,16 @@ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( ) { context(setting: Setting<*, BlockPos>) override fun ImGuiBuilder.buildLayout() { - treeNode("Coordinates", id = setting.name) { + treeNode(setting.name, id = setting.name) { inputVec3i(setting.name, value) { value = it.blockPos } } lambdaTooltip(setting.description) sameLine() button("Set") { - runSafe { - mc.crosshairTarget?.blockResult?.blockPos?.let { - setting.trySetValue(it, logResponse = false) - ConfigCommand.info("Coordinates updated") - } ?: let { - info("No block under cursor") - return@runSafe - } - } + MinecraftClient.getInstance().crosshairTarget?.blockResult?.blockPos?.let { + setting.trySetValue(it, logResponse = false) + ConfigCommand.info("Coordinates updated") + } ?: info("No block under crosshair") } lambdaTooltip("Set the coordinates to the block you are currently looking at") } From af6703f08c437823b5f552217e2f50ebbc87ef84 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Fri, 13 Mar 2026 21:02:38 +0100 Subject: [PATCH 3/4] Move BlockPosSetting 'Set' button infront of the TreeNode element to prevent visual overlap. --- .../config/settings/complex/BlockPosSetting.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 28bb66f7e..362d7d600 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -22,7 +22,6 @@ import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.command.commands.ConfigCommand import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -43,18 +42,18 @@ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( ) { context(setting: Setting<*, BlockPos>) override fun ImGuiBuilder.buildLayout() { - treeNode(setting.name, id = setting.name) { - inputVec3i(setting.name, value) { value = it.blockPos } - } - lambdaTooltip(setting.description) - sameLine() button("Set") { MinecraftClient.getInstance().crosshairTarget?.blockResult?.blockPos?.let { setting.trySetValue(it, logResponse = false) - ConfigCommand.info("Coordinates updated") + setting.info("Coordinates updated") } ?: info("No block under crosshair") } lambdaTooltip("Set the coordinates to the block you are currently looking at") + sameLine() + treeNode(setting.name, id = setting.name) { + inputVec3i(setting.name, value) { value = it.blockPos } + } + lambdaTooltip(setting.description) } context(setting: Setting<*, BlockPos>) From c814a7da4afa33e1126be67e0c58adcf70b38da9 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:16:01 +0100 Subject: [PATCH 4/4] Remove duplicate setting name for BlockPosSetting inside TreeNode --- .../com/lambda/config/settings/complex/BlockPosSetting.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 362d7d600..0abe82b41 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -51,7 +51,7 @@ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( lambdaTooltip("Set the coordinates to the block you are currently looking at") sameLine() treeNode(setting.name, id = setting.name) { - inputVec3i(setting.name, value) { value = it.blockPos } + inputVec3i("##${setting.name}", value) { value = it.blockPos } } lambdaTooltip(setting.description) }