Host side for ported decorant: the chunk mantle reaches 16 blocks around, ids are remembered, decorator platform hooks go (the registry answers), tests for the ported decorators

This commit is contained in:
piexel committed 2026-10-12 02:18:10 +02:00
1 parent 15a7250ffe
commit 7d6256230a
23 files changed
+373 -750

No files matched your search

@@ -40,6 +40,8 @@ import java.util.Collection;
final class IrisGenerationContext implements GenerationContext {
/** Chunk stages write only their own chunk, but see the terrain this far around it (IrisApi's promise). */
private static final int TERRAIN_MARGIN_BLOCKS = 16;
/** The mantle too reaches this far around the chunk; chunks beyond its own are pinned when a stage first reads them. */
private static final int MANTLE_MARGIN_BLOCKS = 16;
private static final int CHUNK_WIDTH = 16;
private final Engine engine;
@@ -61,7 +63,8 @@ final class IrisGenerationContext implements GenerationContext {
this.blocks = new BlockStateHunk(blocks, states);
this.terrain = new IrisTerrainSampler(engine, ids, originX, originZ, TERRAIN_MARGIN_BLOCKS, states);
this.settings = new ChunkModuleSettings(engine, ids);
BlockBox chunk = ApiHeights.columns(engine, originX, originZ, originX + CHUNK_WIDTH, originZ + CHUNK_WIDTH);
BlockBox chunk = ApiHeights.columns(engine, originX - MANTLE_MARGIN_BLOCKS, originZ - MANTLE_MARGIN_BLOCKS,
originX + CHUNK_WIDTH + MANTLE_MARGIN_BLOCKS, originZ + CHUNK_WIDTH + MANTLE_MARGIN_BLOCKS);
this.mantle = new IrisModuleMantle(chunk, mantleChunks, mantleLayers, PlannedBlocks.of(engine, chunk, mantleChunks, states));
}
@@ -19,7 +19,6 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.actuator.DecorantModule;
import art.arcane.iris.engine.actuator.TerrainModule;
import art.arcane.iris.engine.loot.LootModule;
import art.arcane.iris.engine.mantle.components.ObjectModule;
@@ -62,7 +61,7 @@ public final class IrisModuleHost {
* {@code IrisModule/builtin-modules.txt}) instead of being compiled into Iris. A pack loads them from its {@code modules}
* folder, and {@link MissingBuiltInModules} warns when it loads none; a test keeps this equal to the jar's list.
*/
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:deposit");
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:deposit", "iris:decorant");
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
@@ -87,7 +86,7 @@ public final class IrisModuleHost {
private static List<IrisModule> generationModules() {
return List.of(new TerrainModule(), new CarveModule(), new ObjectModule(), new StructureModule(),
new FloatingModule(), new DecorantModule(), new LootModule(), new SpawnModule());
new FloatingModule(), new LootModule(), new SpawnModule());
}
/** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */
@@ -60,7 +60,7 @@ public final class ModuleChunkGeneration {
int chunkX = x >> CHUNK_SHIFT;
int chunkZ = z >> CHUNK_SHIFT;
long seed = ModuleSeeds.chunk(engine.getSeedManager().getSeed(), chunkX, chunkZ);
try (PinnedMantleChunk mantle = new PinnedMantleChunk(engine, chunkX, chunkZ)) {
try (PinnedMantleChunks mantle = new PinnedMantleChunks(engine)) {
IrisGenerationContext inputs = new IrisGenerationContext(engine, x, z, blocks, new PlatformBlockStates(platformStates), mantle,
pack.catalog().mantle());
StageMetrics metrics = new StageMetrics(engine.getMetrics());
@@ -22,6 +22,8 @@ import com.volmit.resource.ResourceId;
import java.io.File;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
/**
@@ -38,6 +40,8 @@ final class PackResourceIds {
private static final String PACK_PATH = "pack";
private final String namespace;
/** Stages ask for the id of the same few keys for every column, so each is worked out once. */
private final Map<String, ResourceId> known = new ConcurrentHashMap<>();
PackResourceIds(File packFolder) {
String name = NOT_NAMESPACE.matcher(packFolder.getName().toLowerCase(Locale.ROOT)).replaceAll(REPLACEMENT);
@@ -56,11 +60,15 @@ final class PackResourceIds {
/** {@code key} of a resource whose type its use makes clear, such as a biome in a biome sample. */
ResourceId of(String key) {
return new ResourceId(namespace, NOT_PATH.matcher(key.toLowerCase(Locale.ROOT)).replaceAll(REPLACEMENT));
return known.computeIfAbsent(key, this::idOf);
}
/** {@code key} of a resource of {@code type}, such as {@code overworld:biome/desert/dunes}. */
ResourceId of(String type, String key) {
return of(type + "/" + key);
}
private ResourceId idOf(String key) {
return new ResourceId(namespace, NOT_PATH.matcher(key.toLowerCase(Locale.ROOT)).replaceAll(REPLACEMENT));
}
}
@@ -1,59 +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.core.modules;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
/**
* The one mantle chunk a generating chunk's stages may read: pinned the first time a stage asks for it and
* released once the chunk's stages are done.
*/
final class PinnedMantleChunk implements IrisModuleMantle.Chunks, AutoCloseable {
private final Engine engine;
private final int chunkX;
private final int chunkZ;
private MantleChunk<Matter> pinned;
PinnedMantleChunk(Engine engine, int chunkX, int chunkZ) {
this.engine = engine;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
}
@Override
public synchronized MantleChunk<Matter> chunk(int x, int z) {
if (x != chunkX || z != chunkZ) {
return null;
}
if (pinned == null) {
pinned = engine.getMantle().getMantle().getChunk(chunkX, chunkZ).use();
}
return pinned;
}
@Override
public synchronized void close() {
if (pinned != null) {
pinned.release();
pinned = null;
}
}
}
@@ -36,7 +36,8 @@ final class StageMetrics implements StageTimings {
private static final Map<String, Function<EngineMetrics, AtomicRollingSequence>> NAMED = Map.of(
"iris:post/smooth", EngineMetrics::getPost,
"iris:perfection/surface", EngineMetrics::getPerfection,
"iris:deposit/ores", EngineMetrics::getDeposit);
"iris:deposit/ores", EngineMetrics::getDeposit,
"iris:decorant/decorate", EngineMetrics::getDecoration);
private final EngineMetrics metrics;
@@ -1,45 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.framework;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public interface EngineDecorator extends EngineComponent {
@BlockCoordinates
void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max);
@BlockCoordinates
default void decorate(int x, int z, int realX, int realZ, Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
decorate(x, z, realX, realX, realX, realZ, realZ, realZ, data, biome, height, max);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
default boolean canGoOn(PlatformBlockState decorant, PlatformBlockState atop) {
if (atop == null || atop.isAir()) {
return false;
}
return B.canPlaceOnto(decorant, atop);
}
}