Merge branch 'wave3b/4'

# Conflicts:
#	README.md
#	src/main/java/com/volmit/world/TerrainSampler.java
This commit is contained in:
piexel committed 2026-10-15 07:13:58 +02:00
commit 58ed81032c
16 files changed
+180 -7

No files matched your search

@@ -34,6 +34,14 @@ public interface BlockRegistry {
*/
PaletteSampler palette(PaletteSpec spec, long seed);
/** The ore that suits the {@code rock} it is placed in, which the platform decides: an ore placed in deepslate is its
* deepslate variant, one placed in other rock its ordinary one. {@code ore} itself when it has no variant, and by
* default for a registry that knows none.
*/
default BlockState oreFor(BlockState rock, BlockState ore) {
return ore;
}
boolean hasTrait(BlockState state, BlockTrait trait);
boolean inTag(BlockState state, ResourceId tag);
/** Whether state can attach to the specified face of support, ignoring other neighbors. */
@@ -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 {
<F extends IrisFeature> List<Entry<F>> at(Class<F> 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 <F extends IrisFeature> Optional<F> declaredBy(ResourceId biome, Class<F> 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
@@ -20,7 +20,9 @@ public interface GenerationContext extends InvocationContext {
FeatureSettings settings();
/** Non-null mantle access scoped to this invocation; the host owns its lifetime. Chunk stages read it
* only: the mantle pipeline has finished around the chunk, and writes throw.
* only: the mantle pipeline has finished around the chunk, and writes throw. Like {@link #terrain()} it covers the
* chunk and the 16 blocks around it, so a stage that places something against a neighbor can see what the mantle
* holds there.
*/
Mantle mantle();
@@ -111,6 +111,12 @@ final class PlacementViews {
bounds();
return new RestrictedMantleLayer<>(this, parent.blocks());
}
@Override
public MantleLayer<Boolean> caverns() {
bounds();
return new RestrictedMantleLayer<>(this, parent.caverns());
}
}
private static final class RestrictedMantleLayer<T> implements MantleLayer<T> {
@@ -43,6 +43,11 @@ public final class ReadOnlyMantle implements Mantle {
return new ReadOnlyLayer<>(mantle.blocks());
}
@Override
public MantleLayer<Boolean> caverns() {
return new ReadOnlyLayer<>(mantle.caverns());
}
@Override
public MantleEdit edit() {
throw new UnsupportedOperationException(READ_ONLY);
@@ -32,6 +32,13 @@ public interface Mantle {
*/
MantleLayer<BlockState> blocks();
/** Where the mantle holds a carved void for the chunk to take over: a cave's air or fluid, planned before the chunks
* were generated. Present ({@code true}) at carved positions, absent elsewhere, also where the chunk's own blocks
* show no void, such as under a dimension stacked above. The host owns this layer, so it needs no registration.
* Stages read it only, and writes throw UnsupportedOperationException. A dimension that keeps no mantle holds none.
*/
MantleLayer<Boolean> caverns();
/** Only one edit may be active per view. Parent reads remain allowed, but parent
* mutations are prohibited until the edit ends (IllegalStateException).
*/
@@ -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 }
+11 -3
View File
@@ -5,15 +5,23 @@ import java.util.List;
import java.util.Objects;
/** A biome of the loaded pack, found through {@code PackResources} by the ids a {@link BiomeSample} gives.
* platformBiome is the platform biome the host writes for it. children are the pack biomes that can
* generate inside it. Rarity is relative to the biome's siblings: higher is rarer.
* platformBiome is the platform biome the host writes for it. vanillaBiome is the biome vanilla's own rules see it as,
* such as which structures may start in it: the platform biome unless the pack says otherwise. children are the pack
* biomes that can generate inside it. Rarity is relative to the biome's siblings: higher is rarer.
*/
public record PackBiome(ResourceId id, String name, ResourceId platformBiome, int rarity, List<ResourceId> children) {
public record PackBiome(ResourceId id, String name, ResourceId platformBiome, ResourceId vanillaBiome, int rarity,
List<ResourceId> children) {
public PackBiome {
Objects.requireNonNull(id, "id");
Objects.requireNonNull(name, "name");
Objects.requireNonNull(platformBiome, "platformBiome");
Objects.requireNonNull(vanillaBiome, "vanillaBiome");
if (rarity < 1) throw new IllegalArgumentException("Biome rarity must be at least 1: " + rarity);
children = List.copyOf(children);
}
/** A biome that vanilla's rules see as its platform biome. */
public PackBiome(ResourceId id, String name, ResourceId platformBiome, int rarity, List<ResourceId> children) {
this(id, name, platformBiome, platformBiome, rarity, children);
}
}
@@ -1,7 +1,8 @@
package com.volmit.world;
import com.volmit.mantle.BlockBox;
import com.volmit.block.BlockState;
import com.volmit.resource.ResourceId;
import com.volmit.mantle.BlockBox;
import java.util.Optional;
import java.util.OptionalInt;
@@ -40,4 +41,33 @@ public interface TerrainSampler {
* Empty when nothing sits above. Outside the bounds it throws like {@link #column}.
*/
OptionalInt upperDimensionY(int worldX, int worldZ);
/** The id of the column's surface biome, as {@link BiomeSample#surfaceBiome()} gives it, for a module that asks about every
* column of a chunk and has no use for the rest of the sample. The host may answer it without working out the cave biome.
*/
default ResourceId surfaceBiome(int worldX, int worldZ) {
return biome(worldX, bounds().minY(), worldZ).surfaceBiome();
}
/** 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<BlockState> 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> upperDimension() {
return Optional.empty();
}
}
@@ -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<BlockState> surfaceBlock(int worldX, int worldZ);
}