Skip to content

Commit 7b9e7c0

Browse files
committed
Merge branch '1.21.5' into settings/custom-settings
# Conflicts: # src/main/kotlin/com/lambda/interaction/construction/context/InteractionContext.kt # src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt
2 parents dcb8f71 + 5533bd2 commit 7b9e7c0

File tree

12 files changed

+109
-26
lines changed

12 files changed

+109
-26
lines changed

src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
import com.lambda.event.events.InventoryEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.gui.DearImGui;
26+
import com.lambda.gui.components.ClickGuiLayout;
2627
import com.lambda.module.modules.player.Interact;
2728
import com.lambda.module.modules.player.InventoryMove;
2829
import com.lambda.module.modules.player.PacketMine;
30+
import com.lambda.util.WindowUtils;
2931
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
3032
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
3133
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
@@ -196,4 +198,11 @@ float getTargetMillisPerTick(float millis, Operation<Float> original) {
196198
else
197199
return (float) TimerManager.INSTANCE.getLength();
198200
}
201+
202+
@Inject(method = "updateWindowTitle", at = @At("HEAD"), cancellable = true)
203+
void updateWindowTitle(CallbackInfo ci) {
204+
if (!ClickGuiLayout.getSetLambdaWindowTitle()) return;
205+
WindowUtils.setLambdaTitle();
206+
ci.cancel();
207+
}
199208
}

src/main/kotlin/com/lambda/Lambda.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.lambda.event.events.ClientEvent
3131
import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe
3232
import com.lambda.gui.components.ClickGuiLayout
3333
import com.lambda.util.KeyCode
34-
import com.lambda.util.WindowIcons.setLambdaWindowIcon
34+
import com.lambda.util.WindowUtils.setLambdaWindowIcon
3535
import com.mojang.authlib.GameProfile
3636
import net.fabricmc.api.ClientModInitializer
3737
import net.fabricmc.loader.api.FabricLoader

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import com.lambda.sound.SoundManager.play
3737
import com.lambda.util.Describable
3838
import com.lambda.util.KeyCode
3939
import com.lambda.util.NamedEnum
40-
import com.lambda.util.WindowIcons.setLambdaWindowIcon
40+
import com.lambda.util.WindowUtils.setLambdaTitle
41+
import com.lambda.util.WindowUtils.setLambdaWindowIcon
4142
import imgui.ImGui
4243
import imgui.extension.implot.ImPlot
4344
import imgui.flag.ImGuiCol
@@ -90,7 +91,8 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
9091
mc.window.setIcon(mc.defaultResourcePack, icon)
9192
}
9293
}
93-
val setLambdaWindowTitle by setting("Set Lambda Window Title", true).group(Group.General)
94+
@JvmStatic val setLambdaWindowTitle by setting("Set Lambda Window Title", true).onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General)
95+
val lambdaTitleAppendixName by setting("Append Username", true) { setLambdaWindowTitle }.onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General)
9496

9597
// Sizing
9698
val windowPaddingX by setting("Window Padding X", 8.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing)

src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt

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

1818
package com.lambda.interaction.construction.context
1919

20+
import com.lambda.context.Automated
2021
import com.lambda.graphics.renderer.esp.DirectionMask
2122
import com.lambda.graphics.renderer.esp.DirectionMask.exclude
2223
import com.lambda.graphics.renderer.esp.ShapeBuilder
@@ -27,12 +28,16 @@ import com.lambda.interaction.request.LogContext.Companion.getLogContextBuilder
2728
import com.lambda.interaction.request.breaking.BreakConfig
2829
import com.lambda.interaction.request.hotbar.HotbarManager
2930
import com.lambda.interaction.request.rotating.RotationRequest
31+
import com.lambda.threading.runSafe
3032
import com.lambda.util.BlockUtils.emptyState
33+
import net.minecraft.block.Block
3134
import net.minecraft.block.BlockState
3235
import net.minecraft.block.FallingBlock
3336
import net.minecraft.util.hit.BlockHitResult
3437
import net.minecraft.util.math.BlockPos
38+
import net.minecraft.util.math.Vec3d
3539
import java.awt.Color
40+
import kotlin.math.sqrt
3641
import kotlin.random.Random
3742

3843
data class BreakContext(
@@ -42,8 +47,9 @@ data class BreakContext(
4247
var itemSelection: StackSelection,
4348
var instantBreak: Boolean,
4449
override var cachedState: BlockState,
45-
val sortMode: BreakConfig.SortMode
46-
) : BuildContext(), LogContext {
50+
val sortMode: BreakConfig.SortMode,
51+
private val automated: Automated
52+
) : BuildContext(), LogContext, Automated by automated {
4753
private val baseColor = Color(222, 0, 0, 25)
4854
private val sideColor = Color(222, 0, 0, 100)
4955

@@ -52,28 +58,37 @@ data class BreakContext(
5258

5359
val random = Random.nextDouble()
5460

55-
override fun compareTo(other: BuildContext): Int {
61+
override fun compareTo(other: BuildContext): Int = runSafe {
5662
return when (other) {
57-
is BreakContext -> compareBy<BreakContext> {
63+
is BreakContext -> compareByDescending<BreakContext> {
64+
if (sortMode == BreakConfig.SortMode.Tool) it.hotbarIndex == HotbarManager.serverSlot
65+
else 0
66+
}.thenBy {
5867
when (sortMode) {
59-
BreakConfig.SortMode.Closest -> it.distance
60-
BreakConfig.SortMode.Farthest -> -it.distance
61-
BreakConfig.SortMode.Tool -> it.hotbarIndex != HotbarManager.serverSlot
68+
BreakConfig.SortMode.Tool,
69+
BreakConfig.SortMode.Closest -> player.eyePos.distance(it.result.pos, it.cachedState.block)
70+
BreakConfig.SortMode.Farthest -> -player.eyePos.distance(it.result.pos, it.cachedState.block)
6271
BreakConfig.SortMode.Rotation -> it.rotation.target.angleDistance
6372
BreakConfig.SortMode.Random -> it.random
6473
}
65-
}.thenBy {
66-
it.distance
67-
}.thenBy {
68-
it.instantBreak
6974
}.thenByDescending {
70-
if (it.cachedState.block is FallingBlock) it.blockPos.y else 0
71-
}.thenBy {
7275
it.hotbarIndex == HotbarManager.serverSlot
73-
}.compare(this, other)
76+
}.thenBy {
77+
it.instantBreak
78+
}.compare(this@BreakContext, other)
7479

7580
else -> 1
7681
}
82+
} ?: 0
83+
84+
private fun Vec3d.distance(vec: Vec3d, block: Block): Double {
85+
val d = vec.x - x
86+
val e = (vec.y - y).let {
87+
if (block is FallingBlock) it - (interactionConfig.attackReach / 2)
88+
else it
89+
}
90+
val f = vec.z - z
91+
return sqrt(d * d + e * e + f * f)
7792
}
7893

7994
override fun ShapeBuilder.buildRenderer() {

src/main/kotlin/com/lambda/interaction/construction/context/BuildContext.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
package com.lambda.interaction.construction.context
1919

20+
import com.lambda.context.Automated
2021
import com.lambda.interaction.construction.result.Drawable
2122
import com.lambda.interaction.request.rotating.RotationRequest
2223
import com.lambda.threading.runSafe
2324
import net.minecraft.block.BlockState
2425
import net.minecraft.util.hit.BlockHitResult
2526
import net.minecraft.util.math.BlockPos
2627

27-
abstract class BuildContext : Comparable<BuildContext>, Drawable {
28+
abstract class BuildContext : Comparable<BuildContext>, Drawable, Automated {
2829
abstract val result: BlockHitResult
2930
abstract val rotation: RotationRequest
3031
abstract val hotbarIndex: Int

src/main/kotlin/com/lambda/interaction/construction/context/InteractionContext.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package com.lambda.interaction.construction.context
1919

20+
import com.lambda.context.Automated
21+
import com.lambda.context.interactConfig
2022
import com.lambda.graphics.renderer.esp.DirectionMask.mask
2123
import com.lambda.graphics.renderer.esp.ShapeBuilder
2224
import com.lambda.interaction.request.LogContext
@@ -39,7 +41,8 @@ class InteractionContext(
3941
override var hotbarIndex: Int,
4042
override var cachedState: BlockState,
4143
override val expectedState: BlockState,
42-
) : BuildContext(), LogContext {
44+
val automated: Automated
45+
) : BuildContext(), LogContext, Automated by automated {
4346
private val baseColor = Color(35, 254, 79, 25)
4447
private val sideColor = Color(35, 254, 79, 100)
4548

src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ object BuildSimulator {
276276
RotationRequest(rotationTarget, this),
277277
player.inventory.selectedSlot,
278278
state,
279-
expectedState
279+
expectedState,
280+
this
280281
)
281282

282283
val stackSelection = (item ?: player.mainHandStack.item).select()
@@ -746,7 +747,8 @@ object BuildSimulator {
746747
StackSelection.EVERYTHING.select(),
747748
instantBreakable(state, pos, breakConfig.breakThreshold),
748749
state,
749-
breakConfig.sorter
750+
breakConfig.sorter,
751+
this
750752
)
751753
acc.add(BreakResult.Break(pos, breakContext))
752754
return acc
@@ -803,7 +805,8 @@ object BuildSimulator {
803805
StackSelection.EVERYTHING.select(),
804806
instant,
805807
state,
806-
breakConfig.sorter
808+
breakConfig.sorter,
809+
this
807810
)
808811

809812
if (gamemode.isCreative) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ object BreakManager : RequestHandler<BreakRequest>(
145145
private var activeRequest: BreakRequest? = null
146146

147147
private var hotbarRequest: HotbarRequest? = null
148-
val swapped get() = hotbarRequest?.done != false
148+
private val swapped get() = hotbarRequest?.done != false
149149

150150
private var rotationRequest: RotationRequest? = null
151151
private val rotated get() = rotationRequest?.done != false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.hud
19+
20+
import com.lambda.gui.dsl.ImGuiBuilder
21+
import com.lambda.module.HudModule
22+
import com.lambda.module.tag.ModuleTag
23+
import com.lambda.threading.runSafe
24+
25+
object AccountName : HudModule(
26+
name = "AccountName",
27+
description = "Displays the current accounts name",
28+
tag = ModuleTag.HUD
29+
) {
30+
override fun ImGuiBuilder.buildLayout() {
31+
runSafe { text(player.name.string) }
32+
}
33+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.lambda.util.NamedEnum
2525

2626
@Suppress("Unused")
2727
object ManagerDebugLoggers : HudModule(
28-
"Manager Debug Loggers",
28+
"ManagerDebugLoggers",
2929
"debug loggers for all action managers in lambda",
3030
ModuleTag.HUD,
3131
customWindow = true

0 commit comments

Comments
 (0)