@@ -20,23 +20,22 @@ package com.lambda.interaction.request.breaking
2020import com.lambda.interaction.request.LogContext
2121import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder
2222import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
23+ import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary
2324import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta
24- import com.lambda.interaction.request.hotbar.HotbarConfig
2525import com.lambda.module.modules.client.TaskFlowModule
2626import net.minecraft.client.network.ClientPlayerEntity
2727import net.minecraft.world.BlockView
2828
2929data class SwapInfo (
3030 private val type : BreakInfo .BreakType ,
31- private val hotbarConfig : HotbarConfig = TaskFlowModule .hotbar ,
31+ private val breakConfig : BreakConfig = TaskFlowModule .build.breaking ,
3232 val swap : Boolean = false ,
33- val minKeepTicks : Int = 0 ,
33+ val longSwap : Boolean = false
3434) : LogContext {
3535 override fun getLogContextBuilder (): LogContextBuilder .() -> Unit = {
3636 group(" Swap Info" ) {
3737 value(" Type" , type)
3838 value(" Swap" , swap)
39- value(" Min Keep Ticks" , minKeepTicks)
4039 }
4140 }
4241
@@ -58,32 +57,30 @@ data class SwapInfo(
5857 ? : throw IllegalStateException (" Rebreak BreakInfo was null when rebreak was considered possible" )
5958 else breakingTicks) + 1 - breakConfig.fudgeFactor
6059
61- val minKeepTicks = run {
62- if (type == Primary ) {
63- val swapTickProgress = breakDelta * (breakTicks + request.config.serverSwapTicks - 1 ).coerceAtLeast(1 )
64- if (swapTickProgress >= threshold && request.config.serverSwapTicks > 0 ) 1
65- else 0
66- } else {
60+ val swapAtEnd = run {
61+ val swapTickProgress = if (type == Primary )
62+ breakDelta * (breakTicks + request.config.serverSwapTicks - 1 ).coerceAtLeast(1 )
63+ else {
6764 val serverSwapTicks = request.hotbar.swapPause.coerceAtLeast(3 )
68- val swapTickProgress = breakDelta * (breakTicks + serverSwapTicks - 1 ).coerceAtLeast(1 )
69- if (swapTickProgress >= threshold) 1
70- else 0
65+ breakDelta * (breakTicks + serverSwapTicks - 1 ).coerceAtLeast(1 )
7166 }
67+ swapTickProgress >= threshold
7268 }
7369
74- val swapAtEnd = breakDelta * breakTicks >= threshold || minKeepTicks > 0
75-
76- val swap = if (rebreakPotential == RebreakHandler .RebreakPotential .Instant )
77- breakConfig.swapMode.isEnabled()
78- else when (breakConfig.swapMode) {
70+ val swap = when (breakConfig.swapMode) {
7971 BreakConfig .SwapMode .None -> false
8072 BreakConfig .SwapMode .Start -> ! breaking
8173 BreakConfig .SwapMode .End -> swapAtEnd
8274 BreakConfig .SwapMode .StartAndEnd -> ! breaking || swapAtEnd
8375 BreakConfig .SwapMode .Constant -> true
8476 }
8577
86- return SwapInfo (info.type, request.hotbar, swap, minKeepTicks)
78+ return SwapInfo (
79+ info.type,
80+ request.config,
81+ swap,
82+ breakConfig.serverSwapTicks > 0 || (info.type == Secondary && swapAtEnd)
83+ )
8784 }
8885 }
8986}
0 commit comments