@@ -71,6 +71,7 @@ import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
7171import com.lambda.util.BlockUtils.isEmpty
7272import com.lambda.util.BlockUtils.isNotBroken
7373import com.lambda.util.BlockUtils.isNotEmpty
74+ import com.lambda.util.Communication.info
7475import com.lambda.util.extension.partialTicks
7576import com.lambda.util.item.ItemUtils.block
7677import com.lambda.util.math.lerp
@@ -298,41 +299,40 @@ object BreakManager : RequestHandler<BreakRequest>(
298299 if (instantBreaks.isEmpty()) rotation.submit(false ) else rotation
299300 }
300301 }
301- .also {
302+ .also {
302303 it.forEach {
303304 it.couldReBreak.update()
304305 it.shouldProgress = ! it.progressedThisTick &&
305306 tickStage in it.breakConfig.breakStageMask &&
306307 (rotated || ! it.isPrimary)
307308 }
308309 }
310+ .asReversed()
309311 .also {
310- if (breakInfos.none { it? .shouldSwap(player, world) == true }) return @also
311-
312- it.firstOrNull()?. let { info ->
313- secondaryBreak?. let { secondary ->
314- val breakDelta = secondary .context.cachedState.calcBreakDelta(
315- player ,
316- world,
317- secondary.context.blockPos,
318- secondary.breakConfig,
319- player.inventory.getStack(secondary.context.hotbarIndex)
320- )
321- val breakAmount = breakDelta * ((secondary.breakingTicks - secondary.breakConfig.fudgeFactor) + 1 )
322- val minKeepTicks = if (breakAmount >= 1.0f ) 1 else 0
323- if ( ! info.context.requestSwap(info.request, minKeepTicks)) {
324- secondary.serverBreakTicks = 0
325- return @run
326- }
327- if (minKeepTicks > 0 ) {
328- secondary.serverBreakTicks ++
329- }
330- return @also
312+ it.firstOrNull { it.shouldSwap(player, world) }?. let { info ->
313+ val breakDelta = info.context.cachedState.calcBreakDelta(
314+ player,
315+ world,
316+ info .context.blockPos,
317+ info.breakConfig ,
318+ player.inventory.getStack(info.context.hotbarIndex)
319+ )
320+ val breakAmount = breakDelta * info.breakingTicks
321+ val minKeepTicks = if (breakAmount >= info.getBreakThreshold() &&
322+ info.serverBreakTicks < info.breakConfig.fudgeFactor )
323+ {
324+ 1
325+ } else 0
326+
327+ if ( ! info.context.requestSwap(info.request, minKeepTicks)) {
328+ info.serverBreakTicks = 0
329+ return @run
330+ }
331+ if (minKeepTicks > 0 ) {
332+ info.serverBreakTicks ++
331333 }
332- if (! info.context.requestSwap(info.request)) return @run
333334 }
334335 }
335- .asReversed()
336336 .forEach { info ->
337337 if (! info.shouldProgress) return @forEach
338338 updateBreakProgress(info)
@@ -640,6 +640,8 @@ object BreakManager : RequestHandler<BreakRequest>(
640640 val config = info.breakConfig
641641 val ctx = info.context
642642
643+ info.progressedThisTick = true
644+
643645 if (! info.breaking) {
644646 if (! startBreaking(info)) {
645647 info.nullify()
@@ -653,7 +655,6 @@ object BreakManager : RequestHandler<BreakRequest>(
653655 return true
654656 }
655657
656- info.progressedThisTick = true
657658 val hitResult = ctx.result
658659
659660 if (gamemode.isCreative && world.worldBorder.contains(ctx.blockPos)) {
@@ -710,7 +711,7 @@ object BreakManager : RequestHandler<BreakRequest>(
710711 }
711712
712713 val swing = config.swing
713- if (overBreakThreshold && ( ! info.isSecondary || info. serverBreakTicks >= info.breakConfig.fudgeFactor + 1 ) ) {
714+ if (overBreakThreshold && info.serverBreakTicks >= info.breakConfig.fudgeFactor) {
714715 if (info.isPrimary) {
715716 onBlockBreak(info)
716717 info.stopBreakPacket(world, interaction)
0 commit comments