@@ -27,17 +27,14 @@ import com.lambda.event.events.UpdateManagerEvent
2727import com.lambda.event.events.WorldEvent
2828import com.lambda.event.listener.SafeListener.Companion.listen
2929import com.lambda.interaction.construction.context.BreakContext
30- import com.lambda.interaction.construction.context.BuildContext
3130import com.lambda.interaction.construction.verify.TargetState
3231import com.lambda.interaction.request.PositionBlocking
3332import com.lambda.interaction.request.Priority
3433import com.lambda.interaction.request.RequestHandler
3534import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode
3635import com.lambda.interaction.request.breaking.BreakConfig.BreakMode
37- import com.lambda.interaction.request.hotbar.HotbarConfig
3836import com.lambda.interaction.request.hotbar.HotbarRequest
3937import com.lambda.interaction.request.placing.PlaceManager
40- import com.lambda.interaction.request.rotation.RotationConfig
4138import com.lambda.interaction.request.rotation.RotationManager.onRotate
4239import com.lambda.interaction.request.rotation.RotationManager.onRotatePost
4340import com.lambda.interaction.request.rotation.RotationRequest
@@ -121,13 +118,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
121118 if (instantBreaks.isEmpty()) return @request
122119
123120 instantBreaks.forEach { ctx ->
124- val breakInfo = with (request) {
125- handleRequestContext(
126- ctx,
127- buildConfig, rotationConfig, hotbarConfig,
128- pendingInteractionsList, onBreak, onItemDrop
129- )
130- } ? : return @request
121+ val breakInfo = handleRequestContext(ctx, request) ? : return @request
131122 if (! breakInfo.requestHotbarSwap()) return @forEach
132123 updateBlockBreakingProgress(breakInfo)
133124 activeThisTick = true
@@ -152,7 +143,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
152143 onRotate(priority = Int .MIN_VALUE ) {
153144 preEvent()
154145
155- if (! updateRequest { true } ) {
146+ if (! updateRequest() ) {
156147 requestRotate()
157148 return @onRotate
158149 }
@@ -175,14 +166,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
175166 validContexts
176167 .filter { it.instantBreak.not () }
177168 .forEach { ctx ->
178- val breakInfo = with (request) {
179- handleRequestContext(
180- ctx,
181- buildConfig, rotationConfig, hotbarConfig,
182- pendingInteractionsList, onBreak, onItemDrop
183- )
184- }
185- if (breakInfo == null ) return @request
169+ if (handleRequestContext(ctx, request) == null ) return @request
186170 }
187171 }
188172
@@ -281,17 +265,9 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
281265
282266 private fun handleRequestContext (
283267 requestCtx : BreakContext ,
284- buildConfig : BuildConfig ,
285- rotationConfig : RotationConfig ,
286- hotbarConfig : HotbarConfig ,
287- pendingInteractionsList : MutableCollection <BuildContext >,
288- onBreak : () -> Unit ,
289- onItemDrop : ((ItemEntity ) -> Unit )?
268+ request : BreakRequest
290269 ): BreakInfo ? {
291- val breakInfo = BreakInfo (requestCtx, BreakType .Primary ,
292- buildConfig.breakSettings, rotationConfig, hotbarConfig,
293- pendingInteractionsList, onBreak, onItemDrop
294- )
270+ val breakInfo = BreakInfo (requestCtx, BreakType .Primary , request)
295271 primaryBreakingInfo?.let { primaryInfo ->
296272 if (! primaryInfo.breakConfig.doubleBreak
297273 || primaryInfo.startedWithSecondary
@@ -308,12 +284,12 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
308284 secondaryBreakingInfo = primaryInfo
309285 primaryBreakingInfo = breakInfo
310286
311- setPendingInteractionsLimits(buildConfig)
287+ setPendingInteractionsLimits(request. buildConfig)
312288 return primaryBreakingInfo
313289 }
314290
315291 primaryBreakingInfo = breakInfo
316- setPendingInteractionsLimits(buildConfig)
292+ setPendingInteractionsLimits(request. buildConfig)
317293 return primaryBreakingInfo
318294 }
319295
@@ -384,10 +360,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
384360 }
385361
386362 if (info.breakConfig.particles) {
387- mc.particleManager.addBlockBreakingParticles(
388- ctx.expectedPos,
389- hitResult.side
390- )
363+ mc.particleManager.addBlockBreakingParticles(ctx.expectedPos, hitResult.side)
391364 }
392365
393366 if (info.breakConfig.breakingTexture) {
@@ -517,11 +490,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
517490 info : BreakInfo ,
518491 stage : Int = info.getBreakTextureProgress(player, world)
519492 ) {
520- world.setBlockBreakingInfo(
521- player.id,
522- info.context.expectedPos,
523- stage
524- )
493+ world.setBlockBreakingInfo(player.id, info.context.expectedPos, stage)
525494 }
526495
527496 private fun isOnBreakCooldown () = blockBreakingCooldown > 0
@@ -532,13 +501,15 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
532501 data class BreakInfo (
533502 val context : BreakContext ,
534503 var type : BreakType ,
535- val breakConfig : BreakConfig ,
536- val rotationConfig : RotationConfig ,
537- val hotbarConfig : HotbarConfig ,
538- val pendingInteractionsList : MutableCollection <BuildContext >,
539- val onBreak : () -> Unit ,
540- val onItemDrop : ((ItemEntity ) -> Unit )?
504+ val request : BreakRequest
541505 ) {
506+ val breakConfig = request.buildConfig.breakSettings
507+ val rotationConfig = request.rotationConfig
508+ private val hotbarConfig = request.hotbarConfig
509+ val pendingInteractionsList = request.pendingInteractionsList
510+ private val onBreak = request.onBreak
511+ private val onItemDrop = request.onItemDrop
512+
542513 var breaking = false
543514 var breakingTicks = 0
544515 var soundsCooldown = 0.0f
@@ -575,21 +546,14 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
575546 hotbarConfig.request(HotbarRequest (context.hotbarIndex)).done
576547
577548 fun getBreakTextureProgress (player : PlayerEntity , world : ClientWorld ): Int {
578- val breakDelta = context.checkedState.calcItemBlockBreakingDelta(
579- player,
580- world,
581- context.expectedPos,
582- player.mainHandStack
583- )
584-
549+ val breakDelta = context.checkedState.calcItemBlockBreakingDelta(player, world, context.expectedPos, player.mainHandStack)
585550 val progress = (breakDelta * breakingTicks) / breakConfig.breakThreshold
586551 return if (progress > 0.0f ) (progress * 10.0f ).toInt() else - 1
587552 }
588553
589554 fun nullify () = type.nullify()
590555
591- fun getBreakThreshold () =
592- type.getBreakThreshold(breakConfig)
556+ fun getBreakThreshold () = type.getBreakThreshold(breakConfig)
593557 }
594558
595559 enum class BreakType (val index : Int ) {
0 commit comments