Skip to content

Commit 3df3485

Browse files
committed
cleaned up some code
1 parent ad9b456 commit 3df3485

File tree

6 files changed

+32
-31
lines changed

6 files changed

+32
-31
lines changed

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,23 @@ object BreakManager : RequestHandler<BreakRequest>(
186186

187187
// Reversed so that the breaking order feels natural to the user as the primary break is always the
188188
// last break to be started
189-
run breakInfos@ {
189+
run {
190190
breakInfos
191191
.filterNotNull()
192192
.filter { !it.isRedundant }
193-
.also { infos ->
194-
rotationRequest = infos.firstOrNull { it.breakConfig.rotateForBreak }?.let { info ->
195-
val rotation = info.context.rotation
196-
if (instantBreaks.isEmpty()) info.request.rotation.request(rotation, false) else rotation
197-
}
193+
.also {
194+
rotationRequest = it.firstOrNull { it.breakConfig.rotateForBreak }
195+
?.let { info ->
196+
val rotation = info.context.rotation
197+
if (instantBreaks.isEmpty()) info.request.rotation.request(rotation, false) else rotation
198+
}
198199
}
199-
.reversed()
200+
.asReversed()
200201
.forEach { info ->
201-
if (info.updatedProgressThisTick) return@forEach
202-
if (!info.context.requestDependencies(request)) return@breakInfos
203-
if ((!rotated && info.isPrimary) || tickStage !in info.breakConfig.breakStageMask) return@breakInfos
202+
if (info.updatedProgressThisTick) return@run
203+
if (!info.context.requestDependencies(request)) return@run
204+
if ((!rotated && info.isPrimary) || tickStage !in info.breakConfig.breakStageMask) return@run
205+
204206
updateBreakProgress(info)
205207
}
206208
}
@@ -263,9 +265,10 @@ object BreakManager : RequestHandler<BreakRequest>(
263265
private fun SafeContext.canAccept(ctx: BreakContext): Boolean {
264266
if (pendingBreaks.any { it.context.expectedPos == ctx.expectedPos }) return false
265267

266-
breakInfos.firstOrNull { it != null && !it.isRedundant }
268+
breakInfos
269+
.firstOrNull { it != null && !it.isRedundant }
267270
?.let { info ->
268-
if ( ctx.hotbarIndex != info.context.hotbarIndex) return false
271+
if (ctx.hotbarIndex != info.context.hotbarIndex) return false
269272
}
270273

271274
return !blockState(ctx.expectedPos).isAir
@@ -641,4 +644,4 @@ object BreakManager : RequestHandler<BreakRequest>(
641644
}
642645

643646
override fun preEvent(): Event = UpdateManagerEvent.Break().post()
644-
}
647+
}

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakRequest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ data class BreakRequest(
4343
) : Request(prio, build.breaking) {
4444
override val done: Boolean
4545
get() = runSafe {
46-
contexts.all {
47-
ctx -> ctx.targetState.matches(blockState(ctx.expectedPos), ctx.expectedPos, world)
48-
}
46+
contexts.all { it.targetState.matches(blockState(it.expectedPos), it.expectedPos, world) }
4947
} == true
50-
}
48+
}

common/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.lambda.config.groups.TickStage
2121
import com.lambda.interaction.request.Priority
2222
import com.lambda.interaction.request.RequestConfig
2323

24-
/*
24+
/**
2525
* Abstract base class for configuring hotbar slot switch behavior.
2626
*
2727
* @param priority The priority of this configuration.
@@ -67,4 +67,4 @@ abstract class HotbarConfig(
6767
override fun requestInternal(request: HotbarRequest, queueIfClosed: Boolean) {
6868
HotbarManager.request(request, queueIfClosed)
6969
}
70-
}
70+
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/RotationConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.lambda.config.groups.TickStage
2121
import com.lambda.interaction.request.Priority
2222
import com.lambda.interaction.request.RequestConfig
2323

24-
/*
24+
/**
2525
* Abstract base class for configuring rotation behavior.
2626
*
2727
* @param priority The priority of this configuration.
@@ -68,4 +68,4 @@ abstract class RotationConfig(priority: Priority) : RequestConfig<RotationReques
6868
override val rotationStageMask = setOf(*TickStage.entries.toTypedArray())
6969
override val rotationMode = mode
7070
}
71-
}
71+
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/visibilty/PointSelection.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ package com.lambda.interaction.request.rotation.visibilty
2020
import com.lambda.interaction.request.rotation.Rotation.Companion.dist
2121
import com.lambda.interaction.request.rotation.RotationManager
2222
import com.lambda.util.math.distSq
23+
import com.lambda.util.math.times
2324

2425
enum class PointSelection(val select: (MutableList<VisibilityChecker.CheckedHit>) -> VisibilityChecker.CheckedHit?) {
2526
ByRotation({ hits ->
2627
hits.minByOrNull {
2728
RotationManager.activeRotation dist it.targetRotation
2829
}
2930
}),
30-
Optimum( optimum@ { hits ->
31+
Optimum({ hits ->
3132
val optimum = hits
32-
.map { it.hit.pos }.reduceOrNull { acc, vec3d ->
33-
acc?.let { it.add(vec3d) } ?: acc
34-
}
35-
?.multiply(1.0 / hits.size.toDouble()) ?: return@optimum null
33+
.map { it.hit.pos }
34+
.reduceOrNull { acc, pos -> acc.add(pos) }
35+
?.times(1 / hits.size)
3636

37-
hits.minByOrNull {
38-
it.hit.pos distSq optimum
37+
optimum?.let {
38+
hits.minByOrNull { it.hit.pos distSq optimum }
3939
}
4040
})
41-
}
41+
}

common/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import net.minecraft.util.math.BlockPos
4040
import java.util.concurrent.ConcurrentLinkedQueue
4141

4242
object PacketMine : Module(
43-
"Packet Mine",
43+
"PacketMine",
4444
"automatically breaks blocks, and does it faster",
4545
setOf(ModuleTag.PLAYER)
4646
) {
@@ -116,4 +116,4 @@ object PacketMine : Module(
116116
enum class Page {
117117
Build, Rotation, Interaction, Inventory, Hotbar
118118
}
119-
}
119+
}

0 commit comments

Comments
 (0)