Skip to content

Commit d6601c4

Browse files
committed
rebreak adjustments
1 parent 37786be commit d6601c4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object BreakManager : RequestHandler<BreakRequest>(
9494
TickEvent.Input.Pre,
9595
TickEvent.Input.Post,
9696
TickEvent.Player.Post,
97-
onOpen = { simulateAbandoned(); processRequest(activeRequest) },
97+
onOpen = { processRequest(activeRequest); simulateAbandoned() },
9898
onClose = { checkForCancels() }
9999
), PositionBlocking {
100100
private var primaryBreak: BreakInfo?

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ object ReBreakManager {
3232
var reBreak: BreakInfo? = null
3333

3434
init {
35-
listen<TickEvent.Post>(priority = Int.MIN_VALUE) {
36-
reBreak?.apply {
37-
breakingTicks++
38-
tickStats()
35+
listen<TickEvent.Pre>(priority = Int.MIN_VALUE) {
36+
reBreak?.run {
37+
if (!progressedThisTick) {
38+
breakingTicks++
39+
progressedThisTick = true
40+
}
3941
}
4042
}
4143

44+
listen<TickEvent.Post>(priority = Int.MIN_VALUE) {
45+
reBreak?.tickStats()
46+
}
47+
4248
listenUnsafe<ConnectionEvent.Connect.Pre>(priority = Int.MIN_VALUE) {
4349
reBreak = null
4450
}
@@ -72,7 +78,7 @@ object ReBreakManager {
7278
val context = info.context
7379

7480
val breakProgress = context.cachedState.calcBlockBreakingDelta(player, world, context.blockPos)
75-
return@runSafe if (info.breakingTicks * breakProgress >= info.breakConfig.breakThreshold) {
81+
return@runSafe if ((info.breakingTicks - info.breakConfig.fudgeFactor) * breakProgress >= info.breakConfig.breakThreshold) {
7682
if (context.cachedState.isEmpty) {
7783
return@runSafe ReBreakResult.Ignored
7884
}

0 commit comments

Comments
 (0)