Skip to content

Commit 1951207

Browse files
committed
more air place build sim checks
1 parent 5e9b892 commit 1951207

File tree

1 file changed

+14
-2
lines changed
  • common/src/main/kotlin/com/lambda/interaction/construction/simulation

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,27 @@ object BuildSimulator {
191191
}
192192

193193
scanSurfaces(box, sides, interact.resolution, preprocessing.surfaceScan) { _, vec ->
194-
if (eye distSq vec > reachSq) {
194+
val distSquared = eye distSq vec
195+
if (distSquared > reachSq) {
195196
misses.add(vec)
196197
return@scanSurfaces
197198
}
198199

199200
val newRotation = eye.rotationTo(vec)
200201

201202
val hit = if (interact.strictRayCast) {
202-
newRotation.rayCast(interact.interactReach, eye)?.blockResult
203+
val rayCast = newRotation.rayCast(interact.interactReach, eye)
204+
when {
205+
rayCast != null && (!place.airPlace.isEnabled() || eye distSq rayCast.pos <= distSquared) ->
206+
rayCast.blockResult
207+
208+
place.airPlace.isEnabled() -> {
209+
val hitVec = newRotation.castBox(box, interact.interactReach, eye)
210+
BlockHitResult(hitVec, hitSide, hitPos, false)
211+
}
212+
213+
else -> null
214+
}
203215
} else {
204216
val hitVec = newRotation.castBox(box, interact.interactReach, eye)
205217
BlockHitResult(hitVec, hitSide, hitPos, false)

0 commit comments

Comments
 (0)