Skip to content

Commit 2f28e0a

Browse files
committed
generally prefer primary breaks item stack for usage, but secondary for min keep ticks
1 parent e463725 commit 2f28e0a

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ data class BreakInfo(
128128
}
129129
}
130130

131-
enum class BreakType(val index: Int) {
132-
Primary(0),
133-
Secondary(1),
134-
RedundantSecondary(2),
135-
ReBreak(2);
131+
enum class BreakType() {
132+
Primary,
133+
Secondary,
134+
RedundantSecondary,
135+
ReBreak;
136136

137137
fun getBreakThreshold(breakConfig: BreakConfig) =
138138
when (this) {

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,25 @@ object BreakManager : RequestHandler<BreakRequest>(
288288
if (instantBreaks.isEmpty()) rotation.submit(false) else rotation
289289
}
290290
}
291+
.also {
292+
it.firstOrNull()?.let { info ->
293+
val minKeepTicks = secondaryBreak?.let { secondary ->
294+
val breakDelta = secondary.context.cachedState.calcBreakDelta(
295+
player,
296+
world,
297+
secondary.context.blockPos,
298+
secondary.breakConfig,
299+
player.inventory.getStack(secondary.context.hotbarIndex)
300+
)
301+
val breakAmount = breakDelta * (secondary.breakingTicks + 1)
302+
if (breakAmount >= 1.0f) 1 else 0
303+
} ?: 0
304+
if (!info.context.requestDependencies(info.request, minKeepTicks)) return@run
305+
}
306+
}
291307
.asReversed()
292308
.forEach { info ->
293309
if (info.progressedThisTick) return@forEach
294-
val minKeepTicks = if (info.isSecondary) {
295-
val breakDelta = info.context.cachedState.calcBreakDelta(
296-
player,
297-
world,
298-
info.context.blockPos,
299-
info.breakConfig,
300-
player.inventory.getStack(info.context.hotbarIndex)
301-
)
302-
val breakAmount = breakDelta * (info.breakingTicks + 1)
303-
if (breakAmount >= 1.0f) 1 else 0
304-
} else 0
305-
if (!info.context.requestDependencies(info.request, minKeepTicks)) return@run
306310
if (tickStage !in info.breakConfig.breakStageMask) return@forEach
307311
if (!rotated && info.isPrimary) return@run
308312

0 commit comments

Comments
 (0)