From d1a1512a6d2372459def3c28ff06cf751bdc65a9 Mon Sep 17 00:00:00 2001 From: piexel Date: Sat, 10 Oct 2026 18:05:50 +0200 Subject: [PATCH] TerrainSampler: the surface biome's kind, the world Y of the dimension's bottom, image-map ground blocks and the dimension stacked above; FeatureSettings.declaredBy for biomes that are no column's surface biome --- .../com/volmit/config/FeatureSettings.java | 10 +++++++ src/main/java/com/volmit/world/BiomeKind.java | 7 +++++ .../java/com/volmit/world/TerrainSampler.java | 24 ++++++++++++++++ .../java/com/volmit/world/UpperDimension.java | 28 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 src/main/java/com/volmit/world/BiomeKind.java create mode 100644 src/main/java/com/volmit/world/UpperDimension.java diff --git a/src/main/java/com/volmit/config/FeatureSettings.java b/src/main/java/com/volmit/config/FeatureSettings.java index a6a31d475..4803a8aeb 100644 --- a/src/main/java/com/volmit/config/FeatureSettings.java +++ b/src/main/java/com/volmit/config/FeatureSettings.java @@ -5,6 +5,7 @@ import com.volmit.IrisFeature; import com.volmit.resource.ResourceId; import java.util.List; import java.util.Objects; +import java.util.Optional; /** Invocation-scoped lookup of the settings that apply at one world column. * @@ -22,6 +23,15 @@ import java.util.Objects; public interface FeatureSettings { List> at(Class featureType, int worldX, int worldZ); + /** The settings {@code biome} declares itself, whichever column it is found at: for a biome that is not a column's + * surface biome, such as the cave biome of {@link com.volmit.world.BiomeSample#caveBiome()}, which is no level of + * {@link #at}. {@code biome} is an id as a {@code BiomeSample} gives it. Empty when the biome declares none, or the + * host knows no such biome. + */ + default Optional declaredBy(ResourceId biome, Class featureType) { + return Optional.empty(); + } + /** One level's declaration of the settings. * * @param level where the settings are declared: the dimension, a region, a biome or the placement diff --git a/src/main/java/com/volmit/world/BiomeKind.java b/src/main/java/com/volmit/world/BiomeKind.java new file mode 100644 index 000000000..6fd9994fa --- /dev/null +++ b/src/main/java/com/volmit/world/BiomeKind.java @@ -0,0 +1,7 @@ +package com.volmit.world; + +/** What a biome is generated as, which decides what grows and spawns in it: the host picks the surface biome of a column + * from the lists of its region (land, sea or shore biomes), and a biome picked for a cave is a {@link #CAVE} biome. + * A child biome is the kind of the biome it was found in. + */ +public enum BiomeKind { LAND, SEA, SHORE, CAVE } diff --git a/src/main/java/com/volmit/world/TerrainSampler.java b/src/main/java/com/volmit/world/TerrainSampler.java index 65d129fcd..f3cb3217b 100644 --- a/src/main/java/com/volmit/world/TerrainSampler.java +++ b/src/main/java/com/volmit/world/TerrainSampler.java @@ -1,6 +1,8 @@ package com.volmit.world; +import com.volmit.block.BlockState; import com.volmit.mantle.BlockBox; +import java.util.Optional; import java.util.OptionalInt; /** Read-only host sampling for the same pack snapshot as the invocation. @@ -30,4 +32,26 @@ public interface TerrainSampler { * Empty when nothing sits above. Outside the bounds it throws like {@link #column}. */ OptionalInt upperDimensionY(int worldX, int worldZ); + + /** What the surface biome of the column was generated as. A cave biome ({@link BiomeSample#caveBiome()}) is always + * {@link BiomeKind#CAVE}, so the answer is about the surface biome only. Outside the bounds it throws like {@link #column}. + */ + BiomeKind surfaceKind(int worldX, int worldZ); + + /** The block an image map of the dimension gives the column's ground, replacing what its biome would put there; empty + * where no map does. Outside the bounds it throws like {@link #column}. + */ + default Optional surfaceBlock(int worldX, int worldZ) { + return Optional.empty(); + } + + /** The Y in the world of the dimension's bottom block, such as {@code -64}: what to add to a height above the bottom + * to get the Y a pack's settings name when they speak of world heights. + */ + int minWorldY(); + + /** The dimension stacked above this one, whose ground starts at {@link #upperDimensionY}; empty when nothing sits above. */ + default Optional upperDimension() { + return Optional.empty(); + } } diff --git a/src/main/java/com/volmit/world/UpperDimension.java b/src/main/java/com/volmit/world/UpperDimension.java new file mode 100644 index 000000000..5174e139a --- /dev/null +++ b/src/main/java/com/volmit/world/UpperDimension.java @@ -0,0 +1,28 @@ +package com.volmit.world; + +import com.volmit.block.BlockState; +import com.volmit.config.FeatureSettings; +import com.volmit.resource.PackResources; +import java.util.Optional; + +/** The dimension stacked above the one being generated, whose ground hangs from the top of this one's volume. It may be + * the dimension itself ({@link #isThisDimension()}). Its own biomes and settings decide what its ground is made of, which + * is why a module that fills it in reads them here and not from the sampler and settings of the dimension it generates. + * Valid for the invocation, like the sampler it comes from. + */ +public interface UpperDimension { + /** Whether the dimension above is this very dimension, stacked on itself. */ + boolean isThisDimension(); + + /** The key the pack knows the dimension by, such as {@code overworld}: what its noise seeds derive from. */ + String key(); + + /** The settings of the upper dimension: its dimension, and the region and surface biome it has at the column. */ + FeatureSettings settings(); + + /** The resources the upper dimension reads: its blocks and its noise. */ + PackResources resources(); + + /** The block an image map of the upper dimension gives its ground at the column; empty where it gives none. */ + Optional surfaceBlock(int worldX, int worldZ); +}