Skip to content

Commit 1aa30e2

Browse files
committed
Fixed some stuff
1 parent f424726 commit 1aa30e2

File tree

8 files changed

+23
-14
lines changed

8 files changed

+23
-14
lines changed

src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.lambda.util.Communication.info
3333
import com.lambda.util.Communication.joinToText
3434
import com.lambda.util.Communication.warn
3535
import com.lambda.util.StringUtils
36+
import com.lambda.util.StringUtils.findSimilarStrings
3637
import com.lambda.util.extension.CommandBuilder
3738
import com.lambda.util.text.ClickEvents.suggestCommand
3839
import com.lambda.util.text.buildText
@@ -93,8 +94,7 @@ object ModuleCommand : LambdaCommand(
9394
}
9495
literal("not found!")
9596
}
96-
val similarModules = StringUtils.findSimilarStrings(
97-
name,
97+
val similarModules = name.findSimilarStrings(
9898
ModuleRegistry.moduleNames,
9999
3
100100
)

src/main/kotlin/com/lambda/event/events/KeyboardEvent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ sealed class KeyboardEvent {
4040
val action: Int,
4141
val modifiers: Int,
4242
) : Event {
43-
/**
44-
* Maps the scancode to the US layout
45-
*/
43+
val bind: Bind
44+
get() = Bind(keyCode, modifiers, -1)
45+
4646
val translated: KeyCode
4747
get() = KeyCode.virtualMapUS(keyCode, scanCode)
4848

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
220220
listen<KeyboardEvent.Press>(alwaysListen = true) { event ->
221221
if (!event.isPressed) return@listen
222222
if (mc.options.commandKey.isPressed) return@listen
223-
if (keybind == KeyCode.Unbound) return@listen
224-
if (event.translated != keybind) return@listen
223+
if (!event.satisfies(keybind)) return@listen
225224
if (!open && mc.currentScreen != null) return@listen
226225
if (open && DearImGui.io.wantTextInput) return@listen
227226

src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ object StateInfo : Module(
4242

4343
init {
4444
listen<KeyboardEvent.Press> { event ->
45-
if (!event.isPressed) return@listen
46-
if (event.keyCode != printBind.code) return@listen
45+
if (!event.isPressed ||
46+
!event.satisfies(printBind)) return@listen
47+
4748
val crosshair = mc.crosshairTarget ?: return@listen
4849
if (crosshair !is BlockHitResult) return@listen
4950
info(blockState(crosshair.blockPos).betterToString())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ object Replay : Module(
134134
if (!it.isPressed) return@listen
135135
if (mc.currentScreen != null && !mc.options.commandKey.isPressed) return@listen
136136

137-
when (it.translated) {
137+
when (it.bind) {
138138
record -> handleRecord()
139139
play -> handlePlay()
140140
cycle -> handlePlayModeCycle()

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.lambda.config.groups.BuildSettings
2121
import com.lambda.config.groups.HotbarSettings
2222
import com.lambda.config.groups.InventorySettings
2323
import com.lambda.config.groups.RotationSettings
24+
import com.lambda.config.settings.complex.Bind
2425
import com.lambda.context.SafeContext
2526
import com.lambda.event.events.MovementEvent
2627
import com.lambda.event.events.TickEvent
@@ -60,7 +61,7 @@ object Scaffold : Module(
6061
private val bridgeRange by setting("Bridge Range", 5, 0..5, 1, "The range at which blocks can be placed to help build support for the player", unit = " blocks").group(Group.General)
6162
private val onlyBelow by setting("Only Below", true, "Restricts bridging to only below the player to avoid place spam if it's impossible to reach the supporting position") { bridgeRange > 0 }.group(Group.General)
6263
private val descend by setting("Descend", KeyCode.Unbound, "Lower the place position by one to allow the player to lower y level").group(Group.General)
63-
private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != KeyCode.Unbound }.group(Group.General)
64+
private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != Bind.Empty }.group(Group.General)
6465
override val buildConfig = BuildSettings(this, Group.Build).apply {
6566
editTyped(::pathing, ::stayInRange, ::collectDrops) {
6667
defaultValue(false)
@@ -88,7 +89,7 @@ object Scaffold : Module(
8889
val playerSupport = player.blockPos.down()
8990
val alreadySupported = blockState(playerSupport).hasSolidTopSurface(world, playerSupport, player)
9091
if (alreadySupported) return@listen
91-
val offset = if (isKeyPressed(descend.code)) descendAmount else 0
92+
val offset = if (isKeyPressed(descend.key)) descendAmount else 0
9293
val beneath = playerSupport.down(offset)
9394
runSafeAutomated {
9495
scaffoldPositions(beneath)
@@ -108,7 +109,7 @@ object Scaffold : Module(
108109
}
109110

110111
listen<MovementEvent.Sneak> {
111-
if (descend.code != mc.options.sneakKey.boundKey.code) return@listen
112+
if (descend.key != mc.options.sneakKey.boundKey.code) return@listen
112113
it.sneak = false
113114
}
114115
}

src/main/kotlin/com/lambda/util/math/Linear.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import java.awt.Color
2424
import kotlin.math.max
2525
import kotlin.math.min
2626
import kotlin.random.Random
27-
import kotlin.random.Random.Default.nextDouble
2827

2928
infix fun ClosedRange<Double>.step(step: Double) = object : DoubleIterator() {
3029
private var next = start
@@ -38,13 +37,17 @@ infix fun ClosedRange<Float>.step(step: Float) = object : FloatIterator() {
3837
override fun nextFloat() = next.also { next += step }
3938
}
4039

40+
@JvmName("randomDouble")
4141
fun ClosedRange<Double>.random(random: Random = Random) = start + (endInclusive - start) * random.nextDouble()
42+
@JvmName("randomFloat")
4243
fun ClosedRange<Float>.random(random: Random = Random) = start + (endInclusive - start) * random.nextDouble()
4344

4445
fun ClosedRange<Double>.normalize(value: Double): Double = transform(value, 0.0, 1.0)
4546
fun ClosedRange<Float>.normalize(value: Float): Float = transform(value, 0f, 1f)
4647

48+
@JvmName("invDouble")
4749
fun ClosedRange<Double>.inv() = endInclusive to start
50+
@JvmName("invFloat")
4851
fun ClosedRange<Float>.inv() = endInclusive to start
4952

5053
/**

src/main/kotlin/com/lambda/util/world/WorldUtils.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import kotlin.math.ceil
3434
import kotlin.sequences.filter
3535

3636
object WorldUtils {
37+
fun SafeContext.isLoaded(pos: BlockPos) =
38+
world.chunkManager.isChunkLoaded(
39+
ChunkSectionPos.getSectionCoord(pos.x), ChunkSectionPos.getSectionCoord(pos.z)
40+
)
41+
3742
/**
3843
* Returns a sequence of entities.
3944
*

0 commit comments

Comments
 (0)