@@ -27,13 +27,14 @@ import com.lambda.event.listener.SafeListener.Companion.listen
2727import com.lambda.interaction.construction.context.InteractionContext
2828import com.lambda.interaction.request.Logger
2929import com.lambda.interaction.request.ManagerUtils.isPosBlocked
30+ import com.lambda.interaction.request.ManagerUtils.newStage
31+ import com.lambda.interaction.request.ManagerUtils.newTick
3032import com.lambda.interaction.request.PositionBlocking
3133import com.lambda.interaction.request.RequestHandler
3234import com.lambda.interaction.request.breaking.BreakManager
3335import com.lambda.interaction.request.interacting.InteractedBlockHandler.pendingActions
3436import com.lambda.interaction.request.interacting.InteractedBlockHandler.setPendingConfigs
3537import com.lambda.interaction.request.interacting.InteractedBlockHandler.startPending
36- import com.lambda.interaction.request.interacting.InteractionManager.activeRequest
3738import com.lambda.interaction.request.interacting.InteractionManager.processRequest
3839import com.lambda.interaction.request.placing.PlaceManager
3940import com.lambda.module.hud.ManagerDebugLoggers.interactionManagerLogger
@@ -48,7 +49,11 @@ object InteractionManager : RequestHandler<InteractRequest>(
4849 TickEvent .Input .Pre ,
4950 TickEvent .Input .Post ,
5051 TickEvent .Player .Post ,
51- onOpen = { activeRequest?.let { processRequest(it) } }
52+ onOpen = {
53+ if (InteractionManager .potentialInteractions.isNotEmpty())
54+ InteractionManager .logger.newStage(InteractionManager .tickStage)
55+ InteractionManager .activeRequest?.let { processRequest(it) }
56+ }
5257), PositionBlocking, Logger {
5358 private var activeRequest: InteractRequest ? = null
5459 private var potentialInteractions = mutableListOf<InteractionContext >()
@@ -64,6 +69,11 @@ object InteractionManager : RequestHandler<InteractRequest>(
6469 override fun load (): String {
6570 super .load()
6671
72+ listen<TickEvent .Pre >(priority = Int .MAX_VALUE ) {
73+ if (potentialInteractions.isNotEmpty())
74+ logger.newTick()
75+ }
76+
6777 listen<TickEvent .Post >(priority = Int .MIN_VALUE ) {
6878 activeRequest = null
6979 interactionsThisTick = 0
@@ -88,6 +98,8 @@ object InteractionManager : RequestHandler<InteractRequest>(
8898 }
8999
90100 fun SafeContext.processRequest (request : InteractRequest ) {
101+ logger.debug(" Processing request ${request.requestID} " )
102+
91103 if (request.fresh) populateFrom(request)
92104
93105 if (player.isSneaking) return
@@ -97,7 +109,10 @@ object InteractionManager : RequestHandler<InteractRequest>(
97109 if (interactionsThisTick + 1 > maxInteractionsThisTick) break
98110 val ctx = iterator.next()
99111
100- if (! ctx.requestDependencies(request)) return
112+ if (! ctx.requestDependencies(request)) {
113+ logger.warning(" Dependencies failed for ${request.requestID} " )
114+ return
115+ }
101116
102117 if (request.interactConfirmationMode != InteractionConfig .InteractConfirmationMode .None ) {
103118 InteractionInfo (ctx, request.pendingInteractionsList, request).startPending()
@@ -115,15 +130,19 @@ object InteractionManager : RequestHandler<InteractRequest>(
115130 request.onInteract?.invoke(ctx.blockPos)
116131 interactionsThisTick++
117132 iterator.remove()
133+ logger.success(" Placed ${ctx.expectedState} at ${ctx.blockPos} " )
118134 }
119135 }
120136
121137 private fun populateFrom (request : InteractRequest ) {
138+ logger.debug(" Populating from request ${request.requestID} " )
122139 setPendingConfigs(request.build)
123140 potentialInteractions = request.contexts
124141 .filter { ! isPosBlocked(it.blockPos) }
125142 .toMutableList()
126143
144+ logger.debug(" ${potentialInteractions.size} potential interactions" )
145+
127146 val pendingLimit = (request.build.maxPendingInteractions - pendingActions.size).coerceAtLeast(0 )
128147 maxInteractionsThisTick = (request.build.interactionsPerTick.coerceAtMost(pendingLimit))
129148 }
0 commit comments