Ship each built-in module as its own jar and let a pack's modules.json decide which update on their own

The built-ins no longer travel as one iris-builtins.jar that a pack has to
copy by hand. IrisModule builds one jar per module (the eight placement
stages share one) with an index of the id and version each module reports,
and Iris bundles that folder.

A pack lists the modules it uses in modules.json, with the version it was
built with and an optional pinned list. Before a pack loads, Iris installs
the jars of listed modules and replaces a jar that differs from the one it
ships. It keeps a jar when the module is pinned, when the pack holds a newer
version than Iris ships, and, in a world's copy of a pack, when the major
version changed, because new chunks would not match the old ones. A jar that
shares classes with a kept jar stays with it, since the two were compiled
against each other. /iris pack update takes the kept terrain changes for a
world. What is installed is recorded in modules.lock.json.

Module versions are now major.minor.patch per module, starting at 1.0.0,
with major meaning "places different blocks or stops loading settings".
This commit is contained in:
piexel committed 2026-11-11 12:51:53 +01:00
1 parent e7d1ed24cb
commit 6e96c6b71e
85 files changed
+2568 -480

No files matched your search

+80 -32
View File
@@ -6,7 +6,7 @@ the Iris API alone (see "Building" below); Iris depends on this project, never t
Ported features are IrisApi modules that every pack loads before its own: object placement
(`iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`,
`iris:vacuum`, `iris:snow`, shipped in the built-ins jar), the mantle, and chunk generation. Every mantle stage is a pass of Iris's
`iris:vacuum`, `iris:snow`, shipped as module jars), the mantle, and chunk generation. Every mantle stage is a pass of Iris's
mantle of its own, in the stage graph's order: `iris:carve/caves`, `iris:objects/place`,
`iris:floating/objects`, `iris:structure/place`, so a pack's mantle stage can order itself after any of
them. Chunk generation then runs, in this order: `iris:biome`, `iris:terrain`, `iris:carve` (cutting the
@@ -22,14 +22,14 @@ snippet type may live in either package. A type stays in `art.arcane.iris.builti
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.
the built-in module jars. 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, `setup.log()` during setup), 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.
Structures are two modules of the built-ins jar. `iris:structure` (`StructureModule`) is where structures go and how they
Structures are two built-in modules. `iris:structure` (`StructureModule`) is where structures go and how they
meet the terrain: it declares the structure placement settings and the mantle stage, validates the placements
(`StructureValidator`), provides `StructureLocator` and `VanillaStructures`, and brings the `/iris module structure`
commands. It gets the pieces of a structure only from the `StructureAssembly` providers of the pack's modules and knows
@@ -59,7 +59,7 @@ Object place modes are data (`PlaceMode`: height sampling,
stilt, `VacuumProfile`, `PlaceTrait`s) that the placement stages ask; the pack JSON keeps the mode names.
`iris:objects` also provides `SaplingGrowth` (`TreeGrowing`: the tree a sapling grows into, as placed blocks, and which
objects are trees) and says which biomes and regions place an object (`ObjectLocating`, for the object search).
`iris:objects` ships in the built-ins jar. It declares the settings `objects` (region, biome: the list of `ObjectPlacement`s),
`iris:objects` ships as a module jar. It declares the settings `objects` (region, biome: the list of `ObjectPlacement`s),
`proceduralObjects` (region, biome), `treeSettings` (dimension), `requireObjectSurfaceSupport`, `objectSurfaceSupportBuffer`,
`upperDimensionObjects` and `upperObjectsForcePlace` (dimension), all written as they always were. `ObjectPlacement` is the
placement itself, read by the module decoder like any settings class, and the one type Iris places with. What a jar cannot do, Iris does through the facades `ObjectHost` and
@@ -83,7 +83,7 @@ The settings of both modules are `builtin.loot` and `builtin.spawn` types of Iri
`iris:spawn` declares `entitySpawners` (list of spawner keys) for the same and `effects` (list, `iris:spawn/effects`) for
regions and biomes. The loot tables, spawners, entities and markers are plain module types too (`LootTable`, `Spawner`,
`EntityDefinition`, `SpawnMarker`). `PlacementLoot` picks the table an object placement gives one of its chests.
`iris:decorant`, `iris:terrain` and `iris:deposit` ship in the built-ins jar and keep their per-world workers (`BiomeDecorators`, `TerrainShaper`,
`iris:decorant`, `iris:terrain` and `iris:deposit` ship as module jars and keep their per-world workers (`BiomeDecorators`, `TerrainShaper`,
`DepositPlacer`) in the world's state store (`context.world().state(...)`); the modules still compiled into Iris reach the same store through
the `IrisChunk` their invocation offers (`context.extension(IrisChunk.class)`, then `state(...)`) or `engine.getGeneration().state(...)`.
@@ -135,7 +135,7 @@ 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. It asks the
`iris:floating` ships as a module 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,
@@ -168,35 +168,83 @@ styles, expressions, images), the pack's objects and blocks, and the placement s
A module this build holds but the jar does not is one Iris registers with its own modules (`IrisModuleHost`): its
classes are then the ones Iris's own code sees.
`./gradlew check` compiles every source and builds the built-ins jar below, which runs the pack class checks.
`./gradlew check` compiles every source and builds the module jars below, which runs the pack class checks.
## Built-in modules as a pack module jar
## Built-in modules as pack module jars
This build packages the built-in modules as an ordinary pack module jar, `build/libs/iris-builtins.jar`, from its own
classes, and Iris bundles it into the plugin: every pack loads it as if it were in its `modules/` folder (IrisApi's
`ModuleHost.bundlingJars`). A pack must not hold a copy of it: its classes would be in two jars, so the pack fails to load
naming both. `./gradlew builtinModulesJar` builds it. `builtin-modules.txt` lists what goes in: `module <class>` lines
(the jar's entry points, written to `META-INF/services/com.volmit.IrisModule`) and `include <pattern>` lines for further
classes. Iris asks for the jar by the capability `art.arcane:iris-builtins`; its plugin leaves the jar's classes out of
its own, and its Bukkit artifact check fails the build if Iris still uses one of them.
Before the jar is written, `ModuleJarCheck` of IrisApi runs the class checks of a pack load on it, with the packages Iris
exposes (`art.arcane.iris.builtin`, VolmLib's `art.arcane.volmlib` and Gson's `com.google.gson`, all three on the check's
classpath, with this build's other classes as the host's); a listed class that uses a class outside the jar and those
packages fails the task naming the class and what it uses. Iris checks the jar once more before bundling it, against the
VolmLib classes its Bukkit jar strips (`core/volmlib-left-out-of-bukkit-jar.txt`), which only Iris knows.
This build packages the built-in modules as ordinary pack module jars, `build/shipped-modules/iris-<name>.jar`, from its
own classes. `./gradlew shippedModules` builds them. `builtin-modules.txt` lists what goes in: a `jar <name>` line starts
a jar, `module <class>` lines name its entry points (written to the jar's `META-INF/services/com.volmit.IrisModule`) and
`include <pattern>` lines add further classes. A class goes into exactly one jar, and the build fails when two jars hold
the same class. Most jars hold one module. The eight object placement stages share one jar, `iris-placement.jar`, because
they share most of their classes.
The jar holds `iris:post`, `iris:perfection`, `iris:matter`, `iris:loot`, `iris:spawn`, `iris:vanilla-features` and
`iris:carve`, `iris:structure`, `iris:jigsaw`, and the object placement stages `iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`, `iris:vacuum` and `iris:snow`. They are
written against IrisApi and `art.arcane.iris.builtin` alone: the chunk's `BlockState` hunk, the block registry's traits and
`canPlaceOn`, the terrain sampler (heights around the chunk, slope, fluid height, where the upper dimension begins) and the
mantle's planned blocks; the placement stages read the placement being run through the `ObjectPlacement` facade, and the loot and
spawn services, which have no chunk to ask, ask the running world (`world.running()`, IrisApi's `RunningWorld`). Without the jar a pack's world has no caves, vanilla
placed features, loot, block drops, entity spawns or ambient effects, and its biomes' `loot`, `blockDrops`, `entitySpawners` and
`effects` are not read.
Iris no longer compiles them in (`IrisModuleHost.generationModules()`); every pack gets them from the bundled jar. A pack
still loads without them, as with an Iris build that bundles no jar, and 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.
Next to the jars the build writes `index.json`, which names each jar's hash and the id and version every module in it
reports. The id and version come from the module class, so a module's `ModuleInfo` is the only place to change them.
Before the jars ship, `ModuleJarCheck` of IrisApi runs the class checks of a pack load on all of them as one jar, with the
packages Iris exposes (`art.arcane.iris.builtin`, VolmLib's `art.arcane.volmlib` and Gson's `com.google.gson`, all three
on the check's classpath, with this build's other classes as the host's). A listed class that uses a class outside the
jars and those packages fails the task naming the class and what it uses. Iris runs the check once more against the
VolmLib classes its Bukkit jar strips (`core/volmlib-left-out-of-bukkit-jar.txt`), which only Iris knows. Iris asks for
the checked one-jar form by the capability `art.arcane:iris-builtins` and for the folder of shipped jars by
`art.arcane:iris-shipped-modules`. Its plugin leaves the jars' classes out of its own, and its Bukkit artifact check
fails the build if Iris still uses one of them.
The modules are written against IrisApi and `art.arcane.iris.builtin` alone: the chunk's `BlockState` hunk, the block
registry's traits and `canPlaceOn`, the terrain sampler (heights around the chunk, slope, fluid height, where the upper
dimension begins) and the mantle's planned blocks. The placement stages read the placement being run through the
`ObjectPlacement` facade, and the loot and spawn services, which have no chunk to ask, ask the running world
(`world.running()`, IrisApi's `RunningWorld`).
### How a pack gets them: modules.json
Iris bundles the folder of jars in its plugin and never loads a module from there. A pack names the modules it uses in
`modules.json`, and Iris copies the jars of those modules into the pack's `modules/` folder before the pack loads:
```json
{
"modules": {
"iris:terrain": "1.0.0",
"iris:carve": "1.0.0",
"acme:rivers": "0.9.0"
},
"pinned": []
}
```
The file belongs to the pack's author. The version beside a module is the one the pack was built and tested with, and
Iris never rewrites the file. `/iris std create` writes one that lists every module Iris ships. A module Iris does not
ship, such as `acme:rivers`, is listed the same way; its author's jar goes into `modules/` by hand and Iris never touches
it. A pack without `modules.json` gets no modules from Iris and is told so once.
What is installed right now is in `modules.lock.json`, which Iris writes when it changes a jar and after every load. Comparing the two files shows
what a pack was built with and what it runs on.
### When a module updates
A module's version is `major.minor.patch` with one fixed meaning:
- **major** rises when the same settings place different blocks, or settings stop loading.
- **minor** rises for new features that leave existing packs generating the same blocks.
- **patch** rises for fixes that leave the output alone.
When Iris ships a jar that differs from the pack's copy, it replaces the copy before the pack loads and logs one line per
module. The exceptions:
- A module in `pinned` stays as it is, always.
- A module the pack holds in a newer version than Iris ships stays. Iris does not downgrade.
- In a world's copy of a pack (`<world>/iris/pack`), a module whose major version changed stays, because its new chunks
would not match the chunks the world has. The world warns on every start until its owner runs `/iris pack update` in
it, which takes those updates too. A pack folder under `plugins/Iris/packs` takes every update, so its author tests
with what Iris ships.
- A module that uses classes of a kept module, or whose classes a kept module uses, stays with it. A pack loads all its
jars in one class loader, and a jar compiled against the new version of another may not link against the old one. Iris
reads the class references from the jars, so nothing declares these links by hand. Many of the built-ins use each
other's classes today, so keeping `iris:terrain` keeps most of the others.
Raising the major number is the author's call. Iris cannot tell whether a change alters terrain, so a release that
changes cave shapes under a minor number updates worlds and leaves a seam at the border of old and new chunks.
`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
+144 -78
View File
@@ -1,7 +1,6 @@
import org.gradle.api.tasks.bundling.ZipEntryCompression
import org.gradle.jvm.tasks.Jar
import java.io.ByteArrayOutputStream
import java.util.Properties
plugins {
`java-library`
@@ -38,7 +37,7 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.46")
}
// The same options as Iris's own compilation, so the classes, and the built-ins jar made from them, are the ones Iris
// The same options as Iris's own compilation, so the classes, and the module jars made from them, are the ones Iris
// shipped when it compiled these sources itself.
tasks.named<JavaCompile>("compileJava") {
options.encoding = "UTF-8"
@@ -51,52 +50,30 @@ tasks.named<JavaCompile>("compileJava") {
}
// The version every built-in module reports: Iris's own, so a pack's copy of the built-ins jar names the Iris build it came
// from. This included build does not inherit Iris's gradle.properties, so it reads irisVersion from there.
val irisVersion: String = providers.gradleProperty("irisVersion").orElse(provider {
Properties().apply { layout.projectDirectory.file("../gradle.properties").asFile.reader().use(::load) }
.getProperty("irisVersion")
}).get()
val generateBuiltInModulesVersion = tasks.register("generateBuiltInModulesVersion") {
description = "Writes BuiltInModulesVersion, which holds the version the built-in modules report."
val output = layout.buildDirectory.dir("generated/sources/builtin-modules-version")
inputs.property("irisVersion", irisVersion)
outputs.dir(output)
doLast {
val source = output.get().file("art/arcane/iris/modules/BuiltInModulesVersion.java").asFile
source.parentFile.mkdirs()
source.writeText("""
|package art.arcane.iris.modules;
|
|/** The version every built-in module reports: the Iris build the built-ins jar came from. Generated by the build. */
|public final class BuiltInModulesVersion {
| public static final String VERSION = "$irisVersion";
|
| private BuiltInModulesVersion() {
| }
|}
|""".trimMargin())
}
}
sourceSets.main {
java.srcDir(generateBuiltInModulesVersion)
}
// The built-ins as a pack module jar, build/libs/iris-builtins.jar. builtin-modules.txt lists what goes in:
// "module <class>" (an entry point, with its nested classes) or "include <ant pattern>".
val builtinModulesJarName = "iris-builtins.jar"
val builtinModuleEntryFile = "com.volmit.IrisModule"
// The built-in modules as pack module jars, one per "jar" section of builtin-modules.txt: build/shipped-modules/iris-<name>.jar,
// with index.json naming the id and version of every module in them. Iris bundles that folder and installs the jars a
// pack's modules.json lists.
val moduleEntryFile = "com.volmit.IrisModule"
val builtinModulesFile = layout.projectDirectory.file("builtin-modules.txt").asFile
val shippedJarPrefix = "iris-"
val shippedIndexName = "index.json"
// The packages an Iris host exposes to pack modules besides the API (Iris's IrisModuleHost.EXPOSED_PACKAGES).
val exposedHostPackages = listOf("art.arcane.iris.builtin", "art.arcane.iris.core.structure.authoring", "art.arcane.volmlib",
"com.google.gson")
data class BuiltinModulesList(val moduleClasses: List<String>, val classPatterns: List<String>)
data class ListedJar(val name: String, val moduleClasses: MutableList<String> = mutableListOf(),
val classPatterns: MutableList<String> = mutableListOf()) {
val fileName get() = "iris-$name.jar"
val taskSuffix get() = name.split('-').joinToString("") { it.replaceFirstChar(Char::uppercase) }
val packagedPatterns
get() = moduleClasses.flatMap { moduleClass ->
val path = moduleClass.replace('.', '/')
listOf("$path.class", "$path\$*.class")
} + classPatterns
}
fun readBuiltinModulesList(): BuiltinModulesList {
val moduleClasses = mutableListOf<String>()
val classPatterns = mutableListOf<String>()
fun readListedJars(): List<ListedJar> {
val jars = mutableListOf<ListedJar>()
builtinModulesFile.readLines()
.map { it.substringBefore('#').trim() }
.filter { it.isNotEmpty() }
@@ -105,51 +82,100 @@ fun readBuiltinModulesList(): BuiltinModulesList {
if (parts.size < 2 || parts[1].isBlank()) {
throw GradleException("${builtinModulesFile.name}: '$line' needs a value after '${parts[0]}'")
}
val value = parts[1].trim()
if (parts[0] == "jar") {
if (jars.any { it.name == value }) {
throw GradleException("${builtinModulesFile.name}: jar '$value' is listed twice")
}
jars.add(ListedJar(value))
return@forEach
}
val jar = jars.lastOrNull()
?: throw GradleException("${builtinModulesFile.name}: '$line' comes before the first 'jar' line")
when (parts[0]) {
"module" -> moduleClasses.add(parts[1].trim())
"include" -> classPatterns.add(parts[1].trim())
else -> throw GradleException("${builtinModulesFile.name}: unknown line '$line'; start it with 'module' or 'include'")
"module" -> jar.moduleClasses.add(value)
"include" -> jar.classPatterns.add(value)
else -> throw GradleException("${builtinModulesFile.name}: unknown line '$line'; start it with 'jar', 'module' or 'include'")
}
}
return BuiltinModulesList(moduleClasses, classPatterns)
jars.filter { it.moduleClasses.isEmpty() }.forEach {
throw GradleException("${builtinModulesFile.name}: jar '${it.name}' lists no module; a pack module jar needs one")
}
return jars
}
val builtinModulesList = readBuiltinModulesList()
val builtinPackagedPatterns = builtinModulesList.moduleClasses.flatMap { moduleClass ->
val path = moduleClass.replace('.', '/')
listOf("$path.class", "$path\$*.class")
} + builtinModulesList.classPatterns
val listedJars = readListedJars()
val builtinModulesBuild = layout.buildDirectory.dir("builtin-modules")
val writeBuiltinModuleEntries = tasks.register("writeBuiltinModuleEntries") {
description = "Writes the built-ins jar's META-INF/services/$builtinModuleEntryFile, one module class per line."
val entries = builtinModulesBuild.map { it.file("services/$builtinModuleEntryFile") }
fun entryFileOf(jar: ListedJar) = builtinModulesBuild.map { it.file("services/${jar.name}/$moduleEntryFile") }
val writeModuleEntries = tasks.register("writeModuleEntries") {
description = "Writes each jar's META-INF/services/$moduleEntryFile, one module class per line."
inputs.file(builtinModulesFile)
outputs.dir(builtinModulesBuild.map { it.dir("services") })
doLast {
listedJars.forEach { jar ->
val entriesFile = entryFileOf(jar).get().asFile
entriesFile.parentFile.mkdirs()
entriesFile.writeText(jar.moduleClasses.joinToString("\n") + "\n")
}
}
}
// A jar's bytes decide whether a pack's copy is the one Iris ships, so the same classes must give the same bytes.
fun Jar.packagedAsShippedModule() {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
// Iris's own jar compresses this one as a whole, which squeezes more out of the classes than compressing them twice.
entryCompression = ZipEntryCompression.STORED
inputs.file(builtinModulesFile)
}
val packageModuleJars = listedJars.map { listed ->
tasks.register<Jar>("package${listed.taskSuffix}ModuleJar") {
description = "Packages ${listed.fileName} before the built-in modules are checked."
archiveFileName.set(listed.fileName)
destinationDirectory.set(builtinModulesBuild.map { it.dir("jars") })
packagedAsShippedModule()
from(sourceSets.main.map { it.java.classesDirectory }) {
include(listed.packagedPatterns)
}
from(entryFileOf(listed)) {
into("META-INF/services")
}
dependsOn(writeModuleEntries)
}
}
// The checks judge a pack's jars together, as a pack load does, so they read all the built-ins as one jar. Nothing ships it.
val allModulesJarName = "iris-builtins.jar"
val writeAllModuleEntries = tasks.register("writeAllModuleEntries") {
description = "Writes the entry file that lists every built-in module, for the jar the checks read."
val entries = builtinModulesBuild.map { it.file("all-services/$moduleEntryFile") }
inputs.file(builtinModulesFile)
outputs.file(entries)
doLast {
val entriesFile = entries.get().asFile
entriesFile.parentFile.mkdirs()
entriesFile.writeText(builtinModulesList.moduleClasses.joinToString("\n") + "\n")
entriesFile.writeText(listedJars.flatMap { it.moduleClasses }.joinToString("\n") + "\n")
}
}
val packageBuiltinModules = tasks.register<Jar>("packageBuiltinModules") {
description = "Packages the listed built-in modules and classes before they are checked."
archiveFileName.set(builtinModulesJarName)
val packageAllModules = tasks.register<Jar>("packageAllModules") {
description = "Packages every built-in module into one jar for the pack module checks."
archiveFileName.set(allModulesJarName)
destinationDirectory.set(builtinModulesBuild.map { it.dir("unchecked") })
// Iris's own jar compresses this one as a whole, which squeezes more out of the classes than compressing them twice.
entryCompression = ZipEntryCompression.STORED
inputs.file(builtinModulesFile)
packagedAsShippedModule()
from(sourceSets.main.map { it.java.classesDirectory }) {
include(builtinPackagedPatterns)
include(listedJars.flatMap { it.packagedPatterns })
}
from(writeBuiltinModuleEntries) {
from(writeAllModuleEntries) {
into("META-INF/services")
}
}
// The check runs on the API's host side, which knows the rules of a pack load; the module classes are on its class path as
// the host's, so a listed class that uses one left out of the jar fails as it would in Iris.
// the host's, so a listed class that uses one left out of every jar fails as it would in Iris.
val builtinModulesCheckClasspath = configurations.create("builtinModulesCheckClasspath") {
isCanBeConsumed = false
isTransitive = false
@@ -158,19 +184,23 @@ val builtinModulesCheckClasspath = configurations.create("builtinModulesCheckCla
}
}
val tools = sourceSets.create("tools")
dependencies {
builtinModulesCheckClasspath("com.volmit:iris-api")
builtinModulesCheckClasspath("com.volmit:iris-host")
builtinModulesCheckClasspath(volmLibCoordinate)
builtinModulesCheckClasspath("com.google.code.gson:gson:2.14.0")
"toolsImplementation"("com.volmit:iris-api")
"toolsImplementation"("com.google.code.gson:gson:2.14.0")
}
val builtinModulesJar = tasks.register<JavaExec>("builtinModulesJar") {
val checkedModulesJar = tasks.register<JavaExec>("checkedModulesJar") {
group = "build"
description = "Builds build/libs/$builtinModulesJarName, the built-in modules as a pack module jar, checked with IrisApi's" +
" pack class and reference checks as a pack load would."
val unchecked = packageBuiltinModules.flatMap { it.archiveFile }
val checked = layout.buildDirectory.file("libs/$builtinModulesJarName")
description = "Checks the built-in modules with IrisApi's pack class and reference checks, as a pack load would, and" +
" writes them as one jar to build/libs/$allModulesJarName for Iris's own check."
val unchecked = packageAllModules.flatMap { it.archiveFile }
val checked = layout.buildDirectory.file("libs/$allModulesJarName")
classpath = builtinModulesCheckClasspath + files(sourceSets.main.map { it.java.classesDirectory })
mainClass.set("com.volmit.host.ModuleJarCheck")
inputs.file(unchecked)
@@ -185,15 +215,38 @@ val builtinModulesJar = tasks.register<JavaExec>("builtinModulesJar") {
}
doLast {
if (executionResult.get().exitValue != 0) {
throw GradleException("The built-in modules jar breaks the rules of a pack module jar:\n" + problems.toString().trim() +
"\nFix the classes listed in ${builtinModulesFile.name}, or move what they use into the jar or into art.arcane.iris.builtin.")
throw GradleException("The built-in modules break the rules of a pack module jar:\n" + problems.toString().trim() +
"\nFix the classes listed in ${builtinModulesFile.name}, or move what they use into a jar or into art.arcane.iris.builtin.")
}
unchecked.get().asFile.copyTo(checked.get().asFile, overwrite = true)
}
}
// Iris bundles the checked jar into its plugin. It asks for it by this capability of the module's coordinate.
configurations.create("builtinModulesJarElements") {
val writeShippedModuleIndex = tasks.register<JavaExec>("writeShippedModuleIndex") {
description = "Writes $shippedIndexName: the hash of every shipped module jar and the id and version its modules report."
val jars = files(packageModuleJars.map { it.flatMap(Jar::getArchiveFile) })
val index = builtinModulesBuild.map { it.file(shippedIndexName) }
classpath = tools.runtimeClasspath + builtinModulesCheckClasspath + files(sourceSets.main.map { it.java.classesDirectory })
mainClass.set("art.arcane.iris.modulebuild.ShippedModuleIndex")
inputs.files(jars)
outputs.file(index)
argumentProviders.add(CommandLineArgumentProvider {
listOf(index.get().asFile.absolutePath) + jars.files.sortedBy { it.name }.map { it.absolutePath }
})
// The index must not describe modules that failed the checks.
dependsOn(checkedModulesJar)
}
val shippedModulesFolder = layout.buildDirectory.dir("shipped-modules")
val shippedModules = tasks.register<Sync>("shippedModules") {
group = "build"
description = "Builds build/shipped-modules: the checked built-in module jars and their $shippedIndexName."
from(packageModuleJars)
from(writeShippedModuleIndex)
into(shippedModulesFolder)
}
fun Configuration.asModuleArtifacts(capability: String) {
isCanBeConsumed = true
isCanBeResolved = false
attributes {
@@ -202,16 +255,29 @@ configurations.create("builtinModulesJarElements") {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
outgoing.capability("art.arcane:iris-builtins:${project.version}")
outgoing.artifact(builtinModulesJar.map { layout.buildDirectory.file("libs/$builtinModulesJarName").get() }) {
builtBy(builtinModulesJar)
outgoing.capability("art.arcane:$capability:${project.version}")
}
// Iris checks the one-jar form once more against what its own Bukkit jar leaves out. It asks for it by this capability.
configurations.create("builtinModulesJarElements") {
asModuleArtifacts("iris-builtins")
outgoing.artifact(checkedModulesJar.map { layout.buildDirectory.file("libs/$allModulesJarName").get() }) {
builtBy(checkedModulesJar)
}
}
// Iris bundles the folder of shipped jars into its plugin. It asks for it by this capability.
configurations.create("shippedModulesElements") {
asModuleArtifacts("iris-shipped-modules")
outgoing.artifact(shippedModulesFolder) {
builtBy(shippedModules)
}
}
tasks.named("check") {
dependsOn(builtinModulesJar)
dependsOn(shippedModules)
}
tasks.named("assemble") {
dependsOn(builtinModulesJar)
dependsOn(shippedModules)
}
+55 -9
View File
@@ -1,30 +1,48 @@
# What goes into build/libs/iris-builtins.jar, the built-in modules as a pack module jar.
# The built-in modules, each as a pack module jar of its own: build/shipped-modules/iris-<name>.jar.
#
# A line is one of (blank lines and # comments are ignored):
#
# module <binary class name> an IrisModule class. It is listed in META-INF/services/com.volmit.IrisModule,
# jar <name> starts the jar iris-<name>.jar; the lines below it say what goes in.
# module <binary class name> an IrisModule class. It is listed in the jar's META-INF/services/com.volmit.IrisModule,
# and its nested classes are packaged with it.
# include <class pattern> more classes for the jar, as an Ant pattern relative to the class root, such as
# art/arcane/iris/engine/modifier/carve/** Settings types, helpers and stage
# constants a listed module owns go here.
#
# A class here must be one a pack module may have: it may use only the IrisApi, the packages Iris exposes
# (art.arcane.iris.builtin), the JDK and the other classes of the jar. `./gradlew builtinModulesJar` checks
# that with IrisApi's pack class checks and fails naming the class and what it uses.
# A class goes into exactly one jar. A pack loads all its jars in one class loader, so a jar may use the classes of
# another; Iris then updates those two jars together (PackModuleUpdates). Modules that share most of their classes share
# a jar, as the eight placement stages do.
#
# Moving a module here means removing it from IrisModuleHost.generationModules() in Iris.
# The settings and helper types only the jar's modules use, which Iris does not expose.
include art/arcane/iris/modules/**
# A class here must be one a pack module may have: it may use only the IrisApi, the packages Iris exposes
# (art.arcane.iris.builtin), the JDK and the classes of these jars. `./gradlew shippedModules` checks that with
# IrisApi's pack class checks and fails naming the class and what it uses.
#
# A module's version is the one its class reports (ModuleInfo). Raise the major number when the same settings place
# different blocks or settings stop loading, the minor number for new features and the patch number for fixes that
# leave the output alone: a world updates on its own only within a major version.
jar post
module art.arcane.iris.engine.modifier.PostModule
include art/arcane/iris/engine/modifier/SurfaceSmoothing*.class
include art/arcane/iris/modules/post/**
jar perfection
module art.arcane.iris.engine.modifier.PerfectionModule
jar matter
module art.arcane.iris.engine.modifier.MatterModule
jar loot
module art.arcane.iris.engine.loot.LootModule
include art/arcane/iris/engine/loot/**
include art/arcane/iris/modules/loot/**
jar spawn
module art.arcane.iris.engine.spawn.SpawnModule
include art/arcane/iris/engine/spawn/**
include art/arcane/iris/modules/spawn/**
jar placement
module art.arcane.iris.engine.object.placement.PrepareModule
module art.arcane.iris.engine.object.placement.AnchorModule
module art.arcane.iris.engine.object.placement.ValidateModule
@@ -40,8 +58,15 @@ include art/arcane/iris/engine/object/placement/ObjectEdits*.class
include art/arcane/iris/engine/object/placement/ResolvedReplace*.class
include art/arcane/iris/engine/object/placement/IrisSurfaceSupport*.class
include art/arcane/iris/engine/object/placement/IrisObjectVacuum.class
include art/arcane/iris/modules/placement/**
include art/arcane/iris/modules/blocks/**
jar vanilla-features
module art.arcane.iris.engine.framework.vanillafeatures.VanillaFeaturesModule
include art/arcane/iris/engine/framework/vanillafeatures/**
include art/arcane/iris/modules/vanillafeatures/**
jar carve
module art.arcane.iris.engine.modifier.CarveModule
include art/arcane/iris/engine/modifier/CaveApplying*.class
include art/arcane/iris/engine/modifier/CaveDressing.class
@@ -66,16 +91,28 @@ include art/arcane/iris/engine/object/terrain/carving/CaveProfileSampler*.class
include art/arcane/iris/engine/object/terrain/carving/DeclaredByLevel.class
include art/arcane/iris/engine/object/terrain/carving/DeclaredCaveProfiles.class
include art/arcane/iris/engine/object/terrain/carving/ResolvedCarvingEntry.class
include art/arcane/iris/modules/carve/**
jar deposit
module art.arcane.iris.engine.modifier.DepositModule
include art/arcane/iris/engine/modifier/DepositPlacer*.class
include art/arcane/iris/engine/modifier/DepositClump*.class
include art/arcane/iris/engine/modifier/ResolvedDeposit*.class
include art/arcane/iris/modules/deposit/**
jar decorant
module art.arcane.iris.engine.actuator.DecorantModule
include art/arcane/iris/engine/decorator/**
include art/arcane/iris/modules/decorant/**
jar terrain
module art.arcane.iris.engine.actuator.TerrainModule
include art/arcane/iris/engine/actuator/Terrain*.class
include art/arcane/iris/engine/actuator/ResolvedOre*.class
include art/arcane/iris/engine/actuator/OreWarmUp*.class
include art/arcane/iris/modules/terrain/**
jar objects
module art.arcane.iris.engine.mantle.components.ObjectModule
include art/arcane/iris/engine/mantle/components/ObjectPlacing*.class
include art/arcane/iris/engine/mantle/components/ChunkObjectPlacing*.class
@@ -90,6 +127,9 @@ include art/arcane/iris/engine/mantle/components/TreeGrowing*.class
include art/arcane/iris/engine/mantle/components/ObjectChunk*.class
include art/arcane/iris/engine/mantle/components/GoldenDebugTerrain*.class
include art/arcane/iris/engine/procedural/**
include art/arcane/iris/modules/objects/**
jar floating
module art.arcane.iris.engine.modifier.FloatingModule
include art/arcane/iris/engine/modifier/FloatingIslands*.class
include art/arcane/iris/engine/object/terrain/floating/**
@@ -98,6 +138,9 @@ include art/arcane/iris/engine/mantle/components/FloatingPlacer*.class
include art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver*.class
include art/arcane/iris/engine/mantle/components/IslandFace*.class
include art/arcane/iris/engine/mantle/components/UndersideTurn*.class
include art/arcane/iris/modules/floating/**
jar structure
module art.arcane.iris.engine.mantle.components.StructureModule
include art/arcane/iris/engine/mantle/components/StructurePlacing*.class
include art/arcane/iris/engine/mantle/components/StructureCarvingFootprint*.class
@@ -121,6 +164,8 @@ include art/arcane/iris/engine/framework/structure/StructureValidator*.class
include art/arcane/iris/engine/framework/structure/StructureVanillaStructures*.class
include art/arcane/iris/engine/framework/structure/StructureWorld*.class
include art/arcane/iris/core/modules/StructureCommands*.class
jar jigsaw
module art.arcane.iris.modules.jigsaw.JigsawModule
include art/arcane/iris/engine/object/structure/**
include art/arcane/iris/engine/framework/StructureAssembler*.class
@@ -147,3 +192,4 @@ include art/arcane/iris/core/structure/conversion/**
include art/arcane/iris/core/structure/export/**
include art/arcane/iris/core/structure/tooling/**
include art/arcane/iris/core/pack/StructurePackageClosure*.class
include art/arcane/iris/modules/jigsaw/**
@@ -25,10 +25,10 @@
* Keep implementation out of it: stage bodies and anything that uses Iris internals live in the
* built-in module classes outside this package, which packs cannot see. Settings and output types go in one
* subpackage per built-in module, named after the module path, such as {@code art.arcane.iris.builtin.spawn}
* for {@code iris:spawn}. A type only the built-ins jar uses, which Iris itself never reads, lives in
* for {@code iris:spawn}. A type only the built-in module jars use, which Iris itself never reads, lives in
* {@code art.arcane.iris.modules} instead, which Iris does not expose.
* <p>
* Besides those, it holds what Iris and the built-ins jar must share, since each sees its own copy
* Besides those, it holds what Iris and the built-in module jars must share, since each sees its own copy
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
* ({@link art.arcane.iris.builtin.structure.StructureVerifier}), and the seed purposes of the built-in features
* ({@link art.arcane.iris.builtin.IrisSeedPurposes}). Keep them few: each is a promise.
@@ -20,7 +20,6 @@ package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.decorant.DecorantSettings;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.decorant.DecorateSettings;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.decorator.DecoratedBiome;
@@ -47,7 +46,7 @@ import com.volmit.world.TerrainSampler;
* {@link DecorateSettings}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
*/
public final class DecorantModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -56,7 +55,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
@Override
public void setup(ModuleSetup setup) {
// Ordering only: iris:matter ships in the built-ins jar, which a pack may not have.
// Ordering only: iris:matter ships as a module jar, which a pack may not have.
setup.stages().define(IrisStages.Decorant.DECORATE).softAfter(IrisStages.Matter.INSERT).run(DecorantModule::decorate);
var registry = setup.registry();
registry.registerSettings(DecorantSettings.class);
@@ -19,7 +19,6 @@ package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.terrain.BedrockSettings;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.terrain.BiomePalettes;
import art.arcane.iris.modules.terrain.CaveCeilingLayersSettings;
import art.arcane.iris.modules.terrain.ExplodeBiomePaletteSizeSettings;
@@ -53,7 +52,7 @@ import java.util.List;
* and the rock and fluid palettes' noise are built ahead of generation, in {@link #warmUp}.
*/
public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -18,7 +18,6 @@
package art.arcane.iris.engine.framework.vanillafeatures;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.vanillafeatures.ImportedFeaturesSettings;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
@@ -32,7 +31,7 @@ import com.volmit.service.VanillaFeatures;
* platform runs the feature pass itself; the module has no stages.
*/
public final class VanillaFeaturesModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -18,7 +18,6 @@
package art.arcane.iris.engine.loot;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.loot.BlockDropSettings;
import art.arcane.iris.builtin.loot.LootSettings;
import com.volmit.IrisModule;
@@ -34,7 +33,7 @@ import com.volmit.service.Loot;
* a container is filled and through {@link BlockDrops} when a player breaks a block.
*/
public final class LootModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -24,7 +24,6 @@ import art.arcane.iris.builtin.objects.ObjectSettings;
import art.arcane.iris.engine.procedural.ProceduralObjectCatalog;
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.objects.PackObjectScenes;
import art.arcane.iris.modules.objects.ProceduralObjectScenes;
import art.arcane.iris.modules.objects.TreeGrowthSettings;
@@ -54,7 +53,7 @@ import java.util.List;
* the studio with every variant of its procedural objects ({@link PackObjectScenes}, {@link ProceduralObjectScenes}).
*/
public final class ObjectModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -64,7 +63,7 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
@Override
public void setup(ModuleSetup setup) {
ModuleLog log = setup.log();
// Ordering only: iris:carve ships in the built-ins jar, which a pack may not have.
// Ordering only: iris:carve ships as a module jar, which a pack may not have.
setup.stages().define(IrisStages.Objects.PLACE).softAfter(IrisStages.Carve.CAVES).reach(settings -> reach(settings, log))
.run(ObjectModule::place);
var registry = setup.registry();
@@ -25,7 +25,6 @@ import art.arcane.iris.core.modules.StructureCommands;
import art.arcane.iris.engine.framework.structure.StructureLocating;
import art.arcane.iris.engine.framework.structure.StructureValidator;
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
import art.arcane.iris.modules.BuiltInModulesVersion;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
@@ -46,7 +45,7 @@ import com.volmit.stage.MantleStageContext;
* providers of the pack's modules, such as {@code iris:jigsaw}, and knows none of them.
*/
public final class StructureModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -20,7 +20,6 @@ package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisSeedPurposes;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.carve.CarvingBiomeSettings;
import art.arcane.iris.modules.carve.CarvingEnabledSettings;
import art.arcane.iris.modules.carve.CarvingSettings;
@@ -60,7 +59,7 @@ import java.util.function.Function;
* {@link CaveCarving}, one per world. The chunk stage's work is done by {@link CaveApplying}.
*/
public final class CarveModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
/** Blended cave walls reach one block past the chunk. */
private static final int CAVE_REACH_BLOCKS = 1;
@@ -19,7 +19,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.deposit.DepositGenerator;
import art.arcane.iris.modules.deposit.DepositSettings;
import art.arcane.iris.modules.deposit.DepositVariantSettings;
@@ -41,7 +40,7 @@ import java.util.List;
* of its columns a biome border crosses.
*/
public final class DepositModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -19,7 +19,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.floating.FloatingChildSettings;
import art.arcane.iris.modules.floating.MergeFloatingChildrenSettings;
import art.arcane.iris.engine.mantle.components.FloatingObjectPlacing;
@@ -38,7 +37,7 @@ import com.volmit.stage.MantleStageContext;
* placement. The chunk stages' work is done by {@link FloatingIslands}.
*/
public final class FloatingModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
private ModuleLog log;
@@ -57,9 +56,9 @@ public final class FloatingModule implements IrisModule {
var graph = setup.stages();
graph.define(IrisStages.Floating.OBJECTS).softAfter(IrisStages.Objects.PLACE).reach(this::objectReach)
.run(FloatingModule::objects);
// Ordering only: iris:post ships in the built-ins jar, which a pack may not have.
// Ordering only: iris:post ships as a module jar, which a pack may not have.
graph.define(IrisStages.Floating.SOLIDS).softAfter(IrisStages.Post.SMOOTH).run(FloatingModule::solids);
// Ordering only: iris:decorant ships in the built-ins jar, which a pack may not have.
// Ordering only: iris:decorant ships as a module jar, which a pack may not have.
graph.define(IrisStages.Floating.DECORATE).softAfter(IrisStages.Decorant.DECORATE).run(FloatingModule::decorate);
}
@@ -19,7 +19,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleSetup;
@@ -36,7 +35,7 @@ import com.volmit.world.TerrainSampler;
* only where a level declares some.
*/
public final class MatterModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
private static final int CHUNK_WIDTH = 16;
private static final int NO_LIMIT = Integer.MAX_VALUE;
@@ -19,7 +19,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.terrain.HideOresSettings;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
@@ -43,7 +42,7 @@ import java.util.Map;
* is left, since removing one can strand the one above.
*/
public final class PerfectionModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
private static final String HALF = "half";
private static final BlockState AIR = new BlockState("minecraft:air");
private static final Map<ResourceId, BlockState> ORE_BASES = oreBases();
@@ -19,7 +19,6 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.post.PostProcessingSettings;
import art.arcane.iris.modules.post.PostProcessingSlabsSettings;
import art.arcane.iris.modules.post.PostProcessingWallsSettings;
@@ -29,7 +28,7 @@ import com.volmit.ModuleSetup;
/** Module {@code iris:post}: smooths the carved surface with {@link SurfaceSmoothing}. */
public final class PostModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -42,7 +41,7 @@ public final class PostModule implements IrisModule {
registry.registerSettings(PostProcessingSettings.class);
registry.registerSettings(PostProcessingSlabsSettings.class);
registry.registerSettings(PostProcessingWallsSettings.class);
// Ordering only: iris:carve ships in the built-ins jar, which a pack may not have.
// Ordering only: iris:carve ships as a module jar, which a pack may not have.
setup.stages().define(IrisStages.Post.SMOOTH).softAfter(IrisStages.Carve.APPLY).run(SurfaceSmoothing::smooth);
}
}
@@ -18,11 +18,10 @@
package art.arcane.iris.engine.object.placement;
import art.arcane.iris.modules.BuiltInModulesVersion;
/** What Iris's built-in object placement modules share: the version they report. The modules ship in the built-ins jar. */
/** What Iris's built-in object placement modules share: the version they report. The modules ship as module jars. */
final class PlacementModules {
static final String VERSION = BuiltInModulesVersion.VERSION;
static final String VERSION = "1.0.0";
private PlacementModules() {
}
@@ -18,7 +18,6 @@
package art.arcane.iris.engine.spawn;
import art.arcane.iris.modules.BuiltInModulesVersion;
import art.arcane.iris.modules.spawn.EffectSettings;
import art.arcane.iris.modules.spawn.SpawnerSettings;
import com.volmit.IrisModule;
@@ -35,7 +34,7 @@ import com.volmit.service.EntitySpawns;
* through {@link AmbientEffects} for the effects due around a player.
*/
public final class SpawnModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -24,7 +24,6 @@ import art.arcane.iris.engine.framework.structure.JigsawStructureAssembly;
import art.arcane.iris.engine.framework.structure.JigsawValidator;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.framework.structure.assembly.StructureAssembly;
import art.arcane.iris.modules.BuiltInModulesVersion;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleSetup;
@@ -40,7 +39,7 @@ import com.volmit.tooling.DatapackStructureImport;
* first command that needs it creates. The studio closes with its tool world, which the host closes when it stops.
*/
public final class JigsawModule implements IrisModule {
private static final String VERSION = BuiltInModulesVersion.VERSION;
private static final String VERSION = "1.0.0";
@Override
public ModuleInfo info() {
@@ -0,0 +1,147 @@
/*
* 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.modulebuild;
import com.google.gson.GsonBuilder;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* Writes the index of the module jars Iris ships: per jar its file name, the hash of its bytes and the id and version each
* of its modules reports. Iris reads the index to tell what it ships without loading a jar. The module classes are on this
* tool's class path, so the id and version come from the class that reports them at run time.
*/
public final class ShippedModuleIndex {
private static final String ENTRY_POINT_FILE = "META-INF/services/" + IrisModule.class.getName();
private static final String CLASS_FILE_SUFFIX = ".class";
private static final String HASH_ALGORITHM = "SHA-256";
private static final String USAGE = "Usage: ShippedModuleIndex <index file to write> <module jar>...";
private static final int FAILED_EXIT_CODE = 1;
private static final int MISSING_ARGUMENT_EXIT_CODE = 2;
private record IndexedModule(String id, String version) {
}
private record IndexedJar(String file, String sha256, List<IndexedModule> modules) {
}
private record Index(List<IndexedJar> jars) {
}
private ShippedModuleIndex() {
}
public static void main(String[] arguments) throws IOException {
if (arguments.length < 2) {
System.err.println(USAGE);
System.exit(MISSING_ARGUMENT_EXIT_CODE);
}
List<Path> jars = Arrays.stream(arguments).skip(1).map(Path::of).toList();
try {
requireEachClassInOneJar(jars);
Files.writeString(Path.of(arguments[0]), toJson(indexOf(jars)), StandardCharsets.UTF_8);
} catch (IllegalStateException problem) {
System.err.println(problem.getMessage());
System.exit(FAILED_EXIT_CODE);
}
}
private static String toJson(Index index) {
return new GsonBuilder().setPrettyPrinting().create().toJson(index) + "\n";
}
private static Index indexOf(List<Path> jars) throws IOException {
List<IndexedJar> indexed = new ArrayList<>();
for (Path jar : jars) {
indexed.add(new IndexedJar(jar.getFileName().toString(), hashOf(jar), modulesOf(jar)));
}
return new Index(indexed);
}
/** A pack loads all its jars in one class loader, which refuses a class that two jars hold. */
private static void requireEachClassInOneJar(List<Path> jars) throws IOException {
Map<String, Path> owners = new HashMap<>();
for (Path jar : jars) {
for (String classEntry : classEntriesOf(jar)) {
Path owner = owners.putIfAbsent(classEntry, jar);
if (owner != null) {
throw new IllegalStateException(classEntry + " is in both " + owner.getFileName() + " and " + jar.getFileName()
+ "; list it under one jar in builtin-modules.txt");
}
}
}
}
private static List<String> classEntriesOf(Path jar) throws IOException {
try (JarFile file = new JarFile(jar.toFile())) {
return file.stream().map(JarEntry::getName).filter(name -> name.endsWith(CLASS_FILE_SUFFIX)).toList();
}
}
private static List<IndexedModule> modulesOf(Path jar) throws IOException {
List<IndexedModule> modules = new ArrayList<>();
for (String entryClass : entryClassesOf(jar)) {
ModuleInfo info = instantiate(entryClass).info();
modules.add(new IndexedModule(info.id().toString(), info.version()));
}
return modules;
}
private static List<String> entryClassesOf(Path jar) throws IOException {
try (JarFile file = new JarFile(jar.toFile())) {
JarEntry entryPoints = file.getJarEntry(ENTRY_POINT_FILE);
if (entryPoints == null) {
throw new IllegalStateException(jar.getFileName() + " lists no module; give its jar a module line in builtin-modules.txt");
}
String listed = new String(file.getInputStream(entryPoints).readAllBytes(), StandardCharsets.UTF_8);
return listed.lines().map(String::strip).filter(line -> !line.isEmpty()).toList();
}
}
private static IrisModule instantiate(String entryClass) {
try {
return (IrisModule) Class.forName(entryClass).getConstructor().newInstance();
} catch (ReflectiveOperationException failure) {
throw new IllegalStateException("Cannot create module " + entryClass + " to read its id and version: " + failure, failure);
}
}
private static String hashOf(Path jar) throws IOException {
try {
return HexFormat.of().formatHex(MessageDigest.getInstance(HASH_ALGORITHM).digest(Files.readAllBytes(jar)));
} catch (NoSuchAlgorithmException missing) {
throw new IllegalStateException("This JDK has no " + HASH_ALGORITHM, missing);
}
}
}