Host the batch 4 IrisApi: api and host artifacts, ModuleLoadException

- Depend on com.volmit:iris-api and com.volmit:iris-host; the probe
  compiles against the api only.
- PackModuleSet catches ModuleLoadException.
- ObjectPlacerEdit implements set(x, y, z, state) without a PlacedBlock;
  block entities sit in their own map.
- BlockStateHunk implements width(), height(), depth().
This commit is contained in:
piexel committed 2026-10-24 04:19:42 +02:00
1 parent 4bacc306e9
commit 64658013fe
16 files changed
+78 -45

No files matched your search

+10 -5
View File
@@ -54,8 +54,10 @@ dependencies {
api(project(':spi'))
// IrisApi, from the sibling checkout (gradle/irisapi-resolution.settings.gradle). Shaded without
// relocation: pack modules compile against com.volmit and the pack loader exposes that package.
implementation('com.volmit:IrisApi')
// relocation: pack modules compile against com.volmit and the pack loader exposes that package,
// except the host side (com.volmit.host), which loads and runs them.
implementation('com.volmit:iris-api')
implementation('com.volmit:iris-host')
// Provided or Classpath
compileOnly(libs.lombok)
@@ -111,7 +113,8 @@ dependencies {
slim(libs.dom4j)
slim(libs.jaxen)
testImplementation('com.volmit:IrisApi')
testImplementation('com.volmit:iris-api')
testImplementation('com.volmit:iris-host')
testImplementation('junit:junit:4.13.2')
testImplementation('org.mockito:mockito-core:5.23.0')
testImplementation(libs.paper.api)
@@ -343,7 +346,8 @@ List<String> builtinPackagedPatterns = builtinModuleClasses.collectMany { String
Provider<Directory> builtinModulesBuild = layout.buildDirectory.dir('builtin-modules')
configurations {
// What the jar check sees besides Iris's classes: the IrisApi and the libraries Iris shares with pack modules.
// What the jar check sees besides Iris's classes: the IrisApi (its host side included, as in the plugin, where the
// check finds it hidden) and the libraries Iris shares with pack modules.
builtinModulesCheckClasspath {
canBeConsumed = false
transitive = false
@@ -354,7 +358,8 @@ configurations {
}
dependencies {
builtinModulesCheckClasspath('com.volmit:IrisApi')
builtinModulesCheckClasspath('com.volmit:iris-api')
builtinModulesCheckClasspath('com.volmit:iris-host')
builtinModulesCheckClasspath(volmLibCoordinate)
builtinModulesCheckClasspath(libs.gson)
}
@@ -49,17 +49,17 @@ final class BlockStateHunk implements Hunk<BlockState> {
}
@Override
public int getWidth() {
public int width() {
return blocks.getWidth();
}
@Override
public int getHeight() {
public int height() {
return blocks.getHeight();
}
@Override
public int getDepth() {
public int depth() {
return blocks.getDepth();
}
@@ -79,9 +79,9 @@ final class BlockStateHunk implements Hunk<BlockState> {
}
private void requireInside(int x, int y, int z) {
if (x < 0 || y < 0 || z < 0 || x >= getWidth() || y >= getHeight() || z >= getDepth()) {
if (x < 0 || y < 0 || z < 0 || x >= width() || y >= height() || z >= depth()) {
throw new IndexOutOfBoundsException("Block " + x + ", " + y + ", " + z + " is outside the "
+ getWidth() + "x" + getHeight() + "x" + getDepth() + " chunk hunk");
+ width() + "x" + height() + "x" + depth() + " chunk hunk");
}
}
}
@@ -25,12 +25,14 @@ import art.arcane.volmlib.util.matter.MatterMarker;
import com.volmit.block.BlockState;
import com.volmit.mantle.BlockBox;
import com.volmit.mantle.Mantle;
import com.volmit.object.BlockEntityData;
import com.volmit.placement.PlacedBlock;
import com.volmit.placement.PlacedMarker;
import com.volmit.placement.PlacementEdit;
import com.volmit.world.BlockPosition;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -52,7 +54,8 @@ final class ObjectPlacerEdit implements PlacementEdit {
private final PlatformBlockStates states;
private final BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener;
private final Supplier<PlacementMantle> mantleSource;
private final Map<BlockPosition, PlacedBlock> blocks = new LinkedHashMap<>();
private final Map<BlockPosition, BlockState> blocks = new LinkedHashMap<>();
private final Map<BlockPosition, BlockEntityData> blockEntities = new HashMap<>();
private final List<PlacedMarker> markers = new ArrayList<>();
private final List<BlockPosition> objectBlocks = new ArrayList<>();
private PlacementMantle mantle;
@@ -82,15 +85,28 @@ final class ObjectPlacerEdit implements PlacementEdit {
@Override
public BlockState get(int x, int y, int z) {
requireInside(x, y, z);
PlacedBlock buffered = blocks.get(new BlockPosition(x, y, z));
return buffered != null ? buffered.state() : states.toApi(placer.get(x, y, z));
BlockState buffered = blocks.get(new BlockPosition(x, y, z));
return buffered != null ? buffered : states.toApi(placer.get(x, y, z));
}
@Override
public void set(int x, int y, int z, BlockState state) {
requireInside(x, y, z);
buffer(new BlockPosition(x, y, z), state);
}
@Override
public void set(PlacedBlock block) {
BlockPosition position = block.position();
requireInside(position.x(), position.y(), position.z());
blocks.put(position, block);
buffer(position, block.state());
block.blockEntity().ifPresent(entity -> blockEntities.put(position, entity));
}
/** A write without a block entity drops one buffered earlier at the same place. */
private void buffer(BlockPosition position, BlockState state) {
blocks.put(position, state);
blockEntities.remove(position);
}
@Override
@@ -131,6 +147,7 @@ final class ObjectPlacerEdit implements PlacementEdit {
public void close() {
discardMantle();
blocks.clear();
blockEntities.clear();
markers.clear();
objectBlocks.clear();
state = State.CLOSED;
@@ -150,11 +167,13 @@ final class ObjectPlacerEdit implements PlacementEdit {
}
private void writeBlocks() {
for (PlacedBlock block : blocks.values()) {
BlockPosition position = block.position();
placer.set(position.x(), position.y(), position.z(), states.toPlatform(block.state()));
block.blockEntity().ifPresent(entity -> placer.setTile(position.x(), position.y(), position.z(), BlockEntities.tileOf(entity)));
}
blocks.forEach((position, block) -> {
placer.set(position.x(), position.y(), position.z(), states.toPlatform(block));
BlockEntityData entity = blockEntities.get(position);
if (entity != null) {
placer.setTile(position.x(), position.y(), position.z(), BlockEntities.tileOf(entity));
}
});
}
private void writeMarkers() {
@@ -169,9 +188,8 @@ final class ObjectPlacerEdit implements PlacementEdit {
return;
}
for (BlockPosition position : objectBlocks) {
PlacedBlock written = blocks.get(position);
listener.accept(new art.arcane.volmlib.util.math.BlockPosition(position.x(), position.y(), position.z()),
states.toPlatform(written.state()));
states.toPlatform(blocks.get(position)));
}
}
@@ -21,6 +21,7 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.spi.IrisLogging;
import com.google.gson.Gson;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleLoadException;
import java.io.File;
import java.util.Arrays;
@@ -124,7 +125,7 @@ public final class PackModuleSet implements AutoCloseable {
pack = loaded;
state = State.LOADED;
warnWhenBuiltInModulesAreMissing(loaded);
} catch (RuntimeException loadFailure) {
} catch (ModuleLoadException loadFailure) {
failure = new PackModulesException(packFolder, loadFailure);
state = State.FAILED;
IrisLogging.error(failure.getMessage());
@@ -18,11 +18,13 @@
package art.arcane.iris.core.modules;
import com.volmit.host.ModuleLoadException;
import java.io.File;
/** A pack whose modules failed to load. The message names the pack and carries IrisApi's load error. */
public final class PackModulesException extends RuntimeException {
public PackModulesException(File packFolder, RuntimeException cause) {
public PackModulesException(File packFolder, ModuleLoadException cause) {
super("Pack " + packFolder.getName() + " cannot load its modules: " + cause.getMessage(), cause);
}
}
@@ -22,6 +22,7 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.PackModuleSet;
import art.arcane.iris.core.modules.PackModulesException;
import com.volmit.host.ModuleLoadException;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.volmlib.util.collection.KList;
import org.junit.Test;
@@ -42,7 +43,7 @@ public class DatapackIngestBrokenModulesTest {
when(dimensions.getPossibleKeys()).thenReturn(new String[]{"overworld"});
when(dimensions.loadAll(new String[]{"overworld"})).thenReturn(new KList<>(new IrisDimension()));
PackModuleSet modules = mock(PackModuleSet.class);
when(modules.pack()).thenThrow(new PackModulesException(new File("broken"), new IllegalArgumentException("Duplicate module example:moss")));
when(modules.pack()).thenThrow(new PackModulesException(new File("broken"), new ModuleLoadException(null, null, "Duplicate module example:moss", null)));
IrisData data = mock(IrisData.class);
when(data.getDimensionLoader()).thenReturn(dimensions);
when(data.getModules()).thenReturn(modules);
@@ -33,6 +33,7 @@ import com.volmit.ModuleSetup;
import com.volmit.config.Feature;
import com.volmit.config.PackSettings;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleLoadException;
import com.volmit.host.ResolvedGraph;
import com.volmit.host.schema.FeatureSchema;
import com.volmit.host.schema.ObjectType;
@@ -145,12 +146,12 @@ public class BuiltInGenerationGraphTest {
@Test
public void aModuleCannotTakeTheKeyOfABuiltInOrAFieldOfIris() {
IllegalArgumentException deposits = assertThrows(IllegalArgumentException.class,
ModuleLoadException deposits = assertThrows(ModuleLoadException.class,
() -> BuiltInPack.serve(mock(IrisData.class), folder, List.of(new RivalModule(TakesDeposits.class))));
assertEquals("region key \"deposits\" is claimed by iris:deposit (host classpath) and test:rival/deposits (host classpath);"
+ " give one of the settings another key in its @Feature", deposits.getMessage());
IllegalArgumentException field = assertThrows(IllegalArgumentException.class,
ModuleLoadException field = assertThrows(ModuleLoadException.class,
() -> BuiltInPack.serve(mock(IrisData.class), folder, List.of(new RivalModule(TakesAHostField.class))));
assertEquals("biome key \"generators\" is claimed by Iris and test:rival/generators (host classpath);"
+ " give one of the settings another key in its @Feature", field.getMessage());
@@ -29,6 +29,7 @@ import com.volmit.ModuleSetup;
import com.volmit.PackContext;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import com.volmit.host.ModuleLoadException;
import com.volmit.world.PackWorld;
import org.junit.After;
import org.junit.Before;
@@ -270,7 +271,7 @@ public class ModuleWorldsTest {
@Test
public void aPackWhoseModulesFailToLoadRunsItsWorldWithoutHooks() {
PackModuleSet broken = mock(PackModuleSet.class);
when(broken.pack()).thenThrow(new PackModulesException(folder.getRoot(), new IllegalArgumentException("broken jar")));
when(broken.pack()).thenThrow(new PackModulesException(folder.getRoot(), new ModuleLoadException(null, null, "broken jar", null)));
when(data.getModules()).thenReturn(broken);
EngineGeneration generation = generation();
@@ -20,6 +20,7 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleLoadException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -83,7 +84,7 @@ public class PackModuleJarNextToBuiltInsTest {
PackModuleJar.write(packFolder, "carve.jar", "pack.ported.Ported",
Map.of("pack.ported.Ported", module("ported", "Ported", builtInId)));
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
ModuleLoadException failure = assertThrows(ModuleLoadException.class,
() -> BuiltInPack.serve(mock(IrisData.class), folder, packFolder, List.of()));
assertEquals("Duplicate module " + builtInId + " from " + Path.of("modules", "carve.jar") + " (pack.ported.Ported); already loaded from host classpath ("
@@ -22,6 +22,7 @@ import art.arcane.volmlib.util.math.RNG;
import com.google.gson.JsonParser;
import com.volmit.host.LoadedPack;
import com.volmit.host.ModuleHost;
import com.volmit.host.ModuleLoadException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -74,7 +75,7 @@ public class SharedLibrariesTest {
public void withoutTheLibrariesExposedTheyAreIrissHiddenClasses() throws IOException {
Path pack = packWithSharedModule();
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> LoadedPack.load(pack,
ModuleLoadException failure = assertThrows(ModuleLoadException.class, () -> LoadedPack.load(pack,
ModuleHost.of(List.of()).exposing(IrisModuleHost.BUILT_IN_API_PACKAGE).copyingJarsTo(folder.newFolder().toPath())));
assertTrue(failure.getMessage(), failure.getMessage().contains("art.arcane.volmlib.util.math.RNG"));
@@ -31,7 +31,7 @@ public class IrisShoreLineDecoratorTest {
Fixture fixture = createFixture(false);
Hunk<BlockState> output = fixture.withSupport(AIR);
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.getHeight());
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.height());
assertSame(AIR, output.get(0, FLUID_HEIGHT + 1, 0));
verify(fixture.decorator).passesChanceGate(anyDouble(), anyDouble());
@@ -43,7 +43,7 @@ public class IrisShoreLineDecoratorTest {
Fixture fixture = createFixture(false);
Hunk<BlockState> output = fixture.withSupport(WATER);
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.getHeight());
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.height());
assertSame(AIR, output.get(0, FLUID_HEIGHT + 1, 0));
verify(fixture.decorator, never()).blockAt(anyDouble(), anyDouble(), anyDouble());
@@ -54,7 +54,7 @@ public class IrisShoreLineDecoratorTest {
Fixture fixture = createFixture(false);
Hunk<BlockState> output = fixture.withSupport(GRASS_BLOCK);
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.getHeight());
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.height());
assertSame(POPPY, output.get(0, FLUID_HEIGHT + 1, 0));
}
@@ -64,7 +64,7 @@ public class IrisShoreLineDecoratorTest {
Fixture fixture = createFixture(true);
Hunk<BlockState> output = fixture.withSupport(AIR);
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.getHeight());
fixture.shoreline.decorate(0, 0, 0, 1, -1, 0, 1, -1, BIOME, FLUID_HEIGHT, output.height());
assertSame(AIR, output.get(0, FLUID_HEIGHT + 1, 0));
}
@@ -371,7 +371,7 @@ public final class ApiChunk implements GenerationContext {
}
private BlockBox chunkColumns() {
return new BlockBox(originX, 0, originZ, originX + WIDTH, blocks.getHeight(), originZ + WIDTH);
return new BlockBox(originX, 0, originZ, originX + WIDTH, blocks.height(), originZ + WIDTH);
}
/** The dimension above, which is the one generated. */
@@ -406,7 +406,7 @@ public final class ApiChunk implements GenerationContext {
@Override
public BlockBox bounds() {
return new BlockBox(originX - TERRAIN_MARGIN, 0, originZ - TERRAIN_MARGIN, originX + WIDTH + TERRAIN_MARGIN,
blocks.getHeight(), originZ + WIDTH + TERRAIN_MARGIN);
blocks.height(), originZ + WIDTH + TERRAIN_MARGIN);
}
@Override
@@ -39,7 +39,7 @@ public class FloatingIslandsTest {
when(host.surfaceBiome(anyInt(), anyInt())).thenReturn(PLAIN_BIOME);
PackWorld world = world(host);
Hunk<BlockState> output = mock(Hunk.class);
when(output.getHeight()).thenReturn(64);
when(output.height()).thenReturn(64);
ChunkStageContext context = mock(ChunkStageContext.class, RETURNS_DEEP_STUBS);
when(context.originX()).thenReturn(CHUNK_ORIGIN);
when(context.originZ()).thenReturn(CHUNK_ORIGIN);
@@ -1,5 +1,6 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.builtin.blocks.WrittenBlocks;
import art.arcane.iris.builtin.carve.CarvingMode;
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
import art.arcane.iris.builtin.validate.ObjectLimit;
@@ -47,7 +48,6 @@ import com.volmit.object.GeneratedObject;
import com.volmit.object.ObjectBlock;
import com.volmit.object.ObjectTransform;
import com.volmit.host.LoadedPack;
import com.volmit.placement.PlacedBlock;
import com.volmit.stage.PlacementStage;
import com.volmit.stage.Stage;
import com.volmit.world.BlockPosition;
@@ -397,10 +397,10 @@ public class IrisObjectPlacementRegressionTest {
@Override
public void setup(ModuleSetup setup) {
setup.stages().define(CAP).requires(IrisStages.Blocks.COMPLETE, IrisStages.Blocks.WRITE).run(context -> {
List<PlacedBlock> written = context.output(IrisStages.Blocks.WRITE).blocks();
writtenSizes.add(written.size());
BlockPosition first = written.getFirst().position();
context.access().set(new PlacedBlock(new BlockPosition(0, first.y() + 1, 0), written.getFirst().state(), Optional.empty()));
WrittenBlocks written = context.output(IrisStages.Blocks.WRITE);
writtenSizes.add(written.positions().size());
BlockPosition first = written.positions().getFirst();
context.access().set(0, first.y() + 1, 0, written.states().getFirst());
});
}
}
+5 -3
View File
@@ -22,8 +22,9 @@
* apply from: new File(settingsDir, 'gradle/irisapi-resolution.settings.gradle')
*
* IrisApi is a separate project with no published artifact, so Iris always compiles against a sibling
* checkout as a composite build. Core declares `com.volmit:IrisApi`; this substitutes it with the
* checkout's root project.
* checkout as a composite build. Core declares `com.volmit:iris-api` (what modules see) and
* `com.volmit:iris-host` (what loads and runs them); this substitutes them with the checkout's `api`
* and `host` projects.
*
* Behaviour:
* -PlocalIrisApiDirectory=<path> explicit IrisApi checkout (relative paths resolve against the
@@ -79,6 +80,7 @@ File irisResolveLocalIrisApiDirectory() {
includeBuild(irisResolveLocalIrisApiDirectory()) {
dependencySubstitution {
substitute(module('com.volmit:IrisApi')).using(project(':'))
substitute(module('com.volmit:iris-api')).using(project(':api'))
substitute(module('com.volmit:iris-host')).using(project(':host'))
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ String volmLibCoordinate = providers.gradleProperty('volmLibCoordinate')
dependencies {
implementation(project(':core'))
// Module settings types the deserialization probe reads are IrisApi features.
compileOnly('com.volmit:IrisApi')
compileOnly('com.volmit:iris-api')
compileOnly(libs.spigot)
testImplementation('junit:junit:4.13.2')
testImplementation(volmLibCoordinate) {