Skip to content

Commit 7b0c246

Browse files
committed
was dumb and didnt fix renders the way i thought i did. Also only reset breaking texture if redundant or primary when cancelling
1 parent c3ade02 commit 7b0c246

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ data class BreakInfo(
101101

102102
private fun getBreakTextureProgress(player: PlayerEntity, world: ClientWorld): Int {
103103
val breakDelta = context.cachedState.calcItemBlockBreakingDelta(player, world, context.blockPos, player.mainHandStack)
104-
val progress = (breakDelta * breakingTicks) / getBreakThreshold()
105-
return if (progress > 0.0f) (progress * 10.0f).toInt() else -1
104+
val progress = (breakDelta * breakingTicks) / (getBreakThreshold() + (breakDelta * breakConfig.fudgeFactor))
105+
return if (progress > 0.0f) (progress * 10.0f).toInt().coerceAtMost(10) else -1
106106
}
107107

108108
fun getBreakThreshold() = type.getBreakThreshold(breakConfig)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,8 @@ object BreakManager : RequestHandler<BreakRequest>(
229229
info.breakConfig,
230230
if (!info.isRedundant) player.inventory.getStack(info.context.hotbarIndex) else null
231231
)
232-
val progress = (info.breakingTicks * breakDelta).let {
233-
if (info.isPrimary) it * (2 - info.breakConfig.breakThreshold)
234-
else it
235-
}.toDouble() * (1 - (breakDelta * config.fudgeFactor))
232+
val threshold = if (info.isPrimary) info.breakConfig.breakThreshold else 1f
233+
val progress = (info.breakingTicks * breakDelta).toDouble() / (threshold + (breakDelta * config.fudgeFactor))
236234
val state = info.context.cachedState
237235
val boxes = state.getOutlineShape(world, info.context.blockPos).boundingBoxes.map {
238236
it.offset(info.context.blockPos)
@@ -562,17 +560,19 @@ object BreakManager : RequestHandler<BreakRequest>(
562560
private fun BreakInfo.cancelBreak() =
563561
runSafe {
564562
if (isRedundant || abandoned) return@runSafe
565-
setBreakingTextureStage(player, world, -1)
566563
if (isPrimary) {
567564
if (breaking) abortBreakPacket(world, interaction)
568565
nullify()
566+
setBreakingTextureStage(player, world, -1)
569567
request.onCancel?.invoke(context.blockPos)
570568
} else if (isSecondary) {
571569
if (breakConfig.unsafeCancels) {
572570
makeRedundant()
571+
setBreakingTextureStage(player, world, -1)
573572
request.onCancel?.invoke(context.blockPos)
573+
} else {
574+
abandoned = true
574575
}
575-
else abandoned = true
576576
}
577577
}
578578

0 commit comments

Comments
 (0)