Skip to content

Commit 49d6e9f

Browse files
committed
use main hand stack for render progress when swap mode is set to start as the tool won't be present again to break the block
1 parent d8de058 commit 49d6e9f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ data class BreakInfo(
128128
}
129129

130130
private fun getBreakTextureProgress(player: PlayerEntity, world: ClientWorld): Int {
131-
val breakDelta = context.cachedState.calcItemBlockBreakingDelta(player, world, context.blockPos, player.mainHandStack)
131+
val swapMode = breakConfig.swapMode
132+
val item = if (swapMode.isEnabled() && swapMode != BreakConfig.SwapMode.Start) player.inventory.getStack(context.hotbarIndex) else player.mainHandStack
133+
val breakDelta = context.cachedState.calcItemBlockBreakingDelta(player, world, context.blockPos, item)
132134
val progress = (breakDelta * breakingTicks) / (getBreakThreshold() + (breakDelta * breakConfig.fudgeFactor))
133135
return if (progress > 0.0f) (progress * 10.0f).toInt().coerceAtMost(10) else -1
134136
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@ object BreakManager : RequestHandler<BreakRequest>(
212212
.forEach { info ->
213213
val config = info.breakConfig
214214
if (!config.renders) return@listen
215+
val swapMode = info.breakConfig.swapMode
215216
val breakDelta = info.context.cachedState.calcBreakDelta(
216217
player,
217218
world,
218219
info.context.blockPos,
219220
info.breakConfig,
220-
if (!info.isRedundant && info.breakConfig.swapMode.isEnabled()) activeStack else null
221+
if (!info.isRedundant && swapMode.isEnabled() && swapMode != BreakConfig.SwapMode.Start) activeStack else null
221222
).toDouble()
222223
val currentDelta = info.breakingTicks * breakDelta
223224

0 commit comments

Comments
 (0)