plugins/DuneTerrain/src/main/java/com/example/duneterrain/RuinsPlan.java
unimatrixgit bc8b2b2a00
All checks were successful
DuneRealms Resourcepack CI / resourcepack (push) Successful in 1m56s
DuneRealms Plugin CI / plugins (push) Successful in 3m16s
Replace Arrakis fortress and add abandoned Fremen village
2026-11-29 22:48:55 +01:00

37 lines
2.1 KiB
Java

package com.example.duneterrain;
import java.util.List;
/** Pure geometry of the abandoned Fremen settlement, relative to its anchor. */
final class RuinsPlan {
private RuinsPlan() {}
record House(int cx, int cz) {
int x1() { return cx - 3; } int x2() { return cx + 3; } int z1() { return cz - 3; } int z2() { return cz + 3; }
boolean contains(int x, int z) { return x >= x1() && x <= x2() && z >= z1() && z <= z2(); }
boolean overlaps(House o) { return x1() <= o.x2() && x2() >= o.x1() && z1() <= o.z2() && z2() >= o.z1(); }
/** Unit vector of the wall that faces the plaza (the door). */
int[] door() { return Math.abs(cx) > Math.abs(cz) ? new int[]{cx > 0 ? -1 : 1, 0} : new int[]{0, cz > 0 ? -1 : 1}; }
}
static final int BASIN_RADIUS = 5, PLAZA_RADIUS = 11, WINDTRAP_X = 10, WINDTRAP_Z = 0;
static final List<House> HOUSES = List.of(new House(-14, -10), new House(0, -16), new House(14, -10),
new House(-14, 9), new House(1, 15), new House(15, 9));
/** Dry irrigation channels from the basin rim: {x, z, dx, dz, length}. */
static final List<int[]> CHANNELS = List.of(new int[]{0, -6, 0, -1, 6}, new int[]{0, 6, 0, 1, 6}, new int[]{-6, 0, -1, 0, 5});
/** Basin depth at a plaza column: 0 outside, up to 3 in the middle. */
static int basinDepth(int x, int z) {
double d = Math.sqrt((double) x * x + (double) z * z);
return d <= 2.2 ? 3 : d <= 4.2 ? 2 : d <= BASIN_RADIUS + 0.5 ? 1 : 0;
}
/** Chance that a wall block at height h (1..4 above the base) is gone. */
static double erosion(int h, boolean collapsed) { return collapsed ? 0.35 + 0.15 * h : 0.05 + 0.12 * h; }
/** Deterministic 0..2 block sand drift at a column. */
static int drift(long id, int x, int z) {
long h = SietchLayout.mix(id ^ (x * 0x9E3779B97F4A7C15L) ^ (z * 0xC2B2AE3D27D4EB4FL));
int v = (int) Math.floorMod(h, 10);
return v < 4 ? 0 : v < 8 ? 1 : 2;
}
static boolean collapsed(long id, int house) { return Math.floorMod(SietchLayout.mix(id ^ house * 0x51ed27L), 3L) == 0; }
}