@@ -59,9 +59,14 @@ object PacketMine : Module(
5959 private var itemDrops = 0
6060
6161 private val breakingPositions = arrayOfNulls<BlockPos >(2 )
62- private var hitPos: BlockPos ? = null
62+
63+ private var requestedThisTick = false
6364
6465 init {
66+ listen<TickEvent .Post > {
67+ requestedThisTick = false
68+ }
69+
6570 listen<PlayerEvent .Attack .Block > { it.cancel() }
6671 listen<PlayerEvent .Breaking .Update > { event ->
6772 event.cancel()
@@ -70,24 +75,29 @@ object PacketMine : Module(
7075 breakingPositions[1 ] = breakingPositions[0 ]
7176 }
7277 breakingPositions[0 ] = null
73- hitPos = event.pos
78+ sendBreakRequest( event.pos)
7479 }
7580
76- listen<TickEvent .Pre > {
77- val requestPositions = arrayListOf<BlockPos >().apply { addAll(breakingPositions.filterNotNull()) }
78- hitPos?.let { pos ->
79- requestPositions.add(pos)
80- hitPos = null
81- }
81+ listen<TickEvent .Input .Pre > {
82+ if (! requestedThisTick) sendBreakRequest()
83+ }
84+ }
8285
83- val request = BreakRequest (
84- breakContexts(requestPositions), build, rotation, hotbar, pendingInteractions = pendingInteractionsList, onAccept = { breakingPositions[0 ] = it },
85- onCancel = { nullifyBreakPos(it) },
86- onBreak = { breaks++ ; nullifyBreakPos(it) },
87- { _ -> itemDrops++ }
88- )
89- breakConfig.request(request)
86+ private fun SafeContext.sendBreakRequest (hitPos : BlockPos ? = null) {
87+ val requestPositions = arrayListOf (* breakingPositions.filterNotNull().toTypedArray())
88+ hitPos?.let { pos ->
89+ requestPositions.add(pos)
9090 }
91+
92+ val request = BreakRequest (
93+ breakContexts(requestPositions), build, rotation, hotbar, pendingInteractions = pendingInteractionsList,
94+ onAccept = { breakingPositions[0 ] = it },
95+ onCancel = { nullifyBreakPos(it) },
96+ onBreak = { breaks++ ; nullifyBreakPos(it) },
97+ { _ -> itemDrops++ }
98+ )
99+ breakConfig.request(request)
100+ requestedThisTick = true
91101 }
92102
93103 private fun nullifyBreakPos (pos : BlockPos ) {
0 commit comments