Skip to content

Commit 871eb69

Browse files
committed
- swapped current mining block to an array in prep for double break
1 parent d1e613c commit 871eb69

File tree

1 file changed

+18
-17
lines changed
  • common/src/main/kotlin/com/lambda/module/modules/player

1 file changed

+18
-17
lines changed

common/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ object PacketMine : Module(
222222
}
223223

224224
val renderer = DynamicESP
225-
private var currentMiningBlock: BreakingContext? = null
225+
private var currentMiningBlock = Array<BreakingContext?>(2) { null }
226226
private var lastNonEmptyState: BlockState? = null
227227
private val blockQueue = ArrayDeque<BlockPos>()
228228
private var queueBreakStartCounter = 0
@@ -268,7 +268,7 @@ object PacketMine : Module(
268268
return@listener
269269
}
270270

271-
currentMiningBlock?.apply {
271+
currentMiningBlock[0]?.apply {
272272
if (it.pos != pos || breakState != BreakState.ReBreaking || !reBreak.isStandard()) return@apply
273273

274274
if (miningProgress < breakThreshold) return@listener
@@ -301,7 +301,7 @@ object PacketMine : Module(
301301
if (breakNextQueueBlock()) return@listener
302302
}
303303

304-
currentMiningBlock?.apply {
304+
currentMiningBlock[0]?.apply {
305305
mineTicks++
306306

307307
val activeState = pos.blockState(world)
@@ -420,7 +420,7 @@ object PacketMine : Module(
420420
}
421421

422422
listener<WorldEvent.BlockUpdate> {
423-
currentMiningBlock?.apply {
423+
currentMiningBlock[0]?.apply {
424424
if (it.pos != pos || !isStateBroken(pos.blockState(world), it.state)) return@listener
425425

426426
runHandlers(ProgressStage.PacketReceiveBreak, pos, lastValidBestTool)
@@ -486,7 +486,7 @@ object PacketMine : Module(
486486
listener<RenderEvent.World> {
487487
renderer.clear()
488488

489-
currentMiningBlock?.apply {
489+
currentMiningBlock[0]?.apply {
490490
buildRenders()
491491
}
492492

@@ -532,7 +532,8 @@ object PacketMine : Module(
532532
}
533533

534534
onDisable {
535-
currentMiningBlock = null
535+
currentMiningBlock[0] = null
536+
currentMiningBlock[1] = null
536537
lastNonEmptyState = null
537538
blockQueue.clear()
538539
queueBreakStartCounter = 0
@@ -557,7 +558,7 @@ object PacketMine : Module(
557558
}
558559

559560
private fun SafeContext.startBreaking(pos: BlockPos) {
560-
if (currentMiningBlock?.pos == pos || blockQueue.contains(pos)) return
561+
if (currentMiningBlock[0]?.pos == pos || blockQueue.contains(pos)) return
561562

562563
val state = pos.blockState(world)
563564
val bestTool = getBestTool(state, pos)
@@ -575,7 +576,7 @@ object PacketMine : Module(
575576
runBetweenHandlers(ProgressStage.StartPre, ProgressStage.StartPost, pos, { bestTool }, instaBroken = instaBreak) {
576577
packetStartBreak(pos)
577578

578-
currentMiningBlock = BreakingContext(pos, state, BreakState.Breaking, breakDelta, bestTool)
579+
currentMiningBlock[0] = BreakingContext(pos, state, BreakState.Breaking, breakDelta, bestTool)
579580

580581
if (!instaBreak) return@runBetweenHandlers
581582

@@ -629,7 +630,7 @@ object PacketMine : Module(
629630
if (rotate.isConstant()
630631
&& !rotated
631632
&& !empty
632-
&& (currentMiningBlock?.breakState != BreakState.ReBreaking
633+
&& (currentMiningBlock[0]?.breakState != BreakState.ReBreaking
633634
|| !reBreak.isStandard()
634635
)
635636
) {
@@ -706,7 +707,7 @@ object PacketMine : Module(
706707

707708
when (progressStage) {
708709
ProgressStage.PreTick -> {
709-
currentMiningBlock?.apply {
710+
currentMiningBlock[0]?.apply {
710711
if (swingMode.isConstant() && breakState == BreakState.Breaking) {
711712
swingMainHand()
712713
}
@@ -873,7 +874,7 @@ object PacketMine : Module(
873874
player.eyePos.distanceTo(vec) > range
874875

875876
private fun SafeContext.onBlockBreak(packetReceiveBreak: Boolean) {
876-
currentMiningBlock?.apply {
877+
currentMiningBlock[0]?.apply {
877878
if (!isOutOfRange(pos.toCenterPos()) || packetReceiveBreak) {
878879
checkClientSideBreak(packetReceiveBreak, pos)
879880
}
@@ -904,12 +905,12 @@ object PacketMine : Module(
904905
}
905906

906907
private fun SafeContext.nullifyCurrentBreakingBlock() {
907-
currentMiningBlock?.apply {
908+
currentMiningBlock[0]?.apply {
908909
if (breakingAnimation) world.setBlockBreakingInfo(player.id, pos, -1)
909910
runHandlers(ProgressStage.TimedOut, pos, lastValidBestTool)
910911
}
911912

912-
currentMiningBlock = null
913+
currentMiningBlock[0] = null
913914
}
914915

915916
private fun isStateBroken(previousState: BlockState?, activeState: BlockState): Boolean {
@@ -938,9 +939,9 @@ object PacketMine : Module(
938939

939940
private fun shouldBePlacedInBlockQueue(pos: BlockPos): Boolean =
940941
queueBlocks
941-
&& currentMiningBlock != null
942-
&& currentMiningBlock?.breakState != BreakState.ReBreaking
943-
&& currentMiningBlock?.pos != pos
942+
&& currentMiningBlock[0] != null
943+
&& currentMiningBlock[0]?.breakState != BreakState.ReBreaking
944+
&& currentMiningBlock[0]?.pos != pos
944945
&& !blockQueue.contains(pos)
945946

946947
private fun SafeContext.breakNextQueueBlock(): Boolean {
@@ -951,7 +952,7 @@ object PacketMine : Module(
951952
blockQueue.remove(this)
952953
startBreaking(this)
953954
} else {
954-
currentMiningBlock = null
955+
currentMiningBlock[0] = null
955956
awaitingQueueBreak = true
956957
}
957958
return true

0 commit comments

Comments
 (0)