Give cave ceiling layers their own thickness noise

Ceiling layers borrowed the thickness noise of the surface layer at the same index, so ceiling layers beyond the surface layer count were dropped and the validator rejected such packs. Each ceiling layer now has its own cached noise, seeded as before, every declared layer is generated, and the validator accepts any count.

TerrainLayersPinTest re-baselined (length 143112 -> 147047, hash 149645537 -> 216639495). Only the MEADOW ceiling output changed, in both the plain and the exploded runs; surface, sea and smoothing output of every biome is identical, and the biomes without ceiling layers are untouched:
- MEADOW ceiling, plain: 5724 -> 7400 characters. Its fourth layer (basalt) is now emitted instead of cut off at the three surface layers.
- MEADOW ceiling, exploded: 13788 -> 16047 characters. Same fourth layer, plus the barrier separators around it.
- Layers 0 to 2 of MEADOW's ceiling now take thickness from their own style and zoom instead of the surface layers' (SIMPLEX zoom 0.3 against the default style for layer 0, the default style against CELLULAR zoom 0.25 for layer 1), so their block counts change at most columns, e.g. column -400,-400 went from "clay tuff deepslate calcite" to "clay clay tuff deepslate tuff calcite basalt".

Upstream: 23bad0e1a
This commit is contained in:
piexel committed 2026-11-10 10:07:29 +01:00
1 parent 5a2c5b2592
commit 7b2a232a42
8 files changed
+160 -60

No files matched your search

@@ -22,25 +22,17 @@ import art.arcane.volmlib.util.json.JSONArray;
import art.arcane.volmlib.util.json.JSONObject;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
* Validates biome layer stacks. caveCeilingLayers reuses the height generators built from layers,
* so a biome with more ceiling entries than surface entries has no generator for the extras; the
* engine skips them, and this validator surfaces the mistake to the author at validate time.
*/
final class PackBiomeLayerValidator {
private static final int DEFAULT_LAYER_COUNT = 1;
private static final String DECORATORS = "decorators";
private PackBiomeLayerValidator() {
}
static List<String> validateCeilingLayerCounts(File biomesFolder) {
static List<String> validateLayers(File biomesFolder) {
List<String> blockingErrors = new ArrayList<>();
if (biomesFolder == null || !biomesFolder.isDirectory()) {
return blockingErrors;
@@ -50,24 +42,13 @@ final class PackBiomeLayerValidator {
biomeFiles.sort(Comparator.comparing(File::getPath));
for (File biomeFile : biomeFiles) {
String biomeKey = PackValidationIo.deriveKey(biomesFolder, biomeFile);
JSONObject biome;
try {
biome = new JSONObject(Files.readString(biomeFile.toPath(), StandardCharsets.UTF_8));
} catch (Throwable e) {
// Invalid JSON is reported by the graph validators; layer counts have nothing to add.
JSONObject biome = PackValidationIo.readJson(biomeFile);
if (biome == null) {
continue;
}
Integer layers = arrayLength(biome, "layers", biomeKey, DEFAULT_LAYER_COUNT, blockingErrors);
Integer ceiling = arrayLength(biome, "caveCeilingLayers", biomeKey, 0, blockingErrors);
if (layers == null || ceiling == null) {
continue;
}
if (ceiling > layers) {
blockingErrors.add("Biome '" + biomeKey + "' declares " + ceiling + " caveCeilingLayers but only "
+ layers + " layers. caveCeilingLayers reuses the layers height generators and must not have more entries.");
}
validateLayerArray(biome, "layers", biomeKey, blockingErrors);
validateLayerArray(biome, "caveCeilingLayers", biomeKey, blockingErrors);
}
return blockingErrors;
}
@@ -127,17 +108,13 @@ final class PackBiomeLayerValidator {
}
}
private static Integer arrayLength(JSONObject biome, String field, String biomeKey, int defaultCount,
List<String> blockingErrors) {
private static void validateLayerArray(JSONObject biome, String field, String biomeKey, List<String> blockingErrors) {
if (!biome.has(field) || biome.isNull(field)) {
return defaultCount;
return;
}
JSONArray array = biome.optJSONArray(field);
if (array == null) {
if (biome.optJSONArray(field) == null) {
blockingErrors.add("Biome '" + biomeKey + "' " + field + " must be an array.");
return null;
}
return array.length();
}
}
@@ -89,7 +89,7 @@ public final class PackValidator {
new File(packFolder, "spawners"), new File(packFolder, "entities")));
blockingErrors.addAll(PackSpawnValidator.validateCustomBiomeSpawns(
new File(packFolder, "biomes"), PackSpawnValidator::resolveEntitySpawnCategory));
blockingErrors.addAll(PackBiomeLayerValidator.validateCeilingLayerCounts(new File(packFolder, "biomes")));
blockingErrors.addAll(PackBiomeLayerValidator.validateLayers(new File(packFolder, "biomes")));
blockingErrors.addAll(PackBiomeLayerValidator.validateDecoratorPalettes(
new File(packFolder, "biomes"), new File(packFolder, "snippet/iris/decorant/decorator")));
PackStyledRangeDefaultValidator.Validation styledRanges = PackStyledRangeDefaultValidator.validate(packFolder);