iris:biome and iris:custom leave the module sources: Iris registers them itself, in core

This commit is contained in:
piexel committed 2026-10-10 14:25:32 +02:00
1 parent 2148eb28cd
commit db0f8a9186
3 files changed
+13 -246

No files matched your search

+13 -1
View File
@@ -16,6 +16,16 @@ mantle components outside the stage graph any more. Their stage constants, and t
types packs may read, live in `src/main/java/art/arcane/iris/builtin`, the package Iris exposes to pack
modules; their stage bodies live beside the features they replace.
Two of those modules are not in this project: `iris:biome` (writes the layout's platform biomes into the chunk) and
`iris:custom` (records the platform's custom blocks of content plugins) are Iris itself, so their classes live in Iris
core (`art.arcane.iris.core.modules.BiomeModule` and `CustomModule`) and Iris registers them (`IrisModuleHost`), not
the built-ins jar. Their stage constants stay in `art.arcane.iris.builtin.IrisStages`, so packs can still order after them.
Built-in modules log through the `ModuleLog` IrisApi hands them (`context.log()` in a stage body, `world.log()` in a
service or hook, `registry.log()` while registering), which labels each line with the module's id, so these sources do not
use `IrisLogging`. Classes of the host's object model (the host-classes list) and code that only has an engine or pack
data still log as Iris itself.
Built-in modules also own pack resources and checks of their own. `iris:structure` reads structures, jigsaw
pools and jigsaw pieces as resource kinds (`StructureResources`), from the folders and files packs have always
used, and checks them with its validator (`StructureValidator`: assembly samples and vanilla structure
@@ -130,7 +140,9 @@ The jar holds `iris:post`, `iris:perfection` and `iris:matter`. They are written
sampler (heights around the chunk, slope, fluid height, where the upper dimension begins) and the mantle's planned blocks.
Iris no longer compiles them in (`IrisModuleHost.generationModules()`), so a pack gets them by putting
`iris-builtins.jar` into its `modules` folder; the built-ins that order after their stages (`iris:floating`,
`iris:decorant`, `iris:custom`) only order, so a pack without the jar still loads.
`iris:decorant`, `iris:custom`) only order, so a pack without the jar still loads. Iris warns once per pack folder
when a pack loads none of the jar's modules (`IrisModuleHost.JAR_MODULE_IDS`, which a test keeps equal to
`builtin-modules.txt`): add a module to the jar and to that list together.
`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: `IrisSeed` (Iris's per-feature world seeds, a facade Iris's worlds implement, so existing worlds generate the
@@ -1,126 +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.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.modules.IrisChunk;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBiome;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.project.context.ChunkedDataCache;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.collection.KMap;
import art.arcane.volmlib.util.mantle.runtime.Mantle;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterBiomeInject;
import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter;
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
/**
* Module {@code iris:biome}: writes each column's biome into the chunk's biome hunk, a custom biome under the
* dimension's namespace, and records the biome id in the mantle for platforms that inject biomes later.
*/
public final class BiomeModule implements IrisModule {
private static final String VERSION = "built-in";
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:biome", "Biomes", VERSION);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Biome.WRITE).run(BiomeModule::write);
}
private static void write(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current();
chunk.state(BiomeWriter.class, BiomeWriter::new).write(chunk.originX(), chunk.originZ(), chunk.biomes(), chunk.context());
}
/** What writing biomes keeps for one engine runtime: the biome stream's random and the platform biomes resolved so far. */
static final class BiomeWriter {
private final Engine engine;
private final RNG rng;
private final KMap<String, ResolvedBiome> resolvedBiomes = new KMap<>();
BiomeWriter(Engine engine) {
this.engine = engine;
this.rng = new RNG(engine.getSeedManager().getBiome());
}
/** A partial biome write fails the chunk: a chunk flagged done with default biomes would keep them forever. */
void write(int originX, int originZ, Hunk<PlatformBiome> biomes, ChunkContext context) {
PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
Mantle<Matter> mantle = engine.getMantle().getMantle();
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
for (int localX = 0; localX < biomes.getWidth(); localX++) {
for (int localZ = 0; localZ < biomes.getDepth(); localZ++) {
int worldX = originX + localX;
int worldZ = originZ + localZ;
ResolvedBiome resolved = resolve(keyOf(biomeCache.get(localX, localZ), worldX, worldZ));
if (resolved.biome() != null) {
biomes.set(localX, 0, localZ, localX, biomes.getHeight() - 1, localZ, resolved.biome());
}
mantle.set(worldX, 0, worldZ, resolved.matter());
}
}
engine.getMetrics().getBiome().put(stopwatch.getMilliseconds());
}
private String keyOf(IrisBiome biome, int worldX, int worldZ) {
if (!biome.isCustom()) {
return biome.getSkyBiomeKey(rng, engine, worldX, 0, worldZ);
}
IrisBiomeCustom custom = biome.getCustomBiome(rng, engine, worldX, 0, worldZ);
return engine.getDimension().getLoadKey() + ":" + custom.getId();
}
/**
* The registry lookup and the biome id depend only on the key, so the pair is cached instead of paying two
* string-keyed lookups per column. Unresolved biomes are never cached, so a biome registered later still
* resolves.
*/
private ResolvedBiome resolve(String key) {
ResolvedBiome cached = key == null ? null : resolvedBiomes.get(key);
if (cached != null) {
return cached;
}
IrisPlatform platform = IrisPlatforms.get();
PlatformBiome biome = platform.registries().biome(key);
ResolvedBiome resolved = new ResolvedBiome(biome, BiomeInjectMatter.get(platform.biomeWriter().biomeIdFor(key)));
if (key != null && biome != null) {
resolvedBiomes.put(key, resolved);
}
return resolved;
}
}
private record ResolvedBiome(PlatformBiome biome, MatterBiomeInject matter) {
}
}
@@ -1,119 +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.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.core.link.Identifier;
import art.arcane.iris.core.modules.IrisChunk;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.parallel.BurstExecutor;
import art.arcane.iris.util.common.parallel.MultiBurst;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
/**
* Module {@code iris:custom}: records the chunk's content-plugin blocks for the server to place later: each
* custom block's placement key goes into the mantle and the block itself is replaced by its base state. Skipped
* while maintenance regeneration bypasses the mantle.
*/
public final class CustomModule implements IrisModule {
private static final String VERSION = "built-in";
private static final int CHUNK_SHIFT = 4;
private static final int SECTION_MASK = 15;
@Override
public ModuleInfo info() {
return ModuleInfo.of("iris:custom", "Custom blocks", VERSION);
}
@Override
public void install(StageGraph graph) {
// Ordering only: iris:perfection ships in the built-ins jar, which a pack may not have.
graph.define(IrisStages.Custom.BLOCKS).softAfter(IrisStages.Perfection.SURFACE.ref()).run(CustomModule::record);
}
private static void record(ChunkStageContext context) {
IrisChunk chunk = IrisChunk.current();
if (chunk.bypassesMantleStages()) {
return;
}
chunk.state(CustomBlockRecording.class, CustomBlockRecording::new).record(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore());
}
/** Moves the custom blocks of a chunk into the mantle for one engine runtime. */
static final class CustomBlockRecording {
private final Engine engine;
CustomBlockRecording(Engine engine) {
this.engine = engine;
}
/** Records the custom blocks of the chunk whose first block is {@code x}, {@code z}, when its mantle chunk is flagged as having some. */
void record(int x, int z, Hunk<PlatformBlockState> output, boolean multicore) {
MantleChunk<Matter> mc = engine.getMantle().getMantle().getChunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT);
if (!mc.isFlagged(MantleFlag.CUSTOM_ACTIVE)) {
return;
}
mc.use();
BurstExecutor burst = MultiBurst.burst.burst(output.getHeight());
burst.setMulticore(multicore);
// complete() must run before release() even when queueing throws — detached burst
// tasks must never write into a released chunk, and a lost permit wedges close().
try {
for (int y = 0; y < output.getHeight(); y++) {
int finalY = y;
burst.queue(() -> {
for (int rX = 0; rX < output.getWidth(); rX++) {
for (int rZ = 0; rZ < output.getDepth(); rZ++) {
PlatformBlockState b = output.get(rX, finalY, rZ);
if (b == null || !b.isCustom()) {
continue;
}
String placementKey = b.deferredPlacementKey();
PlatformBlockState baseState = b.placementBaseState();
if (placementKey == null || baseState == null) {
continue;
}
mc.getOrCreate(finalY >> CHUNK_SHIFT)
.slice(Identifier.class)
.set(rX, finalY & SECTION_MASK, rZ, Identifier.fromString(placementKey));
output.set(rX, finalY, rZ, baseState);
}
}
});
}
} finally {
try {
burst.complete();
} finally {
mc.release();
}
}
}
}
}