@@ -110,8 +110,6 @@ object BreakManager : RequestHandler<BreakRequest>(
110110 it?.breakConfig?.doubleBreak == true || it?.isSecondary == true
111111 }?.context?.itemSelection
112112 ? : StackSelection .EVERYTHING .select()
113- val currentContext
114- get() = breakInfos.lastOrNull()?.context
115113
116114 private val pendingBreakCount get() = breakInfos.count { it != null } + pendingActions.size
117115 override val blockedPositions
@@ -198,6 +196,12 @@ object BreakManager : RequestHandler<BreakRequest>(
198196 }
199197
200198 listen<RenderEvent .StaticESP > { event ->
199+ val activeStack = breakInfos
200+ .filterNotNull()
201+ .firstOrNull()?.let { info ->
202+ player.inventory.getStack(info.context.hotbarIndex)
203+ } ? : return @listen
204+
201205 breakInfos
202206 .filterNotNull()
203207 .forEach { info ->
@@ -208,7 +212,7 @@ object BreakManager : RequestHandler<BreakRequest>(
208212 world,
209213 info.context.blockPos,
210214 info.breakConfig,
211- if (! info.isRedundant) player.inventory.getStack(info.context.hotbarIndex) else null
215+ if (! info.isRedundant) activeStack else null
212216 ).toDouble()
213217 val currentDelta = info.breakingTicks * breakDelta
214218
@@ -290,7 +294,7 @@ object BreakManager : RequestHandler<BreakRequest>(
290294 }
291295 .also {
292296 it.firstOrNull()?.let { info ->
293- val minKeepTicks = secondaryBreak?.let { secondary ->
297+ secondaryBreak?.let { secondary ->
294298 val breakDelta = secondary.context.cachedState.calcBreakDelta(
295299 player,
296300 world,
@@ -299,9 +303,17 @@ object BreakManager : RequestHandler<BreakRequest>(
299303 player.inventory.getStack(secondary.context.hotbarIndex)
300304 )
301305 val breakAmount = breakDelta * (secondary.breakingTicks + 1 )
302- if (breakAmount >= 1.0f ) 1 else 0
303- } ? : 0
304- if (! info.context.requestDependencies(info.request, minKeepTicks)) return @run
306+ val minKeepTicks = if (breakAmount >= 1.0f ) 1 else 0
307+ if (! info.context.requestDependencies(info.request, minKeepTicks)) {
308+ secondary.serverBreakTicks = 0
309+ return @run
310+ }
311+ if (minKeepTicks > 0 ) {
312+ secondary.serverBreakTicks++
313+ }
314+ return @also
315+ }
316+ if (! info.context.requestDependencies(info.request, 0 )) return @run
305317 }
306318 }
307319 .asReversed()
@@ -369,19 +381,13 @@ object BreakManager : RequestHandler<BreakRequest>(
369381 // Sanitize the new breaks
370382 val newBreaks = request.contexts
371383 .distinctBy { it.blockPos }
372- .filter { ctx -> canAccept(ctx) }
373- .let { acceptable ->
374- acceptable.firstOrNull()?.let { first ->
375- acceptable.filter { it.hotbarIndex == first.hotbarIndex }
376- } ? : acceptable
377- }
378384 .toMutableList()
379385
380386 // Update the current break infos
381387 breakInfos
382388 .filterNotNull()
383389 .forEach { info ->
384- newBreaks.find { ctx -> ctx.blockPos == info.context.blockPos }?.let { ctx ->
390+ newBreaks.find { ctx -> ctx.blockPos == info.context.blockPos && canAccept(ctx) }?.let { ctx ->
385391 if (! info.updatedThisTick || info.abandoned) {
386392 info.updateInfo(ctx, request)
387393 if (info.isRedundant)
@@ -418,14 +424,9 @@ object BreakManager : RequestHandler<BreakRequest>(
418424
419425 breakInfos
420426 .lastOrNull { it != null && ! it.isRedundant && it.breakConfig.doubleBreak }
421- ?.let { info ->
422- val currentCtx = info.context
423- val currentStack = player.inventory.getStack(currentCtx.hotbarIndex)
424- val currentSpeed = currentCtx.cachedState.calcItemBlockBreakingDelta(player, world, currentCtx.blockPos, currentStack)
427+ ?.let { current ->
425428 val newStack = player.inventory.getStack(newCtx.hotbarIndex)
426- val newSpeed = currentCtx.cachedState.calcItemBlockBreakingDelta(player, world, info.context.blockPos, newStack)
427- if (! currentCtx.itemSelection.filterStack(newStack) || newSpeed < currentSpeed)
428- return false
429+ if (! current.context.itemSelection.filterStack(newStack)) return false
429430 }
430431
431432 val blockState = blockState(newCtx.blockPos)
@@ -446,6 +447,8 @@ object BreakManager : RequestHandler<BreakRequest>(
446447
447448 val ctx = iterator.next()
448449
450+ if (! canAccept(ctx)) continue
451+
449452 if (! ctx.requestDependencies(request)) return false
450453 rotationRequest = if (request.config.rotateForBreak) ctx.rotation.submit(false ) else null
451454 if (! rotated || tickStage !in request.config.breakStageMask) return false
@@ -469,6 +472,9 @@ object BreakManager : RequestHandler<BreakRequest>(
469472 val iterator = breaks.iterator()
470473 while (iterator.hasNext()) {
471474 val ctx = iterator.next()
475+
476+ if (! canAccept(ctx)) continue
477+
472478 initNewBreak(ctx, request) ? : return false
473479 iterator.remove()
474480 }
@@ -723,7 +729,7 @@ object BreakManager : RequestHandler<BreakRequest>(
723729 }
724730
725731 val swing = config.swing
726- if (overBreakThreshold) {
732+ if (overBreakThreshold && ( ! info.isSecondary || info.serverBreakTicks >= info.breakConfig.fudgeFactor + 1 ) ) {
727733 if (info.isPrimary) {
728734 onBlockBreak(info)
729735 info.stopBreakPacket(world, interaction)
0 commit comments