@@ -75,7 +75,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
7575 request.contexts
7676 .sortedBy { it.instantBreak }
7777 .forEach { requestCtx ->
78- if (blockState (requestCtx.expectedPos).isAir ) {
78+ if (! canAccept (requestCtx) ) {
7979 return @forEach
8080 }
8181 val infoIndex = handleRequestContext(
@@ -144,8 +144,6 @@ object BreakManager : RequestHandler<BreakRequest>() {
144144 buildConfig : BuildConfig ,
145145 rotationConfig : RotationConfig
146146 ): Int {
147- if (! canAccept(requestCtx)) return - 1
148-
149147 primaryBreakingInfo?.let { primaryInfo ->
150148 if (! primaryInfo.breakConfig.doubleBreak) return - 1
151149 if (primaryInfo.startedWithSecondary) return - 1
@@ -167,7 +165,9 @@ object BreakManager : RequestHandler<BreakRequest>() {
167165 onBreak,
168166 buildConfig.breakSettings,
169167 rotationConfig
170- )
168+ ).apply {
169+ startedWithSecondary = true
170+ }
171171 return 0
172172 }
173173 } ? : run {
@@ -177,16 +177,20 @@ object BreakManager : RequestHandler<BreakRequest>() {
177177 onBreak,
178178 buildConfig.breakSettings,
179179 rotationConfig
180- )
180+ ).apply {
181+ if (secondaryBreakingInfo != null )
182+ startedWithSecondary = true
183+ }
181184 pendingInteractions.setMaxSize(buildConfig.maxPendingInteractions)
182185 pendingInteractions.setDecayTime(buildConfig.interactionTimeout * 50L )
183186 return 0
184187 }
185188 }
186189
187- private fun canAccept (ctx : BreakContext ) =
190+ private fun SafeContext. canAccept (ctx : BreakContext ) =
188191 pendingInteractions.none { it.context.expectedPos == ctx.expectedPos }
189192 && breakingInfos.none { info -> info?.context?.expectedPos == ctx.expectedPos }
193+ && ! blockState(ctx.expectedPos).isAir
190194
191195 private fun SafeContext.updateBlockBreakingProgress (info : BreakInfo , item : ItemStack ): Boolean {
192196 val ctx = info.context
@@ -301,9 +305,9 @@ object BreakManager : RequestHandler<BreakRequest>() {
301305 if (info.breakConfig.breakingTexture) {
302306 setBreakingTextureStage(info)
303307 }
308+ if (info.type == BreakInfo .BreakType .Secondary )
309+ primaryBreakingInfo?.startedWithSecondary = true
304310 }
305- if (info.type == BreakInfo .BreakType .Secondary )
306- primaryBreakingInfo?.startedWithSecondary = true
307311
308312 if (info.breakConfig.breakMode == BreakMode .Packet ) {
309313 ctx.stopBreakPacket(sequence, connection)
0 commit comments