@@ -49,6 +49,7 @@ import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
4949import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak
5050import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary
5151import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary
52+ import com.lambda.interaction.request.breaking.BreakManager.activeInfos
5253import com.lambda.interaction.request.breaking.BreakManager.activeRequest
5354import com.lambda.interaction.request.breaking.BreakManager.breakInfos
5455import com.lambda.interaction.request.breaking.BreakManager.breaks
@@ -103,7 +104,12 @@ object BreakManager : RequestHandler<BreakRequest>(
103104 TickEvent .Input .Pre ,
104105 TickEvent .Input .Post ,
105106 TickEvent .Player .Post ,
106- onOpen = { processRequest(activeRequest); simulateAbandoned() },
107+ onOpen = {
108+ if (activeInfos.isNotEmpty() || breaks.isNotEmpty() || instantBreaks.isNotEmpty())
109+ BreakManager .logger.system("Tick stage ${BreakManager .tickStage?.run { this::class.qualifiedName }}")
110+ processRequest(activeRequest)
111+ simulateAbandoned()
112+ },
107113 onClose = { checkForCancels() }
108114), PositionBlocking, Logger {
109115 private val breakInfos = arrayOfNulls<BreakInfo >(2 )
@@ -178,6 +184,11 @@ object BreakManager : RequestHandler<BreakRequest>(
178184 override fun load (): String {
179185 super .load()
180186
187+ listen<TickEvent .Pre >(priority = Int .MAX_VALUE ) {
188+ if (activeInfos.isEmpty() && breaks.isEmpty() && instantBreaks.isEmpty()) return @listen
189+ logger.system(" ------------- New Tick -------------" )
190+ }
191+
181192 listen<TickEvent .Post >(priority = Int .MIN_VALUE ) {
182193 if (! swappedThisTick) {
183194 currentStack = player.mainHandStack
@@ -377,7 +388,7 @@ object BreakManager : RequestHandler<BreakRequest>(
377388 .forEach { info ->
378389 newBreaks.find { ctx -> ctx.blockPos == info.context.blockPos && canAccept(ctx) }?.let { ctx ->
379390 if ((! info.updatedThisTick || info.type == RedundantSecondary ) || info.abandoned) {
380- logger.debug(" Updating info for ${ info.type} " )
391+ logger.debug(" Updating info for $info " )
381392 if (info.type == RedundantSecondary )
382393 info.request.onStart?.invoke(info.context.blockPos)
383394 else if (info.abandoned) {
@@ -403,7 +414,7 @@ object BreakManager : RequestHandler<BreakRequest>(
403414 .filter { ! it.instantBreak }
404415 .toMutableList()
405416
406- logger.debug(" ${breaks.size} unprocessed instant breaks" )
417+ logger.debug(" ${breaks.size} unprocessed breaks" )
407418
408419 val breakConfig = request.config
409420 val pendingLimit = (breakConfig.maxPendingBreaks - pendingBreakCount).coerceAtLeast(0 )
@@ -429,7 +440,6 @@ object BreakManager : RequestHandler<BreakRequest>(
429440 activeInfos
430441 .filter { it.updatedThisTick }
431442 .let { infos ->
432- if (infos.isNotEmpty()) logger.debug(" Handling pre-processing" )
433443 rotationRequest = infos.firstOrNull { info -> info.breakConfig.rotateForBreak }
434444 ?.let { info ->
435445 val rotation = info.context.rotation
@@ -453,7 +463,7 @@ object BreakManager : RequestHandler<BreakRequest>(
453463 }
454464 logger.debug(" Submitting request for hotbar index ${info.context.hotbarIndex} with min swap ticks $minSwapTicks (${hotbarRequest.requestID} )" )
455465 if (! hotbarRequest.done) {
456- logger.debug (" hotbar request failed (${hotbarRequest.requestID} )" )
466+ logger.warning (" hotbar request failed (${hotbarRequest.requestID} )" )
457467 return false
458468 }
459469 if (minSwapTicks > 0 ) {
@@ -474,7 +484,7 @@ object BreakManager : RequestHandler<BreakRequest>(
474484 * @return false if a break could not be performed.
475485 */
476486 private fun SafeContext.performInstantBreaks (request : BreakRequest ): Boolean {
477- if (instantBreaks.isNotEmpty()) logger.debug(" Processing instant breaks" )
487+ if (instantBreaks.isNotEmpty()) logger.debug(" Processing instant breaks ${instantBreaks.size} " )
478488 val iterator = instantBreaks.iterator()
479489 while (iterator.hasNext()) {
480490 if (breaksThisTick + 1 > maxBreaksThisTick) return false
@@ -503,7 +513,7 @@ object BreakManager : RequestHandler<BreakRequest>(
503513 * @see initNewBreak
504514 */
505515 private fun SafeContext.processNewBreaks (request : BreakRequest ): Boolean {
506- if (breaks.isNotEmpty()) logger.debug(" Processing new breaks" )
516+ if (breaks.isNotEmpty()) logger.debug(" Processing new breaks ${breaks.size} " )
507517 val iterator = breaks.iterator()
508518 while (iterator.hasNext()) {
509519 val ctx = iterator.next()
@@ -538,6 +548,7 @@ object BreakManager : RequestHandler<BreakRequest>(
538548
539549 if (! primaryInfo.breaking) {
540550 secondaryBreak = breakInfo.apply { type = Secondary }
551+ logger.success(" Initialized $secondaryBreak " )
541552 return secondaryBreak
542553 }
543554
@@ -549,6 +560,7 @@ object BreakManager : RequestHandler<BreakRequest>(
549560
550561 primaryBreak = breakInfo
551562 setPendingConfigs(request.build)
563+ logger.success(" Initialized $primaryBreak " )
552564 return primaryBreak
553565 }
554566
@@ -632,7 +644,7 @@ object BreakManager : RequestHandler<BreakRequest>(
632644 }
633645
634646 private fun BreakInfo.updatePreProcessing (player : ClientPlayerEntity , world : BlockView ) {
635- logger.debug(" Updating pre-processing for $type " )
647+ logger.debug(" Updating pre-processing for $this " )
636648
637649 shouldProgress = ! progressedThisTick
638650 && tickStage in breakConfig.breakStageMask
@@ -661,20 +673,20 @@ object BreakManager : RequestHandler<BreakRequest>(
661673 if (type == RedundantSecondary || abandoned) return @runSafe
662674 when (type) {
663675 Primary -> {
664- logger.debug (" Cancelling $type " )
676+ logger.warning (" Cancelling ${ this @cancelBreak} " )
665677 nullify()
666678 setBreakingTextureStage(player, world, - 1 )
667679 abortBreakPacket(world, interaction)
668680 request.onCancel?.invoke(context.blockPos)
669681 }
670682 Secondary -> {
671683 if (breakConfig.unsafeCancels) {
672- logger.warning(" Making $type redundant" )
684+ logger.warning(" Making ${ this @cancelBreak} redundant" )
673685 type = RedundantSecondary
674686 setBreakingTextureStage(player, world, - 1 )
675687 request.onCancel?.invoke(context.blockPos)
676688 } else {
677- logger.debug (" Abandoning $type " )
689+ logger.warning (" Abandoning ${ this @cancelBreak} " )
678690 abandoned = true
679691 }
680692 }
@@ -774,7 +786,7 @@ object BreakManager : RequestHandler<BreakRequest>(
774786
775787 val swing = config.swing
776788 if (progress >= info.getBreakThreshold() && info.swapInfo.canCompleteBreak) {
777- logger.success(" Breaking ${ info.type} ${info.context.cachedState} " )
789+ logger.success(" Breaking $info " )
778790 if (info.type == Primary ) {
779791 onBlockBreak(info)
780792 info.stopBreakPacket(world, interaction)
0 commit comments