Skip to content

Commit 5a2cf1f

Browse files
committed
check by not null count in PacketMine and account for multiple different hotbar index requiring contexts within the same request
1 parent 4800ed2 commit 5a2cf1f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ object BreakManager : RequestHandler<BreakRequest>(
325325
val newBreaks = request.contexts
326326
.distinctBy { it.blockPos }
327327
.filter { ctx -> canAccept(ctx, request.build.breaking) }
328+
.let { acceptable ->
329+
acceptable.firstOrNull()?.let { first ->
330+
acceptable.filter { it.hotbarIndex == first.hotbarIndex }
331+
} ?: acceptable
332+
}
328333
.toMutableList()
329334

330335
// Update the current break infos or cancel if abandoned

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ object PacketMine : Module(
171171
}
172172

173173
private fun SafeContext.requestBreakManager(requestPositions: Collection<BlockPos?>, reBreaking: Boolean = false) {
174-
if (requestPositions.isEmpty()) return
174+
if (requestPositions.count { it != null } <= 0) return
175175
val breakContexts = breakContexts(requestPositions)
176176
if (!reBreaking) {
177177
queuePositions.retainAllPositions(breakContexts)

0 commit comments

Comments
 (0)