mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
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:
1 parent
a13593f16e
commit
14acc4f37b
5 files changed
+33
-61
No files matched your search
@@ -136,10 +136,11 @@ workers: `ResolvedOre`/`ResolvedOres` (blocks and chance noise per world, `Terra
|
||||
(`carvingBiome`, a band's biome, a floating child's target and carving) implement `LinkedBiomes`, which is how Iris's biome tree and the biomes a
|
||||
dimension reaches learn of them without reading the settings classes; and `iris:carve` provides the `CaveBiomes` service
|
||||
(`CaveBiomeBands`), which Iris asks for the dimension's carving band at a position and for a biome's minimum cave depth.
|
||||
`iris:floating` ships in the built-ins jar: `FloatingWorld` holds a world's floating children, noise and seeds, and what a jar
|
||||
cannot do Iris does through `FloatingHost` (`art.arcane.iris.builtin.floating`): the surface biome of a column, a biome's
|
||||
height for the `BIOME` top shape, painting the sky biome, an object's footprint and shrinking, and placing an object
|
||||
floating, on an island's top or hung under it, where the jar's `IslandAnchor` says where the island face is.
|
||||
`iris:floating` ships in the built-ins jar: `FloatingWorld` holds a world's floating children, noise and seeds. It asks the
|
||||
API alone: the running world's layout for a column's surface biome and a biome's height for the `BIOME` top shape
|
||||
(`TerrainSampler.biomeHeight`), the chunk's terrain for a child's sky biome (`skyBiome`), which it writes with
|
||||
`Mantle.setPlatformBiome`, and `PackWorld.placements()` to place an object floating, on an island's top or hung under it,
|
||||
where the jar's `IslandAnchor` says where the island face is.
|
||||
|
||||
Packs write each settings feature under the short key it declares: `deposits` (dimension, region, biome; a list), `decorators`
|
||||
(biome; a list), `importedStructures` (dimension; an object of `disabled`, `adjustments` and the rest) and `structures`
|
||||
@@ -165,7 +166,7 @@ Iris includes this build (`includeBuild('../IrisModule')` in its `settings.gradl
|
||||
core and its adapters still name many of them (the cut-over that ends this comes later). Classes that need Iris itself
|
||||
are Iris's and live in Iris core: the layout model (`IrisBiome`, `IrisRegion`, `IrisDimension`, generators, noise
|
||||
styles, expressions, images), the pack's objects and blocks, the structure assembler, locator, fitting and placer
|
||||
(behind `StructureHost`), and the object placers behind `ObjectHost` and `FloatingHost`. A module this build holds
|
||||
(behind `StructureHost`), and the placement service behind `PackWorld.placements()`. A module this build holds
|
||||
but the jar does not, such as `iris:structure`, is one Iris registers with its own modules (`IrisModuleHost`): its
|
||||
classes are then the ones Iris's own code sees.
|
||||
|
||||
@@ -201,9 +202,9 @@ none of the jar's modules (`IrisModuleHost.JAR_MODULE_IDS`, which a test keeps e
|
||||
|
||||
`art.arcane.iris.builtin` also holds what the compiled-in built-ins and the jar must share, because each sees its own copy of
|
||||
every other class. The facades among them are interfaces Iris implements and offers through IrisApi's extension point, never
|
||||
through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`ObjectHost`,
|
||||
`FloatingHost`, `StructureHost`, `spawn.SpawnCooldowns`), `context.extension(X.class)` for what belongs to one invocation (`ObjectPlacement`
|
||||
in a placement stage, `MatterMantle` in a chunk or mantle stage) and `settings.extension(X.class)` for a reach worked out
|
||||
through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`LegacyStreams`,
|
||||
`StructureHost`, `spawn.SpawnCooldowns`), `context.extension(X.class)` for what belongs to one invocation (`MatterMantle`
|
||||
in a chunk or mantle stage) and `settings.extension(X.class)` for a reach worked out
|
||||
before any world exists, each with `.orElseThrow()`, since a built-in runs only where Iris offers them. Iris's per-feature world seeds are
|
||||
IrisApi purpose seeds: `world.seed(IrisSeedPurposes.CARVE)` (`iris:seed/carve`), which Iris answers with the seeds its worlds always
|
||||
had, so existing worlds generate the same; `spawn.SpawnCooldowns` (the spawner cooldowns
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user