Skip to content

Commit 1fa8c74

Browse files
committed
corrected break / place manager rotations to show an underlying issue
1 parent 9a5ba9e commit 1fa8c74

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
8989
get() = breakingInfos.mapNotNull { it?.context?.expectedPos } + pendingBreaks.map { it.context.expectedPos }
9090

9191
private var rotation: RotationRequest? = null
92-
private var validRotation = false
92+
private val validRotation
93+
get() = rotation?.done ?: true
9394

9495
private var blockBreakingCooldown = 0
9596

@@ -160,7 +161,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
160161
}
161162

162163
requestRotate()
163-
if (!validRotation && rotation != null) {
164+
if (!validRotation) {
164165
postEvent()
165166
return@listen
166167
}
@@ -179,10 +180,6 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
179180
postEvent()
180181
}
181182

182-
listen<UpdateManagerEvent.Rotation.Post>(priority = Int.MIN_VALUE + 1) {
183-
validRotation = rotation?.done ?: true
184-
}
185-
186183
listen<WorldEvent.BlockUpdate.Server>(priority = Int.MIN_VALUE + 1) { event ->
187184
pendingBreaks
188185
.firstOrNull { it.context.expectedPos == event.pos }

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
7171
}
7272

7373
private var rotation: RotationRequest? = null
74-
private var validRotation = false
7574

7675
private var shouldCrouch = false
7776

@@ -125,13 +124,6 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
125124
)
126125
.take(takeCount)
127126

128-
rotation = if (placeConfig.rotateForPlace || placeConfig.axisRotate) {
129-
placeContexts.firstOrNull()?.let { ctx ->
130-
if (ctx.rotation.target.angleDistance == 0.0) null
131-
else request.rotationConfig.request(ctx.rotation)
132-
}
133-
} else null
134-
135127
placeContexts.forEach { ctx ->
136128
val notSneaking = !player.isSneaking
137129
val hotbarRequest = request.hotbarConfig.request(HotbarRequest(ctx.hotbarIndex))
@@ -140,8 +132,9 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
140132
postEvent()
141133
return@listen
142134
}
143-
rotation?.let { rotation ->
144-
if (rotation !== ctx.rotation || !validRotation) {
135+
if ((placeConfig.rotateForPlace || placeConfig.axisRotate)) {
136+
rotation = request.rotationConfig.request(ctx.rotation)
137+
if (!ctx.rotation.target.verify()) {
145138
postEvent()
146139
return@listen
147140
}
@@ -162,10 +155,6 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
162155
postEvent()
163156
}
164157

165-
listen<UpdateManagerEvent.Rotation.Post>(priority = Int.MIN_VALUE) {
166-
validRotation = rotation?.done ?: true
167-
}
168-
169158
listen<MovementEvent.InputUpdate>(priority = Int.MIN_VALUE) {
170159
if (shouldCrouch) {
171160
shouldCrouch = false

common/src/main/kotlin/com/lambda/interaction/request/rotation/RotationRequest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.lambda.interaction.request.rotation
1919

2020
import com.lambda.interaction.request.Priority
2121
import com.lambda.interaction.request.Request
22-
import com.lambda.interaction.request.rotation.Rotation.Companion.dist
2322
import com.lambda.interaction.request.rotation.visibilty.RotationTarget
2423
import com.lambda.threading.runSafe
2524

@@ -41,6 +40,6 @@ data class RotationRequest(
4140

4241
override val done: Boolean get() =
4342
mode == RotationMode.None || runSafe {
44-
target.verify(target)
43+
target.verify()
4544
} == true
4645
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/visibilty/RotationTarget.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.lambda.util.collections.updatableLazy
3535
*/
3636
data class RotationTarget(
3737
val hit: RequestedHit? = null,
38-
val verify: RotationTarget.() -> Boolean = { hit?.verifyRotation() ?: true },
38+
val verify: () -> Boolean = { hit?.verifyRotation() ?: true },
3939
private val buildRotation: SafeContext.() -> Rotation?,
4040
) {
4141
val targetRotation = updatableLazy {

0 commit comments

Comments
 (0)