Skip to content

Commit 93c5831

Browse files
committed
test players rotation before simulating axis rotations
1 parent a358fca commit 93c5831

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ data class PlaceContext(
7878
withState(blockState(result.blockPos), result.blockPos, sideColor, result.side)
7979
}
8080

81-
override fun shouldRotate(config: BuildConfig) = config.placing.rotate
81+
override fun shouldRotate(config: BuildConfig) = config.placing.rotateForPlace
8282

8383
fun requestDependencies(request: PlaceRequest): Boolean {
8484
val hotbarRequest = request.hotbar.request(HotbarRequest(hotbarIndex, request.hotbar), false)
85-
val validRotation = if (request.build.placing.rotate) {
85+
val validRotation = if (request.build.placing.rotateForPlace) {
8686
request.rotation.request(rotation, false).done && !currentDirIsInvalid
8787
} else true
8888
return hotbarRequest.done && validRotation

common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ object BuildSimulator {
295295
}
296296

297297
lateinit var resultState: BlockState
298-
var rot = RotationManager.serverRotation
298+
var rot = fakePlayer.rotation
299299

300300
val simulatePlaceState = placeState@ {
301301
resultState = blockItem.getPlacementState(context)
@@ -311,7 +311,7 @@ object BuildSimulator {
311311
}
312312

313313
val currentDirIsInvalid = simulatePlaceState()?.let { basePlaceResult ->
314-
if (!place.rotate) {
314+
if (!place.rotateForPlace) {
315315
acc.add(basePlaceResult)
316316
return@forEach
317317
}
@@ -329,6 +329,12 @@ object BuildSimulator {
329329
return@rotate
330330
}
331331

332+
fakePlayer.rotation = player.rotation
333+
simulatePlaceState() ?: run {
334+
rot = fakePlayer.rotation
335+
return@rotate
336+
}
337+
332338
if (currentDirIsInvalid) {
333339
PlaceDirection.entries.asReversed().forEachIndexed direction@ { index, direction ->
334340
fakePlayer.rotation = direction.rotation

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.lambda.interaction.request.placing
1919

2020
import com.lambda.config.groups.BuildConfig
21-
import com.lambda.config.groups.TickStage
2221
import com.lambda.event.Event
2322
import com.lambda.interaction.request.Priority
2423
import com.lambda.interaction.request.RequestConfig
@@ -27,12 +26,10 @@ abstract class PlaceConfig(
2726
priority: Priority
2827
) : RequestConfig<PlaceRequest>(priority) {
2928
abstract val rotateForPlace: Boolean
30-
val rotate
31-
get() = rotateForPlace || axisRotate
3229
abstract val airPlace: AirPlaceMode
3330
protected abstract val axisRotateSetting: Boolean
3431
val axisRotate
35-
get() = airPlace.isEnabled() && axisRotateSetting
32+
get() = rotateForPlace && airPlace.isEnabled() && axisRotateSetting
3633
abstract val placeStageMask: Set<Event>
3734
abstract val placeConfirmationMode: PlaceConfirmationMode
3835
abstract val maxPendingPlacements: Int

common/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class BuildTask @Ta5kBuilder constructor(
100100
TaskFlowModule.drawables = results
101101
.filterIsInstance<Drawable>()
102102
.plus(pendingInteractions.toList())
103-
.toMutableList()
104103

105104
val resultsNotBlocked = results
106105
.filter { result -> pendingInteractions.none { it.expectedPos == result.blockPos } }
@@ -143,10 +142,9 @@ class BuildTask @Ta5kBuilder constructor(
143142
val requestContexts = arrayListOf<BreakContext>()
144143

145144
if (build.breaking.breaksPerTick > 1) {
146-
val take = emptyPendingInteractionSlots.coerceAtLeast(0)
147145
breakResults
148146
.filter { it.context.instantBreak }
149-
.take(take)
147+
.take(emptyPendingInteractionSlots)
150148
.let { instantBreakResults ->
151149
requestContexts.addAll(instantBreakResults.map { it.context })
152150
}

0 commit comments

Comments
 (0)