Skip to content

Commit 0700e5b

Browse files
committed
more specific context sorting in contextual context managers
1 parent bf3fc35 commit 0700e5b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
129129

130130
val validContexts = request.contexts
131131
.filter { ctx -> canAccept(ctx) }
132-
.sortedBy { it.instantBreak }
132+
.sortedWith(
133+
compareByDescending<BreakContext> { it.instantBreak }
134+
.thenByDescending { it.hotbarIndex == HotbarManager.serverSlot }
135+
)
133136
.take(maxBreaksThisTick)
134137

135138
val instantBreaks = validContexts
136139
.take(breakConfig.instantBreaksPerTick)
137140
.filter { it.instantBreak }
138-
.sortedBy { it.hotbarIndex == HotbarManager.serverSlot }
139141

140142
if (instantBreaks.isNotEmpty()) {
141143
instantBreaks.forEach { ctx ->

common/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
117117
val currentHotbarIndex = HotbarManager.serverSlot
118118
val placeContexts = request.placeContexts
119119
.filter { canPlace(it) }
120-
.sortedBy { isSneaking == it.sneak && currentHotbarIndex == it.hotbarIndex }
120+
.sortedWith(
121+
compareByDescending<PlaceContext> { it.hotbarIndex == currentHotbarIndex }
122+
.thenByDescending { it.sneak == isSneaking }
123+
)
121124
.take(takeCount)
122125

123126
rotation = if (placeConfig.rotateForPlace || placeConfig.axisRotate) {

0 commit comments

Comments
 (0)