Skip to content

Commit 7a102e9

Browse files
committed
move shouldProgress into its own variable for use in swap checks
1 parent 84f1513 commit 7a102e9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ data class BreakInfo(
4949
} == true
5050
}
5151

52+
var shouldProgress = false
5253
var breaking = false
5354
var abandoned = false
5455
var breakingTicks = 0
@@ -103,7 +104,7 @@ data class BreakInfo(
103104
}
104105

105106
fun shouldSwap(player: ClientPlayerEntity, world: WorldView): Boolean {
106-
if (BreakManager.tickStage !in breakConfig.breakStageMask) return false
107+
if (!shouldProgress) return false
107108
val item = player.inventory.getStack(context.hotbarIndex)
108109
val breakDelta = context.cachedState.calcItemBlockBreakingDelta(player, world, context.blockPos, item)
109110
val breakProgress = breakDelta * ((breakingTicks + 1) - breakConfig.fudgeFactor).let {

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ object BreakManager : RequestHandler<BreakRequest>(
299299
}
300300
}
301301
.also {
302-
it.forEach { it.couldReBreak.update() }
302+
it.forEach {
303+
it.couldReBreak.update()
304+
it.shouldProgress = !it.progressedThisTick &&
305+
tickStage in it.breakConfig.breakStageMask &&
306+
rotated || !it.isPrimary
307+
}
303308
}
304309
.also {
305310
if (breakInfos.none { it?.shouldSwap(player, world) == true }) return@also
@@ -329,10 +334,7 @@ object BreakManager : RequestHandler<BreakRequest>(
329334
}
330335
.asReversed()
331336
.forEach { info ->
332-
if (info.progressedThisTick) return@forEach
333-
if (tickStage !in info.breakConfig.breakStageMask) return@forEach
334-
if (!rotated && info.isPrimary) return@run
335-
337+
if (!info.shouldProgress) return@forEach
336338
updateBreakProgress(info)
337339
}
338340
}
@@ -814,7 +816,7 @@ object BreakManager : RequestHandler<BreakRequest>(
814816
config: BreakConfig,
815817
item: ItemStack? = null
816818
) = runSafe {
817-
val delta = calcItemBlockBreakingDelta(player, world, pos, item ?: player.inventory.selectedStack)
819+
val delta = calcItemBlockBreakingDelta(player, world, pos, item ?: player.mainHandStack)
818820
//ToDo: This setting requires some fixes / improvements in the player movement prediction to work properly. Currently, it's broken
819821
// if (config.desyncFix) {
820822
// val nextTickPrediction = buildPlayerPrediction().next()

0 commit comments

Comments
 (0)