Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 992914e

Browse files
committed
fix!: coerce
1 parent 3f0d1bf commit 992914e

File tree

1 file changed

+7
-3
lines changed
  • src/main/kotlin/scpsharp/util

1 file changed

+7
-3
lines changed

src/main/kotlin/scpsharp/util/Math.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ import net.minecraft.util.math.BlockBox
55
import net.minecraft.util.math.BlockPos
66
import net.minecraft.util.math.Direction
77
import net.minecraft.util.math.Vec3i
8+
import kotlin.math.max
9+
import kotlin.math.min
810

911
fun BlockBox(pos1: BlockPos, pos2: BlockPos): BlockBox =
1012
BlockBox.create(Vec3i(pos1.x, pos1.y, pos1.z), Vec3i(pos2.x, pos2.y, pos2.z))
1113

12-
@Suppress("DEPRECATION")
13-
operator fun BlockBox.plus(box: BlockBox): BlockBox = encompass(box)
14+
operator fun BlockBox.plus(box: BlockBox) = BlockBox(
15+
min(minX, box.minX), min(minY, box.minY), min(minZ, box.minZ),
16+
max(maxX, box.maxX), max(maxY, box.maxY), max(maxZ, box.maxZ),
17+
)
1418

1519
fun BlockBox.coerce(box: BlockBox) = BlockBox(
1620
minX.coerceAtLeast(box.minX), minY.coerceAtLeast(box.minY), minZ.coerceAtLeast(box.minZ),
17-
minX.coerceAtMost(box.minX), minY.coerceAtMost(box.minY), minZ.coerceAtMost(box.minZ),
21+
maxX.coerceAtMost(box.maxX), maxY.coerceAtMost(box.maxY), maxZ.coerceAtMost(box.maxZ),
1822
)
1923

2024
val Direction.asBlockRotation

0 commit comments

Comments
 (0)