Skip to content

Commit d7ac3d4

Browse files
committed
Merge branch '1.21.5' of https://github.com/Avanatiker/NeoLambda into 1.21.5
2 parents 1c71a57 + abbc93c commit d7ac3d4

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BuildSettings(
3939
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks", vis).group(*groupPath, Group.General)
4040
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis).group(*groupPath, Group.General)
4141
override val interactionsPerTick by c.setting("Interactions Per Tick", 5, 1..30, 1, "The amount of interactions that can happen per tick", visibility = vis).group(*groupPath, Group.General)
42-
override val maxPendingInteractions by c.setting("Max Pending Interactions", 1, 1..10, 1, "Dont wait for this many interactions for the server response", visibility = vis).group(*groupPath, Group.General)
42+
override val maxPendingInteractions by c.setting("Max Pending Interactions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions", visibility = vis).group(*groupPath, Group.General)
4343

4444
// Breaking
4545
override val breaking = BreakSettings(c, groupPath.toList() + Group.Break, vis)

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

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import com.lambda.interaction.request.PositionBlocking
4343
import com.lambda.interaction.request.RequestHandler
4444
import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode
4545
import com.lambda.interaction.request.breaking.BreakConfig.BreakMode
46-
import com.lambda.interaction.request.breaking.BreakInfo.BreakType
4746
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary
4847
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak
4948
import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary
@@ -174,7 +173,8 @@ object BreakManager : RequestHandler<BreakRequest>(
174173
listen<TickEvent.Post>(priority = Int.MIN_VALUE) {
175174
if (!swappedThisTick) {
176175
swappedStack = player.mainHandStack
177-
} else swappedThisTick = false
176+
}
177+
swappedThisTick = false
178178
heldTicks++
179179
if (breakCooldown > 0) {
180180
breakCooldown--
@@ -189,12 +189,10 @@ object BreakManager : RequestHandler<BreakRequest>(
189189
if (event.pos == RebreakManager.rebreak?.context?.blockPos) return@listen
190190

191191
breakInfos
192-
.filterNotNull()
193-
.firstOrNull { it.context.blockPos == event.pos }
192+
.firstOrNull { it?.context?.blockPos == event.pos }
194193
?.let { info ->
195-
val currentState = info.context.cachedState
196194
// if not broken
197-
if (isNotBroken(currentState, event.newState)) {
195+
if (isNotBroken(info.context.cachedState, event.newState)) {
198196
// update the cached state
199197
info.context.cachedState = event.newState
200198
return@listen
@@ -321,8 +319,7 @@ object BreakManager : RequestHandler<BreakRequest>(
321319

322320
// Reversed so that the breaking order feels natural to the user as the primary break is always the
323321
// last break to be started
324-
run {
325-
if (!handlePreProcessing()) return@run
322+
if (handlePreProcessing()) {
326323
activeInfos
327324
.filter { it.updatedThisTick }
328325
.asReversed()
@@ -360,15 +357,16 @@ object BreakManager : RequestHandler<BreakRequest>(
360357
.filterNotNull()
361358
.forEach { info ->
362359
newBreaks.find { ctx -> ctx.blockPos == info.context.blockPos && canAccept(ctx) }?.let { ctx ->
363-
if (!info.updatedThisTick || info.abandoned) {
364-
info.updateInfo(ctx, request)
360+
if ((!info.updatedThisTick || info.type == RedundantSecondary) || info.abandoned) {
365361
if (info.type == RedundantSecondary)
366362
info.request.onStart?.invoke(info.context.blockPos)
367363
else if (info.abandoned) {
368364
info.abandoned = false
369365
info.request.onStart?.invoke(info.context.blockPos)
370366
} else
371367
info.request.onUpdate?.invoke(info.context.blockPos)
368+
369+
info.updateInfo(ctx, request)
372370
}
373371
newBreaks.remove(ctx)
374372
return@forEach
@@ -417,14 +415,13 @@ object BreakManager : RequestHandler<BreakRequest>(
417415

418416
infos.forEach { it.updatePreProcessing(player, world) }
419417

420-
if (swappedThisTick) return true
421-
422418
infos.firstOrNull()?.let { info ->
423-
infos.firstOrNull { it.shouldSwap && it.shouldProgress }?.let { last ->
419+
infos.lastOrNull { it.shouldSwap && it.shouldProgress }?.let { last ->
424420
val minSwapTicks = max(info.minSwapTicks, last.minSwapTicks)
425421
if (!info.context.requestSwap(info.request, minSwapTicks))
426422
return false
427-
if (minSwapTicks > 0) swappedStack = info.swapStack
423+
if (minSwapTicks > 0)
424+
swappedStack = info.swapStack
428425
}
429426
}
430427
}
@@ -540,7 +537,7 @@ object BreakManager : RequestHandler<BreakRequest>(
540537
.forEach { info ->
541538
if (info.type == RedundantSecondary && !info.progressedThisTick) {
542539
val cachedState = info.context.cachedState
543-
if (cachedState.isEmpty || cachedState.isAir) {
540+
if (cachedState.isEmpty) {
544541
info.nullify()
545542
return@forEach
546543
}
@@ -675,13 +672,8 @@ object BreakManager : RequestHandler<BreakRequest>(
675672
/**
676673
* Nullifies the break. If the block is not broken, the [BreakInfo.internalOnCancel] callback gets triggered
677674
*/
678-
private fun BreakInfo.nullify() = type.nullify()
679-
680-
/**
681-
* Nullifies the [BreakInfo] reference in the [breakInfos] array based on the [BreakType]
682-
*/
683-
private fun BreakType.nullify() =
684-
when (this) {
675+
private fun BreakInfo.nullify() =
676+
when (type) {
685677
Primary, Rebreak -> primaryBreak = null
686678
else -> secondaryBreak = null
687679
}
@@ -726,7 +718,7 @@ object BreakManager : RequestHandler<BreakRequest>(
726718
}
727719

728720
val blockState = blockState(ctx.blockPos)
729-
if (blockState.isEmpty || blockState.isAir) {
721+
if (blockState.isEmpty) {
730722
info.nullify()
731723
info.request.onCancel?.invoke(ctx.blockPos)
732724
return false

0 commit comments

Comments
 (0)