@@ -63,10 +63,13 @@ object BreakManager : RequestHandler<BreakRequest>() {
6363 TaskFlowModule .build.maxPendingInteractions, TaskFlowModule .build.interactionTimeout * 50L
6464 ) { info(" ${it::class .simpleName} at ${it.context.expectedPos.toShortString()} timed out" ) }
6565
66+ private var blockBreakingCooldown = 0
67+
6668 init {
6769 listen<TickEvent .Pre >(Int .MIN_VALUE ) {
68- if (interaction.blockBreakingCooldown > 0 ) {
69- interaction.blockBreakingCooldown--
70+ if (isOnBreakCooldown()) {
71+ blockBreakingCooldown--
72+ updateRequest(true ) { true }
7073 return @listen
7174 }
7275
@@ -199,7 +202,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
199202 val hitResult = ctx.result
200203
201204 if (interaction.currentGameMode.isCreative && world.worldBorder.contains(ctx.expectedPos)) {
202- interaction.blockBreakingCooldown = info.breakConfig.breakDelay
205+ setBreakCooldown( info.breakConfig.breakDelay)
203206 interaction.sendSequencedPacket(world) { sequence ->
204207 onBlockBreak(info)
205208 PlayerActionC2SPacket (PlayerActionC2SPacket .Action .START_DESTROY_BLOCK , ctx.expectedPos, hitResult.side, sequence)
@@ -264,6 +267,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
264267 PlayerActionC2SPacket (PlayerActionC2SPacket .Action .STOP_DESTROY_BLOCK , ctx.expectedPos, hitResult.side, sequence)
265268 }
266269 if (info.breakConfig.swing != BreakConfig .SwingMode .Start ) swingHand(info)
270+ setBreakCooldown(info.breakConfig.breakDelay)
267271 } else {
268272 if (info.breakConfig.swing == BreakConfig .SwingMode .Constant ) swingHand(info)
269273 }
@@ -282,7 +286,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
282286 onBlockBreak(info)
283287 PlayerActionC2SPacket (PlayerActionC2SPacket .Action .START_DESTROY_BLOCK , ctx.expectedPos, ctx.result.side, sequence)
284288 }
285- interaction.blockBreakingCooldown = info.breakConfig.breakDelay
289+ setBreakCooldown( info.breakConfig.breakDelay)
286290 return true
287291 }
288292 if (info.breaking) return false
@@ -386,6 +390,11 @@ object BreakManager : RequestHandler<BreakRequest>() {
386390 }
387391 }
388392
393+ private fun isOnBreakCooldown () = blockBreakingCooldown > 0
394+ private fun setBreakCooldown (cooldown : Int ) {
395+ blockBreakingCooldown = cooldown
396+ }
397+
389398 data class BreakInfo (
390399 val context : BreakContext ,
391400 var type : BreakType ,
0 commit comments