Batch 4 of the API review: api and host artifacts, ModuleLoadException

- Split into Gradle subprojects api (com.volmit:iris-api) and host
  (com.volmit:iris-host). ExposedPackages never exposes com.volmit.host.
- One unchecked ModuleLoadException(moduleId, origin, message, cause)
  for every load error; messages unchanged.
- PlacementAccess.set(x, y, z, state) next to set(PlacedBlock).
- BlockState: precompiled patterns, withProperty copies once.
- Mantle and layer views are made once per invocation.
- Hunk getters are width(), height(), depth().
- Held types and host types are deprecated for removal at the cut-over.
- Docs: artifacts, one-or-more modules per jar, no option shorthand.
This commit is contained in:
piexel committed 2026-10-24 04:19:39 +02:00
1 parent 3a307b5b8e
commit b6c2992752
309 files changed
+547 -178

No files matched your search

@@ -0,0 +1,52 @@
package com.volmit.generation;
import com.volmit.config.FeatureSettings;
import com.volmit.mantle.BlockBox;
import com.volmit.world.TerrainSampler;
/** What chunk and mantle invocations share: the chunk they run for, its terrain and its settings. X and Z are world
* coordinates; heights are above the dimension's bottom. Must not be retained after execution.
*/
public interface ChunkContext extends InvocationContext {
/** The width of a chunk along X and Z, in blocks. */
int CHUNK_WIDTH = 16;
/** The local X and Z of a chunk's centre column, where something that happens once per chunk reads its settings. */
int CENTRE_COLUMN = 7;
/** The chunk's first block along X, in world coordinates. */
int originX();
/** The chunk's first block along Z, in world coordinates. */
int originZ();
TerrainSampler terrain();
FeatureSettings settings();
/** The chunk's X in chunk coordinates. */
default int chunkX() {
return Math.floorDiv(originX(), CHUNK_WIDTH);
}
/** The chunk's Z in chunk coordinates. */
default int chunkZ() {
return Math.floorDiv(originZ(), CHUNK_WIDTH);
}
/** The world X of the chunk's centre column (local 7). */
default int centreX() {
return originX() + CENTRE_COLUMN;
}
/** The world Z of the chunk's centre column (local 7). */
default int centreZ() {
return originZ() + CENTRE_COLUMN;
}
/** The chunk's 16 by 16 columns in world coordinates, at the full height the terrain covers. */
default BlockBox area() {
var bounds = terrain().bounds();
return new BlockBox(originX(), bounds.minY(), originZ(), originX() + CHUNK_WIDTH, bounds.maxY(), originZ() + CHUNK_WIDTH);
}
}
@@ -0,0 +1,37 @@
package com.volmit.generation;
import com.volmit.hunk.Hunk;
import com.volmit.mantle.Mantle;
import com.volmit.world.TerrainSampler;
/** Per-invocation chunk generation inputs. Must not be retained after execution. */
public interface GenerationContext extends ChunkContext {
/** World coordinates of the local volume's first column. The volume starts at the dimension's bottom:
* local y is the height above it (0 = bottom block).
*/
@Override
int originX();
@Override
int originZ();
/** The terrain of the chunk and of the 16 blocks around it on every side, at full height: a chunk stage writes only
* its own chunk, but may look at its neighbors' terrain, such as their heights.
*/
@Override
TerrainSampler terrain();
/** Non-null mantle access scoped to this invocation; the host owns its lifetime. Like {@link #terrain()} it covers
* the chunk and the 16 blocks around it, so a stage that places something against a neighbor can see what the mantle
* holds there. A chunk stage writes module layers inside its own chunk's columns only, such as markers it derives
* from the chunk's finished blocks: the mantle pipeline has finished around the chunk, and a neighbor may already
* be generated, so writes outside the chunk throw UnsupportedOperationException, as do writes to
* {@link Mantle#blocks()} and {@link Mantle#edit()}.
*/
Mantle mantle();
/** The host-owned local volume of the given value type, shared by all stages of this
* invocation. Unsupported types throw IllegalArgumentException.
*/
<T> Hunk<T> hunk(Class<T> type);
}
@@ -0,0 +1,33 @@
package com.volmit.generation;
import com.volmit.ModuleLog;
import com.volmit.world.PackWorld;
import java.util.Optional;
/** Host-owned invocation inputs. Views must not be retained or used by detached tasks.
*
* <p>There is no shared random stream. A stage draws from {@link com.volmit.stage.StageContext#random()},
* a stream of its own, and an object generator from {@link com.volmit.object.ObjectGenerationContext#random()}.
*/
public interface InvocationContext {
/** The world this invocation generates: its seed, the pack snapshot's resources, its settings and the state modules
* keep for it ({@link PackWorld#state}). Every invocation has one. A placement a tool makes outside a world the host
* generates, such as a studio paste, gets a world of its own that lives for that placement.
*/
PackWorld world();
/** The log of the module this invocation runs for, labelled with the module's id. The same as {@code world().log()}. */
default ModuleLog log() {
return world().log();
}
/**
* What the host offers for this one invocation beyond the API, as an object of {@code type}: empty when the host
* offers no such thing. The per invocation counterpart of {@link PackWorld#extension}: a host hands its own modules
* inputs that belong to one placement or one chunk this way, such as what Iris knows about the placement that is
* running. The host fills it for each invocation; like every input it must not be kept after the invocation.
*/
default <T> Optional<T> extension(Class<T> type) {
return Optional.empty();
}
}
@@ -0,0 +1,17 @@
package com.volmit.generation;
import com.volmit.mantle.Mantle;
import com.volmit.world.TerrainSampler;
/** Per-invocation inputs of the mantle pipeline for one chunk. Must not be retained after execution. */
public interface MantleGenerationContext extends ChunkContext {
/** The terrain of the chunk and of the larger of the stage's reach and 16 blocks around it on every side, at full
* height: a mantle stage writes only the mantle, but may look at the terrain around its chunk, such as the heights
* a cave blends over its borders.
*/
@Override
TerrainSampler terrain();
/** The mantle of the chunk widened by the pipeline's reach, full height (heights 0 up to the dimension height). Writes outside it throw. */
Mantle mantle();
}