Add module display names, reject duplicate pack classes, log pack modules

ModuleInfo gains a required, non-blank display name next to id and
version: ModuleInfo.of(id, name, version).

PackModules now fails when a class is in two jars of one pack, naming
the class and both jars. ModuleJar indexes class names while it reads
the entry point, so the check runs before the pack class loader exists
and nothing is half-loaded. Jars are read with the runtime's
multi-release version, like the loader reads them: a versioned class
counts once under its base name; module-info.class and anything under
META-INF/ are ignored.

A successful load logs one INFO summary through System.Logger with the
display name, id, version and jar of each module, or a line saying the
pack has no module jars. PackModulesSummary builds the text and is
tested without a logging backend.
This commit is contained in:
piexel committed 2026-10-05 18:02:31 +02:00
1 parent 4fa6ddcd7a
commit b137bc6d92
19 files changed
+328 -53

No files matched your search

@@ -31,6 +31,16 @@ class ApiValuesTest {
assertThrows(IllegalArgumentException.class, () -> new ResourceKey<>("test:value", int.class));
}
@Test
void moduleInfoRequiresANameAndVersion() {
var info = ModuleInfo.of("example:moss", "Moss", "1.0.0");
assertEquals(ResourceId.parse("example:moss"), info.id());
assertEquals("Moss", info.name());
assertThrows(IllegalArgumentException.class, () -> ModuleInfo.of("example:moss", " ", "1.0.0"));
assertThrows(IllegalArgumentException.class, () -> ModuleInfo.of("example:moss", "Moss", ""));
assertThrows(NullPointerException.class, () -> ModuleInfo.of("example:moss", null, "1.0.0"));
}
@Test
void sparseObjectsCopySortAndRejectDuplicateOrOutOfBoundsBlocks() {
var a = new ObjectBlock(new BlockPosition(-1, 0, 0), new BlockState("minecraft:stone"));