Batch 7 stage 4a: floating islands shape and paint through the api

FloatingWorld asks the running layout for a biome's height, and the island
stage paints sky biomes with TerrainSampler.skyBiome and
Mantle.setPlatformBiome. FloatingHost is deleted.
This commit is contained in:
piexel committed 2026-10-28 01:58:47 +01:00
1 parent a13593f16e
commit 14acc4f37b
5 files changed
+33 -61

No files matched your search

@@ -1,37 +0,0 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.builtin.floating;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.resource.ResourceId;
/**
* What {@code iris:floating} asks of Iris beyond the API: a biome's own terrain height and the sky biome an island
* paints. Iris offers it as an extension of its worlds: {@code world.extension(FloatingHost.class)}.
*/
public interface FloatingHost {
/** The height the terrain generators of {@code biome} give the column, as Iris shapes the biome's terrain with {@code seed}. */
double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed);
/**
* Paints the sky biome {@code biome} stands for at the column into the blocks {@code ys} of the mantle, where the biome
* pass finds it. {@code random} seeds the biome's generator the first time the biome is asked.
*/
void paintSkyBiome(ResourceId biome, int worldX, int worldZ, int[] ys, RNG random);
}
@@ -45,6 +45,7 @@ import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockState;
import com.volmit.config.FeatureSettings;
import com.volmit.hunk.Hunk;
import com.volmit.mantle.Mantle;
import com.volmit.resource.ResourceId;
import com.volmit.stage.ChunkStageContext;
import com.volmit.world.BiomeKind;
@@ -55,6 +56,7 @@ import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* Fills and decorates the floating islands of the dimension's floating child biomes for {@link FloatingModule}:
@@ -141,7 +143,7 @@ final class FloatingIslands {
}
fillLocalFluid(chunk, sample, xf, zf);
paintSkyBiomes(parent, wx, wz, sample, chunk.height);
paintSkyBiomes(chunk, parent, wx, wz, sample);
}
private void fillLocalFluid(Chunk chunk, FloatingIslandSample sample, int xf, int zf) {
@@ -397,7 +399,7 @@ final class FloatingIslands {
}
/** Paints, for each child the column's island is made of, its biome's sky biome into the child's solid blocks. */
private void paintSkyBiomes(ResourceId parent, int wx, int wz, FloatingIslandSample sample, int chunkHeight) {
private void paintSkyBiomes(Chunk chunk, ResourceId parent, int wx, int wz, FloatingIslandSample sample) {
try {
Map<ResolvedFloatingChild, List<Integer>> solidYsByEntry = new IdentityHashMap<>();
for (int k = 0; k <= sample.topIdx; k++) {
@@ -405,7 +407,7 @@ final class FloatingIslands {
continue;
}
int y = sample.islandBaseY + k;
if (y < 0 || y >= chunkHeight) {
if (y < 0 || y >= chunk.height) {
continue;
}
solidYsByEntry.computeIfAbsent(sample.entryAt(k), ignored -> new ArrayList<>()).add(y);
@@ -416,8 +418,13 @@ final class FloatingIslands {
if (target == null) {
continue;
}
int[] ys = solid.getValue().stream().mapToInt(Integer::intValue).toArray();
world.host().paintSkyBiome(target, wx, wz, ys, rng);
Optional<ResourceId> skyBiome = chunk.terrain.skyBiome(target, wx, wz);
if (skyBiome.isEmpty()) {
continue;
}
for (int y : solid.getValue()) {
chunk.mantle.setPlatformBiome(wx, y, wz, skyBiome.get());
}
}
} catch (Throwable e) {
log.error("Failed to write the sky biomes of a floating island", e);
@@ -438,6 +445,8 @@ final class FloatingIslands {
final PaletteExplosion explosion;
final ColumnSlope slope;
final FloatingIslandBoundarySampler boundarySampler;
final TerrainSampler terrain;
final Mantle mantle;
Chunk(ChunkStageContext context) {
this.originX = context.originX();
@@ -447,7 +456,8 @@ final class FloatingIslands {
this.blocks = context.world().resources().blocks();
this.settings = context.settings();
this.explosion = PaletteExplosion.of(settings, context.centreX(), context.centreZ());
TerrainSampler terrain = context.terrain();
this.terrain = context.terrain();
this.mantle = context.mantle();
this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
this.boundarySampler = new FloatingIslandBoundarySampler(world::surfaceBiome);
}
@@ -782,7 +782,7 @@ public final class FloatingIslandSample {
if (target == null) {
yield maxTopHeight / 2;
}
double h = world.host().biomeHeight(target, wx, wz, world.baseSeed());
double h = world.biomeHeight(target, wx, wz);
int rounded = (int) Math.round(h);
if (rounded < 0) {
yield 0;
@@ -24,7 +24,6 @@ import art.arcane.iris.modules.carve.CarvingSettings;
import art.arcane.iris.builtin.carve.CaveProfile;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.modules.floating.FloatingChildSettings;
import art.arcane.iris.builtin.floating.FloatingHost;
import art.arcane.iris.modules.floating.MergeFloatingChildrenSettings;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import art.arcane.iris.builtin.objects.ObjectSettings;
@@ -41,14 +40,13 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* What the floating islands of one world are made from: the world's hosts, layout, noise and seeds, the floating children
* What the floating islands of one world are made from: the world's layout, noise and seeds, the floating children
* each biome declares, and the {@link ResolvedFloatingChild} of every child met, one per decoded entry. One per world
* ({@link #of}).
*/
public final class FloatingWorld {
private static final long BASE_SEED_SALT = 0x5EED_F107_00F1B10CL;
private final FloatingHost host;
private final PackResources resources;
private final RunningWorld running;
private final long baseSeed;
@@ -57,9 +55,8 @@ public final class FloatingWorld {
private final List<CarvingEntry> dimensionCarving;
private final Map<FloatingChildBiome, ResolvedFloatingChild> resolved = new ConcurrentHashMap<>();
FloatingWorld(FloatingHost host, PackResources resources, RunningWorld running, long terrainSeed,
FloatingWorld(PackResources resources, RunningWorld running, long terrainSeed,
long carveSeed, int minWorldY, List<CarvingEntry> dimensionCarving) {
this.host = host;
this.resources = resources;
this.running = running;
this.baseSeed = terrainSeed ^ BASE_SEED_SALT;
@@ -74,8 +71,8 @@ public final class FloatingWorld {
}
private static FloatingWorld create(PackWorld world) {
return new FloatingWorld(world.extension(FloatingHost.class).orElseThrow(), world.resources(), world.running().orElseThrow(), world.seed(IrisSeedPurposes.TERRAIN), world.seed(IrisSeedPurposes.CARVE),
world.minWorldY(), dimensionCarvingOf(world));
return new FloatingWorld(world.resources(), world.running().orElseThrow(), world.seed(IrisSeedPurposes.TERRAIN),
world.seed(IrisSeedPurposes.CARVE), world.minWorldY(), dimensionCarvingOf(world));
}
private static List<CarvingEntry> dimensionCarvingOf(PackWorld world) {
@@ -84,8 +81,9 @@ public final class FloatingWorld {
.orElse(List.of());
}
public FloatingHost host() {
return host;
/** The height the terrain generators of {@code biome} give the column when shaped with {@link #baseSeed}. */
public double biomeHeight(ResourceId biome, int worldX, int worldZ) {
return running.layout().biomeHeight(biome, worldX, worldZ, baseSeed);
}
public NoiseFactory noise() {