@@ -66,6 +66,7 @@ import com.lambda.interaction.request.breaking.BrokenBlockHandler.pendingActions
6666import com.lambda.interaction.request.breaking.BrokenBlockHandler.setPendingConfigs
6767import com.lambda.interaction.request.breaking.BrokenBlockHandler.startPending
6868import com.lambda.interaction.request.breaking.SwapInfo.Companion.getSwapInfo
69+ import com.lambda.interaction.request.hotbar.HotbarRequest
6970import com.lambda.interaction.request.interacting.InteractionManager
7071import com.lambda.interaction.request.placing.PlaceManager
7172import com.lambda.interaction.request.rotating.RotationRequest
@@ -428,8 +429,16 @@ object BreakManager : RequestHandler<BreakRequest>(
428429 infos.firstOrNull()?.let { info ->
429430 infos.lastOrNull { it.swapInfo.swap && it.shouldProgress }?.let { last ->
430431 val minSwapTicks = max(info.swapInfo.minKeepTicks, last.swapInfo.minKeepTicks)
431- if (! info.context.requestSwap(info.request, minSwapTicks))
432+ val hotbarRequest = with (info) {
433+ HotbarRequest (
434+ context.hotbarIndex,
435+ request.hotbar,
436+ request.hotbar.keepTicks.coerceAtLeast(minSwapTicks)
437+ ).submit(false )
438+ }
439+ if (! hotbarRequest.done) {
432440 return false
441+ }
433442 if (minSwapTicks > 0 ) {
434443 val alreadySwapped = swappedThisTick
435444 currentStack = info.swapStack
@@ -513,8 +522,8 @@ object BreakManager : RequestHandler<BreakRequest>(
513522 return secondaryBreak
514523 }
515524
516- primaryInfo.stopBreakPacket(world, interaction)
517- primaryInfo.makeSecondary( )
525+ secondaryBreak = primaryInfo.apply { type = Secondary }
526+ secondaryBreak?.stopBreakPacket(world, interaction )
518527 return @let
519528 }
520529
@@ -615,17 +624,6 @@ object BreakManager : RequestHandler<BreakRequest>(
615624 swapInfo = getSwapInfo(this , player, world)
616625 }
617626
618- /* *
619- * Makes the [BreakInfo] a secondary if not already.
620- */
621- private fun BreakInfo.makeSecondary () {
622- if (secondaryBreak == = this ) return
623- secondaryBreak = this .apply {
624- type = Secondary
625- }
626- primaryBreak = null
627- }
628-
629627 /* *
630628 * Attempts to cancel the break.
631629 *
@@ -715,12 +713,8 @@ object BreakManager : RequestHandler<BreakRequest>(
715713 }
716714
717715 info.breakingTicks++
718- val progress = blockState.calcBreakDelta(
719- player,
720- world,
721- ctx.blockPos,
722- config
723- ) * (info.breakingTicks - config.fudgeFactor)
716+ val breakDelta = blockState.calcBreakDelta(player, world, ctx.blockPos, config)
717+ val progress = breakDelta * (info.breakingTicks - config.fudgeFactor)
724718
725719 if (config.sounds) {
726720 if (info.soundsCooldown % 4.0f == 0.0f ) {
@@ -748,7 +742,7 @@ object BreakManager : RequestHandler<BreakRequest>(
748742 }
749743
750744 val swing = config.swing
751- if (progress >= info.getBreakThreshold() && info.swapInfo.canCompleteBreak ) {
745+ if (progress >= info.getBreakThreshold() && info.swapInfo.validSwap ) {
752746 if (info.type == Primary ) {
753747 onBlockBreak(info)
754748 info.stopBreakPacket(world, interaction)
@@ -821,8 +815,11 @@ object BreakManager : RequestHandler<BreakRequest>(
821815 }
822816
823817 val progress = blockState.calcBreakDelta(player, world, ctx.blockPos, info.breakConfig)
824- info.vanillaInstantBreakable = progress >= 1 && info.swapInfo.canCompleteBreak
825- if (progress >= info.getBreakThreshold() && info.swapInfo.canCompleteBreak) {
818+
819+ val instantBreakable = progress >= info.getBreakThreshold() && info.swapInfo.validSwap
820+ info.vanillaInstantBreakable = progress >= 1 && info.swapInfo.validSwap
821+
822+ if (instantBreakable) {
826823 onBlockBreak(info)
827824 if (! info.vanillaInstantBreakable) breakCooldown = info.breakConfig.breakDelay
828825 } else {
@@ -842,7 +839,7 @@ object BreakManager : RequestHandler<BreakRequest>(
842839
843840 info.startBreakPacket(world, interaction)
844841
845- if (info.type == Secondary || (! info.vanillaInstantBreakable && progress >= info.breakConfig.breakThreshold )) {
842+ if (info.type == Secondary || (instantBreakable && ! info.vanillaInstantBreakable )) {
846843 info.stopBreakPacket(world, interaction)
847844 }
848845
@@ -854,10 +851,9 @@ object BreakManager : RequestHandler<BreakRequest>(
854851 world : BlockView ,
855852 pos : BlockPos ,
856853 config : BreakConfig ,
857- item : ItemStack ? = null,
858- ignoreEfficiency : Boolean = false
854+ item : ItemStack ? = null
859855 ) = runSafe {
860- val delta = calcItemBlockBreakingDelta(player, world, pos, item ? : player.mainHandStack, ignoreEfficiency )
856+ val delta = calcItemBlockBreakingDelta(player, world, pos, item ? : player.mainHandStack)
861857 // ToDo: This setting requires some fixes / improvements in the player movement prediction to work properly. Currently, it's broken
862858// if (config.desyncFix) {
863859// val nextTickPrediction = buildPlayerPrediction().next()
0 commit comments