Skip to content

Commit 52b051a

Browse files
committed
no silent swapping for primary breaks
>:( Yet another thing ruined...
1 parent 10bf9cd commit 52b051a

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ data class BreakInfo(
107107
if (!shouldProgress) return false
108108
val item = player.inventory.getStack(context.hotbarIndex)
109109
val breakDelta = context.cachedState.calcItemBlockBreakingDelta(player, world, context.blockPos, item)
110-
val breakProgress = breakDelta * ((breakingTicks + 1) - breakConfig.fudgeFactor).let {
111-
if (isSecondary) it + 1 else it
112-
}
110+
val breakProgress = breakDelta * (breakingTicks + 1)
113111
return if (couldReBreak.value == true)
114112
breakConfig.swapMode.isEnabled()
115113
else when (breakConfig.swapMode) {

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

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
7171
import com.lambda.util.BlockUtils.isEmpty
7272
import com.lambda.util.BlockUtils.isNotBroken
7373
import com.lambda.util.BlockUtils.isNotEmpty
74+
import com.lambda.util.Communication.info
7475
import com.lambda.util.extension.partialTicks
7576
import com.lambda.util.item.ItemUtils.block
7677
import com.lambda.util.math.lerp
@@ -298,41 +299,40 @@ object BreakManager : RequestHandler<BreakRequest>(
298299
if (instantBreaks.isEmpty()) rotation.submit(false) else rotation
299300
}
300301
}
301-
.also {
302+
.also {
302303
it.forEach {
303304
it.couldReBreak.update()
304305
it.shouldProgress = !it.progressedThisTick &&
305306
tickStage in it.breakConfig.breakStageMask &&
306307
(rotated || !it.isPrimary)
307308
}
308309
}
310+
.asReversed()
309311
.also {
310-
if (breakInfos.none { it?.shouldSwap(player, world) == true }) return@also
311-
312-
it.firstOrNull()?.let { info ->
313-
secondaryBreak?.let { secondary ->
314-
val breakDelta = secondary.context.cachedState.calcBreakDelta(
315-
player,
316-
world,
317-
secondary.context.blockPos,
318-
secondary.breakConfig,
319-
player.inventory.getStack(secondary.context.hotbarIndex)
320-
)
321-
val breakAmount = breakDelta * ((secondary.breakingTicks - secondary.breakConfig.fudgeFactor) + 1)
322-
val minKeepTicks = if (breakAmount >= 1.0f) 1 else 0
323-
if (!info.context.requestSwap(info.request, minKeepTicks)) {
324-
secondary.serverBreakTicks = 0
325-
return@run
326-
}
327-
if (minKeepTicks > 0) {
328-
secondary.serverBreakTicks++
329-
}
330-
return@also
312+
it.firstOrNull { it.shouldSwap(player, world) }?.let { info ->
313+
val breakDelta = info.context.cachedState.calcBreakDelta(
314+
player,
315+
world,
316+
info.context.blockPos,
317+
info.breakConfig,
318+
player.inventory.getStack(info.context.hotbarIndex)
319+
)
320+
val breakAmount = breakDelta * info.breakingTicks
321+
val minKeepTicks = if (breakAmount >= info.getBreakThreshold() &&
322+
info.serverBreakTicks < info.breakConfig.fudgeFactor)
323+
{
324+
1
325+
} else 0
326+
327+
if (!info.context.requestSwap(info.request, minKeepTicks)) {
328+
info.serverBreakTicks = 0
329+
return@run
330+
}
331+
if (minKeepTicks > 0) {
332+
info.serverBreakTicks++
331333
}
332-
if (!info.context.requestSwap(info.request)) return@run
333334
}
334335
}
335-
.asReversed()
336336
.forEach { info ->
337337
if (!info.shouldProgress) return@forEach
338338
updateBreakProgress(info)
@@ -640,6 +640,8 @@ object BreakManager : RequestHandler<BreakRequest>(
640640
val config = info.breakConfig
641641
val ctx = info.context
642642

643+
info.progressedThisTick = true
644+
643645
if (!info.breaking) {
644646
if (!startBreaking(info)) {
645647
info.nullify()
@@ -653,7 +655,6 @@ object BreakManager : RequestHandler<BreakRequest>(
653655
return true
654656
}
655657

656-
info.progressedThisTick = true
657658
val hitResult = ctx.result
658659

659660
if (gamemode.isCreative && world.worldBorder.contains(ctx.blockPos)) {
@@ -710,7 +711,7 @@ object BreakManager : RequestHandler<BreakRequest>(
710711
}
711712

712713
val swing = config.swing
713-
if (overBreakThreshold && (!info.isSecondary || info.serverBreakTicks >= info.breakConfig.fudgeFactor + 1)) {
714+
if (overBreakThreshold && info.serverBreakTicks >= info.breakConfig.fudgeFactor) {
714715
if (info.isPrimary) {
715716
onBlockBreak(info)
716717
info.stopBreakPacket(world, interaction)

0 commit comments

Comments
 (0)