@@ -78,15 +78,15 @@ object BreakManager : RequestHandler<BreakRequest>() {
7878 if (! canAccept(requestCtx)) {
7979 return @forEach
8080 }
81- val infoIndex = handleRequestContext(
81+ val breakType = handleRequestContext(
8282 requestCtx,
8383 request.onBreak,
8484 request.buildConfig,
8585 request.rotationConfig
8686 )
87- if (infoIndex == - 1 ) return @request
87+ if (breakType == BreakType . Null ) return @request
8888 if (requestCtx.instantBreak && instaBreaks < request.buildConfig.breakSettings.breaksPerTick) {
89- breakingInfos.getOrNull(infoIndex )?.let { info ->
89+ breakingInfos.getOrNull(breakType.index )?.let { info ->
9090 updateBlockBreakingProgress(info, player.mainHandStack)
9191 instaBreaks++
9292 }
@@ -143,47 +143,42 @@ object BreakManager : RequestHandler<BreakRequest>() {
143143 onBreak : () -> Unit ,
144144 buildConfig : BuildConfig ,
145145 rotationConfig : RotationConfig
146- ): Int {
146+ ): BreakType {
147147 primaryBreakingInfo?.let { primaryInfo ->
148- if (! primaryInfo.breakConfig.doubleBreak) return - 1
149- if (primaryInfo.startedWithSecondary) return - 1
148+ if (! primaryInfo.breakConfig.doubleBreak) return BreakType . Null
149+ if (primaryInfo.startedWithSecondary) return BreakType . Null
150150 if (! primaryInfo.breaking) {
151151 secondaryBreakingInfo = BreakInfo (
152152 requestCtx,
153- BreakInfo . BreakType .Secondary ,
153+ BreakType .Secondary ,
154154 onBreak,
155155 buildConfig.breakSettings,
156156 rotationConfig
157157 )
158- return 1
158+ return BreakType . Secondary
159159 } else {
160- primaryInfo.type = BreakInfo . BreakType .Secondary
160+ primaryInfo.type = BreakType .Secondary
161161 secondaryBreakingInfo = primaryInfo
162162 primaryBreakingInfo = BreakInfo (
163163 requestCtx,
164- BreakInfo . BreakType .Primary ,
164+ BreakType .Primary ,
165165 onBreak,
166166 buildConfig.breakSettings,
167167 rotationConfig
168- ).apply {
169- startedWithSecondary = true
170- }
171- return 0
168+ )
169+ return BreakType .Primary
172170 }
173171 } ? : run {
174172 primaryBreakingInfo = BreakInfo (
175173 requestCtx,
176- BreakInfo . BreakType .Primary ,
174+ BreakType .Primary ,
177175 onBreak,
178176 buildConfig.breakSettings,
179177 rotationConfig
180- ).apply {
181- if (secondaryBreakingInfo != null )
182- startedWithSecondary = true
183- }
178+ )
184179 pendingInteractions.setMaxSize(buildConfig.maxPendingInteractions)
185180 pendingInteractions.setDecayTime(buildConfig.interactionTimeout * 50L )
186- return 0
181+ return BreakType . Primary
187182 }
188183 }
189184
@@ -305,7 +300,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
305300 if (info.breakConfig.breakingTexture) {
306301 setBreakingTextureStage(info)
307302 }
308- if (info.type == BreakInfo . BreakType . Secondary )
303+ if (secondaryBreakingInfo != null )
309304 primaryBreakingInfo?.startedWithSecondary = true
310305 }
311306
@@ -412,22 +407,25 @@ object BreakManager : RequestHandler<BreakRequest>() {
412407
413408 fun getBreakThreshold () =
414409 type.getBreakThreshold(breakConfig)
410+ }
415411
416- enum class BreakType {
417- Primary ,
418- Secondary ;
412+ enum class BreakType (val index : Int ) {
413+ Primary (0 ),
414+ Secondary (1 ),
415+ Null (- 1 );
419416
420- fun getBreakThreshold (breakConfig : BreakConfig ) =
421- when (this ) {
422- Primary -> breakConfig.breakThreshold
423- Secondary -> 1.0f
424- }
417+ fun getBreakThreshold (breakConfig : BreakConfig ) =
418+ when (this ) {
419+ Primary -> breakConfig.breakThreshold
420+ Secondary -> 1.0f
421+ else -> - 1.0f
422+ }
425423
426- fun nullify () =
427- when (this ) {
428- Primary -> primaryBreakingInfo = null
429- Secondary -> secondaryBreakingInfo = null
430- }
431- }
424+ fun nullify () =
425+ when (this ) {
426+ Primary -> primaryBreakingInfo = null
427+ Secondary -> secondaryBreakingInfo = null
428+ else -> { }
429+ }
432430 }
433431}
0 commit comments