Skip to content

Commit b629941

Browse files
committed
BreakInfo and SwapInfo toLogContext
1 parent 10df72d commit b629941

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ package com.lambda.interaction.request.breaking
1919

2020
import com.lambda.interaction.construction.context.BreakContext
2121
import com.lambda.interaction.request.ActionInfo
22+
import com.lambda.interaction.request.DebugLogger.LogEntry.Companion.toLogContext
23+
import com.lambda.interaction.request.LogContext
24+
import com.lambda.interaction.request.LogContext.Companion.buildLogContext
2225
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
2326
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak
2427
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary
@@ -39,7 +42,7 @@ data class BreakInfo(
3942
override var context: BreakContext,
4043
var type: BreakType,
4144
var request: BreakRequest
42-
) : ActionInfo {
45+
) : ActionInfo, LogContext {
4346
// Delegates
4447
val breakConfig get() = request.build.breaking
4548
override val pendingInteractionsList get() = request.pendingInteractions
@@ -148,5 +151,28 @@ data class BreakInfo(
148151
)
149152
}
150153

154+
override fun toLogContext() =
155+
buildLogContext {
156+
text("Break Info:")
157+
pushTab()
158+
text("Type: $type")
159+
text("Pos: ${context.blockPos.toLogContext()}")
160+
text("Details:")
161+
pushTab()
162+
text("Should Progress: $shouldProgress")
163+
text("Rebreak Potential: $rebreakPotential")
164+
text(swapInfo.toLogContext())
165+
text("Swap Stack: $swapStack")
166+
text("Updated This Tick: $updatedThisTick")
167+
text("Updated Pre-Processing This Tick: $updatedPreProcessingThisTick")
168+
text("Progressed This Tick: $progressedThisTick")
169+
text("Breaking: $breaking")
170+
text("Abandoned: $abandoned")
171+
text("Breaking Ticks: $breakingTicks")
172+
text("Sounds Cooldown: $soundsCooldown")
173+
text("Vanilla Instant Breakable: $vanillaInstantBreakable")
174+
text("Rebreakable: $rebreakable")
175+
}
176+
151177
override fun toString() = "$type, ${context.cachedState}, ${context.blockPos}"
152178
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package com.lambda.interaction.request.breaking
1919

2020
import com.lambda.Lambda.mc
21+
import com.lambda.interaction.request.LogContext
22+
import com.lambda.interaction.request.LogContext.Companion.buildLogContext
2123
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
2224
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak
2325
import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta
@@ -32,7 +34,7 @@ data class SwapInfo(
3234
private val breakConfig: BreakConfig = TaskFlowModule.build.breaking,
3335
val swap: Boolean = false,
3436
val minKeepTicks: Int = 0,
35-
) {
37+
) : LogContext {
3638
val validSwap
3739
get() = run {
3840
val serverSwapTicks = if (type == Primary || type == Rebreak) breakConfig.serverSwapTicks
@@ -41,6 +43,16 @@ data class SwapInfo(
4143
(mc.player?.mainHandStack?.heldTicks ?: return false) >= serverSwapTicks
4244
}
4345

46+
override fun toLogContext() =
47+
buildLogContext {
48+
text("Swap Info:")
49+
pushTab()
50+
text("Type: $type")
51+
text("Swap: $swap")
52+
text("Min Keep Ticks: $minKeepTicks")
53+
text("Valid Swap: $validSwap")
54+
}
55+
4456
companion object {
4557
val EMPTY = SwapInfo(Primary)
4658

0 commit comments

Comments
 (0)