Merge branch 'wave3b/5'

This commit is contained in:
piexel committed 2026-10-15 07:06:59 +02:00
commit b047a2675d
10 files changed
+171 -5

No files matched your search

@@ -12,6 +12,10 @@ public interface MantleGenerationContext extends InvocationContext {
/** The chunk's first block along Z, in world coordinates. */
int originZ();
/** The terrain of the chunk and of the larger of the stage's reach and 16 blocks around it on every side, at full
* height: a mantle stage writes only the mantle, but may look at the terrain around its chunk, such as the heights
* a cave blends over its borders.
*/
TerrainSampler terrain();
FeatureSettings settings();
@@ -11,7 +11,7 @@ import com.volmit.mantle.MantleVisitor;
/** The mantle as chunk stages see it: reads pass through, every write throws. The mantle pipeline has
* finished around the chunk by then, and its neighbors may already be generated.
*/
final class ReadOnlyMantle implements Mantle {
public final class ReadOnlyMantle implements Mantle {
private static final String READ_ONLY = "Chunk stages read the mantle but do not write it;"
+ " write it from a mantle stage (Stage.mantle), which runs before the chunks it reaches";
@@ -21,6 +21,13 @@ final class ReadOnlyMantle implements Mantle {
this.mantle = mantle;
}
/** The host's mantle behind this view: for a host's own extensions of {@link Mantle}, such as a built-in facade that
* reaches the platform's storage. A module that writes through it breaks the promise this view makes to chunk stages.
*/
public Mantle host() {
return mantle;
}
@Override
public BlockBox bounds() {
return mantle.bounds();
@@ -9,4 +9,48 @@ public interface NoiseSampler {
double sample(double worldX, double worldZ);
double sample(double worldX, double y, double worldZ);
/** {@link #sample(double, double)} mapped from 0..1 to -1..1 ({@code sample * 2 - 1}), for noise that is added up
* and compared around zero. A host may answer a repeated read of the same coordinates from a per-thread memo, so a
* caller that samples the same field at the same points again and again (a carver testing densities) should read
* this instead of mapping {@link #sample(double, double)} itself.
*/
default double signed(double worldX, double worldZ) {
return sample(worldX, worldZ) * 2D - 1D;
}
/** The three-dimensional counterpart of {@link #signed(double, double)}. */
default double signed(double worldX, double y, double worldZ) {
return sample(worldX, y, worldZ) * 2D - 1D;
}
/** This noise with its coordinates multiplied by {@code factor}: a factor above 1 squeezes the pattern, below 1
* stretches it. A host folds the factor into the generator's own scale, so the result is the very noise the style
* would give with that extra scale (same values and float rounding), and builds it without touching this sampler.
* The default multiplies the coordinates before sampling, which may round differently.
*/
default NoiseSampler scaled(double factor) {
NoiseSampler source = this;
return new NoiseSampler() {
@Override
public double sample(double worldX, double worldZ) {
return source.sample(worldX * factor, worldZ * factor);
}
@Override
public double sample(double worldX, double y, double worldZ) {
return source.sample(worldX * factor, y * factor, worldZ * factor);
}
@Override
public double signed(double worldX, double worldZ) {
return source.signed(worldX * factor, worldZ * factor);
}
@Override
public double signed(double worldX, double y, double worldZ) {
return source.signed(worldX * factor, y * factor, worldZ * factor);
}
};
}
}
@@ -28,6 +28,15 @@ public interface PackResources {
/** Builds the noise of the {@link com.volmit.noise.NoiseStyle}s the pack's settings describe. */
NoiseFactory noise();
/** The id the pack's resources have for the one the pack's own files name by {@code packKey}, such as {@code desert/dunes}
* (a biome's key in a region, a settings field naming a biome): {@code overworld:desert/dunes} in the pack
* {@code overworld}. Characters an id cannot hold are replaced the way the host does for its own ids, so use this and
* not {@code new ResourceId(packId().namespace(), packKey)} for a key that may hold them.
*/
default ResourceId idOf(String packKey) {
return new ResourceId(packId().namespace(), packKey);
}
<T> Optional<T> find(ResourceKey<T> key);
/** The ids of every resource of the kind {@code type} selects, in id order. A type the host does not serve
@@ -26,6 +26,14 @@ public interface PackWorld {
/** The settings of the world's dimension and of every region and biome it can reach, as mantle reaches see them. */
PackSettings settings();
/** The platform's Y of the dimension's bottom (-64 in the overworld). Every height the API carries is above that
* bottom; settings that name an absolute world Y, as packs write them for the platform, are converted with it:
* {@code heightAboveBottom = worldY - minHeight()}. Zero unless the host's dimensions begin below Y 0.
*/
default int minHeight() {
return 0;
}
/**
* The world's one {@code type} instance, created by {@code create} the first time anyone asks for it. Modules keep
* their caches and per-world workers here instead of in fields, since stage bodies and services are shared by every
@@ -1,6 +1,8 @@
package com.volmit.world;
import com.volmit.mantle.BlockBox;
import com.volmit.resource.ResourceId;
import java.util.Optional;
import java.util.OptionalInt;
/** Read-only host sampling for the same pack snapshot as the invocation.
@@ -20,6 +22,14 @@ public interface TerrainSampler {
}
BiomeSample biome(int worldX, int y, int worldZ);
/** The {@link BiomeSample#caveBiome()} alone, for a module that asks it block by block and needs neither the region
* nor the surface biome: the host may answer it without working out the rest of {@link #biome}. Outside the bounds it
* throws like {@link #biome}.
*/
default Optional<ResourceId> caveBiome(int worldX, int y, int worldZ) {
return biome(worldX, y, worldZ).caveBiome();
}
/** The height up to which the host fills the world with fluid wherever the terrain lies lower, the sea level of the
* dimension: a column's {@link TerrainSample#fluidY()} is this height when its surface is below it.
*/