@@ -324,7 +324,7 @@ object BreakManager : RequestHandler<BreakRequest>(
324324 }
325325 return @also
326326 }
327- if (! info.context.requestSwap(info.request, 0 )) return @run
327+ if (! info.context.requestSwap(info.request)) return @run
328328 }
329329 }
330330 .asReversed()
@@ -333,28 +333,6 @@ object BreakManager : RequestHandler<BreakRequest>(
333333 if (tickStage !in info.breakConfig.breakStageMask) return @forEach
334334 if (! rotated && info.isPrimary) return @run
335335
336- if (info.couldReBreak.value == true ) when (val reBreakResult = ReBreakManager .handleUpdate(info.context, info.request)) {
337- is ReBreakResult .StillBreaking -> {
338- primaryBreak = reBreakResult.breakInfo.apply {
339- type = Primary
340- ReBreakManager .clearReBreak()
341- request.onStart?.invoke(info.context.blockPos)
342- }
343-
344- primaryBreak?.let { primary ->
345- updateBreakProgress(primary)
346- }
347- return @forEach
348- }
349- is ReBreakResult .ReBroke -> {
350- info.type = ReBreak
351- info.nullify()
352- info.request.onReBreak?.invoke(info.context.blockPos)
353- return @forEach
354- }
355- else -> {}
356- }
357-
358336 updateBreakProgress(info)
359337 }
360338 }
@@ -657,31 +635,31 @@ object BreakManager : RequestHandler<BreakRequest>(
657635 * @see net.minecraft.client.network.ClientPlayerInteractionManager.updateBlockBreakingProgress
658636 */
659637 private fun SafeContext.updateBreakProgress (info : BreakInfo ): Boolean {
660- info.progressedThisTick = true
661-
662638 val config = info.breakConfig
663639 val ctx = info.context
664- val hitResult = ctx.result
665-
666- if (gamemode.isCreative && world.worldBorder.contains(ctx.blockPos) && info.breaking) {
667- breakCooldown = config.breakDelay
668- lastPosStarted = ctx.blockPos
669- onBlockBreak(info)
670- info.startBreakPacket(world, interaction)
671- if (config.swing.isEnabled()) {
672- swingHand(config.swingType, Hand .MAIN_HAND )
673- }
674- return true
675- }
676640
677641 if (! info.breaking) {
678642 if (! startBreaking(info)) {
679643 info.nullify()
680- info.request.onCancel?.invoke(info.context .blockPos)
644+ info.request.onCancel?.invoke(ctx .blockPos)
681645 return false
682646 }
683647 val swing = config.swing
684- if (swing.isEnabled() && swing != BreakConfig .SwingMode .End ) {
648+ if (swing.isEnabled() && (swing != BreakConfig .SwingMode .End || info.isReBreaking)) {
649+ swingHand(config.swingType, Hand .MAIN_HAND )
650+ }
651+ return true
652+ }
653+
654+ info.progressedThisTick = true
655+ val hitResult = ctx.result
656+
657+ if (gamemode.isCreative && world.worldBorder.contains(ctx.blockPos)) {
658+ breakCooldown = config.breakDelay
659+ lastPosStarted = ctx.blockPos
660+ onBlockBreak(info)
661+ info.startBreakPacket(world, interaction)
662+ if (config.swing.isEnabled()) {
685663 swingHand(config.swingType, Hand .MAIN_HAND )
686664 }
687665 return true
@@ -690,7 +668,7 @@ object BreakManager : RequestHandler<BreakRequest>(
690668 val blockState = blockState(ctx.blockPos)
691669 if (blockState.isEmpty || blockState.isAir) {
692670 info.nullify()
693- info.request.onCancel?.invoke(info.context .blockPos)
671+ info.request.onCancel?.invoke(ctx .blockPos)
694672 return false
695673 }
696674
@@ -756,6 +734,28 @@ object BreakManager : RequestHandler<BreakRequest>(
756734 private fun SafeContext.startBreaking (info : BreakInfo ): Boolean {
757735 val ctx = info.context
758736
737+ if (info.couldReBreak.value == true ) when (val reBreakResult = ReBreakManager .handleUpdate(info.context, info.request)) {
738+ is ReBreakResult .StillBreaking -> {
739+ primaryBreak = reBreakResult.breakInfo.apply {
740+ type = Primary
741+ ReBreakManager .clearReBreak()
742+ request.onStart?.invoke(ctx.blockPos)
743+ }
744+
745+ primaryBreak?.let { primary ->
746+ updateBreakProgress(primary)
747+ }
748+ return true
749+ }
750+ is ReBreakResult .ReBroke -> {
751+ info.type = ReBreak
752+ info.nullify()
753+ info.request.onReBreak?.invoke(ctx.blockPos)
754+ return true
755+ }
756+ else -> {}
757+ }
758+
759759 if (player.isBlockBreakingRestricted(world, ctx.blockPos, gamemode)) return false
760760 if (! world.worldBorder.contains(ctx.blockPos)) return false
761761
0 commit comments