A pack that loads none of the built-in modules is told once, with the jar to copy and where

This commit is contained in:
piexel committed 2026-10-10 14:25:56 +02:00
1 parent 9147acca0c
commit ee2a0425e2
6 files changed
+202 -1

No files matched your search

@@ -58,6 +58,12 @@ public final class IrisModuleHost {
public static final List<String> SHARED_LIBRARY_PACKAGES = List.of("art.arcane.volmlib", "com.google.gson");
/** Every package pack modules may use besides the IrisApi. {@code exposedHostPackages} in IrisModule's build lists the same. */
public static final List<String> EXPOSED_PACKAGES = Stream.concat(Stream.of(BUILT_IN_API_PACKAGE), SHARED_LIBRARY_PACKAGES.stream()).toList();
/**
* The ids of the built-in modules that ship in the built-ins jar ({@code iris-builtins.jar}, listed in
* {@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'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"};
@@ -0,0 +1,49 @@
/*
* 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 com.volmit.host.DiscoveredModule;
import java.io.File;
import java.util.Collection;
import java.util.Optional;
/**
* Notices a pack that loads without the built-in modules jar. Such a pack still loads and generates, but quietly without
* what the jar's modules do, so the owner is told once, with the fix.
*/
final class MissingBuiltInModules {
static final String JAR_NAME = "iris-builtins.jar";
private MissingBuiltInModules() {
}
/** What to tell the owner of {@code packFolder} whose pack loaded {@code packModules}; empty when the built-ins jar is there. */
static Optional<String> warning(File packFolder, Collection<DiscoveredModule> packModules) {
boolean builtInsLoaded = packModules.stream()
.map(module -> module.info().id().toString())
.anyMatch(IrisModuleHost.JAR_MODULE_IDS::contains);
if (builtInsLoaded) {
return Optional.empty();
}
return Optional.of("Pack " + packFolder.getName() + " loads without the built-in modules (" + JAR_NAME + "): its chunks get"
+ " no objects or structures, no surface smoothing and no clean-up of floating decorations. Copy " + JAR_NAME
+ " into " + new File(packFolder, PackModuleSet.MODULES_FOLDER).getPath() + " to fix it.");
}
}
@@ -37,8 +37,9 @@ import java.util.function.Supplier;
public final class PackModuleSet implements AutoCloseable {
private enum State { NOT_LOADED, LOADED, FAILED, CLOSED }
private static final String MODULES_FOLDER = "modules";
static final String MODULES_FOLDER = "modules";
private static final String JAR_EXTENSION = ".jar";
private static final String MISSING_BUILT_INS_KEY = "missing-built-in-modules:";
private final File packFolder;
private final Supplier<Gson> irisGson;
@@ -113,6 +114,7 @@ public final class PackModuleSet implements AutoCloseable {
pack = loaded;
settings = new ModuleSettingsDecoder(loaded.catalog(), packFolder.toPath(), irisGson);
state = State.LOADED;
warnWhenBuiltInModulesAreMissing(loaded);
} catch (RuntimeException loadFailure) {
failure = new PackModulesException(packFolder, loadFailure);
state = State.FAILED;
@@ -121,6 +123,11 @@ public final class PackModuleSet implements AutoCloseable {
}
}
private void warnWhenBuiltInModulesAreMissing(LoadedPack loaded) {
MissingBuiltInModules.warning(packFolder, loaded.packModules())
.ifPresent(warning -> IrisLogging.warnOnce(MISSING_BUILT_INS_KEY + packFolder.getAbsolutePath(), "%s", warning));
}
/** Each module jar's name, size and modification time, in name order. */
private List<String> jarFingerprint() {
File[] jars = new File(packFolder, MODULES_FOLDER).listFiles(file -> file.isFile() && file.getName().endsWith(JAR_EXTENSION));