Apply offsets to the logical plot grid

This commit is contained in:
2026-09-27 08:21:22 -07:00
parent 8d99c2e67f
commit 60c3d41e50
7 changed files with 234 additions and 40 deletions

View File

@@ -26,21 +26,21 @@ import org.junit.jupiter.api.Test;
class SpawnLayoutTest {
@Test
void defaultMultipliersPreserveTheOnePlotSpawnBounds() {
Cuboid spawn = SpawnLayout.bounds(1, 1, 1, 32, 10, 32, 4, 4, 62);
Cuboid spawn = SpawnLayout.bounds(1, 1, 1, 32, 10, 32, 4, 4, 62, 0, 0, 0);
assertEqualsBounds(spawn, 2, 62, 2, 33, 71, 33);
}
@Test
void appliesEachMultiplierToItsOwnAlignedGridDimension() {
Cuboid spawn = SpawnLayout.bounds(2, 3, 4, 32, 10, 32, 4, 4, 62);
Cuboid spawn = SpawnLayout.bounds(2, 3, 4, 32, 10, 32, 4, 4, 62, 0, 0, 0);
assertEqualsBounds(spawn, 2, 62, 2, 69, 91, 141);
}
@Test
void validatesTheEntireSpawnHeightAgainstWorldBounds() {
Cuboid spawn = SpawnLayout.bounds(1, 3, 1, 32, 10, 32, 4, 4, 62);
Cuboid spawn = SpawnLayout.bounds(1, 3, 1, 32, 10, 32, 4, 4, 62, 0, 0, 0);
assertTrue(SpawnLayout.withinBuildHeight(spawn, -64, 320));
assertFalse(SpawnLayout.withinBuildHeight(spawn, -64, 91));
@@ -48,15 +48,23 @@ class SpawnLayoutTest {
@Test
void alignsSpawnAxesToTheirIndependentRoadWidths() {
Cuboid spawn = SpawnLayout.bounds(2, 1, 3, 32, 10, 32, 6, 2, 62);
Cuboid spawn = SpawnLayout.bounds(2, 1, 3, 32, 10, 32, 6, 2, 62, 0, 0, 0);
assertEqualsBounds(spawn, 3, 62, 1, 72, 71, 100);
}
@Test
void alignsSpawnBoundsWithAllGridOffsets() {
Cuboid spawn = SpawnLayout.bounds(2, 2, 3, 32, 10, 32, 6, 2, 62, -7, 3, 11);
assertEqualsBounds(spawn, -4, 65, 12, 65, 84, 111);
}
@Test
void rejectsNonPositiveSpawnMultipliers() {
assertThrows(
IllegalArgumentException.class, () -> SpawnLayout.bounds(0, 1, 1, 32, 10, 32, 4, 4, 62));
IllegalArgumentException.class,
() -> SpawnLayout.bounds(0, 1, 1, 32, 10, 32, 4, 4, 62, 0, 0, 0));
}
private static void assertEqualsBounds(