Add native biome families, desert vegetation, static sky controls and Seamless views
Build and smoke / changes (push) Waiting to run

This commit is contained in:
dnorberg committed 2026-11-17 18:12:07 -05:00
1 parent 90e4a98a7a
commit d199ac253e
92 files changed
+2520 -224

No files matched your search

@@ -0,0 +1,77 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import net.dnorberg.rivencraft.shared.DesertVegetation;
import net.dnorberg.rivencraft.shared.DesertVegetation.*;
/** Storage-free shared placement checks; no fixture is packaged into either mod JAR. */
public class DesertVegetationChecks {
record Pos(int x, int y, int z) {}
static class World implements DesertVegetation.World {
final Map<Pos, Plant> plants = new HashMap<>();
Ground ground = Ground.SAND;
boolean desert = true;
boolean mixed;
boolean blocked;
int ceiling = 320;
int readsOutside;
public int surfaceY(int x, int z) { return 4; }
public int maxY() { return ceiling; }
public boolean desert(int x, int y, int z) { return desert && (!mixed || x < 8); }
public Ground ground(int x, int y, int z) { return ground; }
public boolean air(int x, int y, int z) {
if (x < 0 || x > 15 || z < 0 || z > 15) readsOutside++;
return y >= 4 && !blocked && !plants.containsKey(new Pos(x,y,z));
}
public void set(int x, int y, int z, Plant plant) {
if (x < 0 || x > 15 || z < 0 || z > 15 || y >= ceiling)
throw new AssertionError("Write outside chunk/world bounds");
if (plants.putIfAbsent(new Pos(x,y,z),plant) != null)
throw new AssertionError("Overwrote existing vegetation");
}
}
static int place(World w, Kind k, long seed) {
return DesertVegetation.place(w,k,0,0,new Random(seed)::nextInt);
}
static void check(boolean condition, String label) {
if (!condition) throw new AssertionError(label);
}
public static void main(String[] args) {
for (Kind kind : Kind.values()) {
var a = new World();
int count = place(a,kind,108);
check(count > 0,"Page produces plants: "+kind);
var b = new World();
place(b,kind,108);
check(a.plants.equals(b.plants),"Seeded repeatability: "+kind);
check(a.readsOutside == 0,"Chunk-local checks: "+kind);
if (kind == Kind.FLOWERS)
check(a.plants.values().stream().allMatch(p -> p == Plant.DEAD_BUSH),"Desert plants only");
else {
int max = a.plants.keySet().stream().mapToInt(Pos::y).max().orElseThrow() - 3;
check(kind == Kind.HUGE_TREES ? max >= 5 && max <= 9 : max <= 3,"Cactus heights");
}
int original = a.plants.size();
for (int n=1;n<4;n++) place(a,kind,108+n);
check(a.plants.size() > original,"Repeated pages add plants: "+kind);
var outside = new World(); outside.desert = false;
check(place(outside,kind,108)==0 && outside.plants.isEmpty(),"No non-desert writes");
var unsupported = new World(); unsupported.ground=Ground.OTHER;
check(place(unsupported,kind,108)==0 && unsupported.plants.isEmpty(),"Preserve rock/invalid ground");
var blocked = new World(); blocked.blocked=true; blocked.ground=Ground.SOIL;
check(place(blocked,kind,108)==0 && blocked.plants.isEmpty(),"No partial writes when obstructed");
var mixed = new World(); mixed.mixed=true;
place(mixed,kind,108);
check(mixed.plants.keySet().stream().allMatch(p -> p.x()<8),"Candidate biome selection");
}
var flat = new World(); flat.ground=Ground.SOIL;
int cacti=place(flat,Kind.TREES,108);
check(cacti>0 && flat.plants.values().stream().filter(p -> p==Plant.SAND).count()==cacti,
"Flat soil converts exactly one base per cactus");
var low = new World(); low.ceiling=8;
check(place(low,Kind.HUGE_TREES,108)==0 && low.plants.isEmpty(),"No truncated tall cactus/headroom writes");
System.out.println("DESERT108_PASS: placement, heights, repeated pages, seed repeatability, biome boundaries, "
+"chunk bounds, obstruction, ground protection, Flat bases and ceiling");
}
}