Skip to content

Commit 98561c2

Browse files
committed
use updatableLazy
1 parent 232c217 commit 98561c2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.lambda.interaction.construction.context.BreakContext
2121
import com.lambda.interaction.request.ActionInfo
2222
import com.lambda.threading.runSafe
2323
import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
24+
import com.lambda.util.collections.updatableLazy
2425
import net.minecraft.client.network.ClientPlayerEntity
2526
import net.minecraft.client.network.ClientPlayerInteractionManager
2627
import net.minecraft.client.world.ClientWorld
@@ -42,7 +43,7 @@ data class BreakInfo(
4243
var progressedThisTick = false
4344
var serverBreakTicks = 0
4445

45-
var couldReBreak = lazy {
46+
var couldReBreak = updatableLazy {
4647
runSafe {
4748
ReBreakManager.couldReBreak(this@BreakInfo, player, world)
4849
} == true
@@ -107,7 +108,7 @@ data class BreakInfo(
107108
val breakProgress = breakDelta * ((breakingTicks + 1) - breakConfig.fudgeFactor).let {
108109
if (isSecondary) it + 1 else it
109110
}
110-
return if (couldReBreak.value)
111+
return if (couldReBreak.value == true)
111112
breakConfig.swapMode.isEnabled()
112113
else when (breakConfig.swapMode) {
113114
BreakConfig.SwapMode.None -> false

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ object BreakManager : RequestHandler<BreakRequest>(
297297
if (instantBreaks.isEmpty()) rotation.submit(false) else rotation
298298
}
299299
}
300+
.also {
301+
it.forEach { it.couldReBreak.update() }
302+
}
300303
.also {
301304
if (breakInfos.none { it?.shouldSwap(player, world) == true }) return@also
302305

@@ -329,7 +332,7 @@ object BreakManager : RequestHandler<BreakRequest>(
329332
if (tickStage !in info.breakConfig.breakStageMask) return@forEach
330333
if (!rotated && info.isPrimary) return@run
331334

332-
if (info.couldReBreak.value) when (val reBreakResult = ReBreakManager.handleUpdate(info.context, info.request)) {
335+
if (info.couldReBreak.value == true) when (val reBreakResult = ReBreakManager.handleUpdate(info.context, info.request)) {
333336
is ReBreakResult.StillBreaking -> {
334337
primaryBreak = reBreakResult.breakInfo.apply {
335338
type = Primary

0 commit comments

Comments
 (0)