Skip to content

Commit 52428ee

Browse files
committed
looser redundant break handling when considered broken
1 parent 6a51aca commit 52428ee

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -406,25 +406,29 @@ object BreakManager : RequestHandler<BreakRequest>(
406406
*/
407407
private fun SafeContext.onBlockBreak(info: BreakInfo) {
408408
info.request.onStop?.invoke(info.context.expectedPos)
409-
when (info.breakConfig.breakConfirmation) {
410-
BreakConfirmationMode.None -> {
411-
destroyBlock(info)
412-
info.internalOnBreak()
413-
if (!info.callbacksCompleted) {
409+
if (info.isRedundant) {
410+
info.startPending()
411+
} else {
412+
when (info.breakConfig.breakConfirmation) {
413+
BreakConfirmationMode.None -> {
414+
destroyBlock(info)
415+
info.internalOnBreak()
416+
if (!info.callbacksCompleted) {
417+
info.startPending()
418+
} else {
419+
ReBreakManager.offerReBreak(info)
420+
}
421+
}
422+
BreakConfirmationMode.BreakThenAwait -> {
423+
destroyBlock(info)
424+
info.startPending()
425+
}
426+
BreakConfirmationMode.AwaitThenBreak -> {
414427
info.startPending()
415-
} else {
416-
ReBreakManager.offerReBreak(info)
417428
}
418429
}
419-
BreakConfirmationMode.BreakThenAwait -> {
420-
destroyBlock(info)
421-
info.startPending()
422-
}
423-
BreakConfirmationMode.AwaitThenBreak -> {
424-
info.startPending()
425-
}
430+
breaksThisTick++
426431
}
427-
breaksThisTick++
428432
info.nullify()
429433
}
430434

@@ -508,8 +512,7 @@ object BreakManager : RequestHandler<BreakRequest>(
508512
lastPosStarted = ctx.expectedPos
509513
onBlockBreak(info)
510514
info.startBreakPacket(world, interaction)
511-
val swing = config.swing
512-
if (swing.isEnabled()) {
515+
if (config.swing.isEnabled()) {
513516
swingHand(config.swingType, Hand.MAIN_HAND)
514517
}
515518
return true

common/src/main/kotlin/com/lambda/interaction/request/breaking/BrokenBlockHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object BrokenBlockHandler {
8888
return@listen
8989
}
9090

91-
if (pending.breakConfig.breakConfirmation == BreakConfirmationMode.AwaitThenBreak) {
91+
if (pending.breakConfig.breakConfirmation == BreakConfirmationMode.AwaitThenBreak || pending.isRedundant) {
9292
destroyBlock(pending)
9393
}
9494
pending.internalOnBreak()

common/src/main/kotlin/com/lambda/interaction/request/breaking/ReBreakManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ object ReBreakManager {
7474

7575
val breakProgress = context.checkedState.calcBlockBreakingDelta(player, world, context.expectedPos)
7676
return@runSafe if (info.breakingTicks * breakProgress >= info.breakConfig.breakThreshold) {
77-
if (!context.checkedState.isEmpty && !awaitThenBreak) {
77+
if (context.checkedState.isEmpty) {
78+
return@runSafe ReBreakResult.Ignored
79+
}
80+
if (!awaitThenBreak) {
7881
destroyBlock(info)
7982
}
8083
info.stopBreakPacket(world, interaction)

0 commit comments

Comments
 (0)