diff --git a/gradle.properties b/gradle.properties index 5a05db1f..cafc83e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,13 +7,13 @@ org.gradle.caching=true #org.gradle.configuration-cache=true # Versions -versionConnector=2.0.0-beta.5 +versionConnector=2.0.0-beta.6 versionAdapter=1.13.20+1.21.1-20240811.191740 versionAdapterDefinition=1.13.23+1.21.1 versionAdapterRuntime=1.0.0+1.21.1 versionMc=1.21.1 -versionNeoForge=21.1.90 +versionNeoForge=21.1.97 versionParchmentMc=1.21 versionParchment=2024.07.28 versionForgeAutoRenamingTool=1.0.12 diff --git a/src/main/java/org/sinytra/connector/locator/ConnectorEarlyLocatorBootstrap.java b/src/main/java/org/sinytra/connector/locator/ConnectorEarlyLocatorBootstrap.java index 49d4d703..92013ed7 100644 --- a/src/main/java/org/sinytra/connector/locator/ConnectorEarlyLocatorBootstrap.java +++ b/src/main/java/org/sinytra/connector/locator/ConnectorEarlyLocatorBootstrap.java @@ -1,6 +1,5 @@ package org.sinytra.connector.locator; -import com.mojang.logging.LogUtils; import cpw.mods.jarhandling.SecureJar; import net.neoforged.fml.loading.moddiscovery.readers.JarModsDotTomlModFileReader; import net.neoforged.neoforgespi.ILaunchContext; @@ -12,9 +11,7 @@ import org.apache.logging.log4j.core.Filter; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.filter.MarkerFilter; -import org.sinytra.connector.ConnectorEarlyLoader; import org.sinytra.connector.service.DummyVirtualJar; -import org.slf4j.Logger; import java.util.Arrays; import java.util.Locale; @@ -27,26 +24,9 @@ * An ugly hack to sort FML dependency providers and make sure {@link ConnectorLocator ours} comes last. */ public class ConnectorEarlyLocatorBootstrap implements IModFileCandidateLocator { - private static final Logger LOGGER = LogUtils.getLogger(); - private static ILaunchContext launchContext; public ConnectorEarlyLocatorBootstrap() { - // Unfortunately, FML doesn't provide a way to sort mod/dependency locators by priority, so we have to create our own - try { -// Method method = FMLLoader.class.getDeclaredMethod("getModDiscoverer"); -// method.setAccessible(true); -// ModDiscoverer discoverer = (ModDiscoverer) method.invoke(null); -// Field field = ModDiscoverer.class.getDeclaredField("dependencyLocatorList"); -// field.setAccessible(true); -// List dependencyLocatorList = (List) field.get(discoverer); -// // 1 - move under; 0 - preserve original order -// dependencyLocatorList.sort(Comparator.comparingInt(loc -> loc instanceof ConnectorLocator ? 1 : 0)); - } catch (Throwable t) { - LOGGER.error("Error sorting FML dependency locators", t); - // We can't throw here as that would prevent the connector mod from loading and lead to fabric loader being loaded twice instead - ConnectorEarlyLoader.addGenericLoadingException(t, "Error sorting FML dependency locators"); - } injectLogMarkers(); } diff --git a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java index 93038a55..72e0fac1 100644 --- a/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java +++ b/src/main/java/org/sinytra/connector/locator/ConnectorLocator.java @@ -27,6 +27,7 @@ import org.sinytra.connector.locator.filter.SplitPackageMerger; import org.sinytra.connector.transformer.jar.JarTransformer; import org.sinytra.connector.util.ConnectorUtil; +import org.sinytra.connector.util.PriorityModLoadingException; import org.slf4j.Logger; import java.io.IOException; @@ -75,6 +76,8 @@ public void scanMods(List loadedMods, IDiscoveryPipeline pipeline) { } loadEmbeddedJars(pipeline); + } catch (PriorityModLoadingException e) { + throw e; } catch (ModLoadingException e) { // Let these pass through ConnectorEarlyLoader.addGenericLoadingException(e.getIssues()); diff --git a/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java b/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java index bc2f8c6f..ce293ba1 100644 --- a/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java +++ b/src/main/java/org/sinytra/connector/locator/MixinTransformSafeguard.java @@ -7,6 +7,7 @@ import org.sinytra.adapter.patch.api.PatchAuditTrail; import org.sinytra.connector.transformer.jar.JarTransformer; import org.sinytra.connector.util.ConnectorConfig; +import org.sinytra.connector.util.PriorityModLoadingException; import org.slf4j.Logger; import java.util.List; @@ -41,6 +42,6 @@ public static void trigger(List failing builder.append("\n"); }); - throw new ModLoadingException(ModLoadingIssue.error(builder.toString())); + throw new PriorityModLoadingException(ModLoadingIssue.error(builder.toString())); } } diff --git a/src/main/java/org/sinytra/connector/service/FabricMixinBootstrap.java b/src/main/java/org/sinytra/connector/service/FabricMixinBootstrap.java index 45c00a00..ebc14569 100644 --- a/src/main/java/org/sinytra/connector/service/FabricMixinBootstrap.java +++ b/src/main/java/org/sinytra/connector/service/FabricMixinBootstrap.java @@ -25,6 +25,7 @@ import net.fabricmc.loader.impl.FabricLoaderImpl; import net.neoforged.fml.loading.LoadingModList; import net.neoforged.fml.loading.moddiscovery.ModFileInfo; +import net.neoforged.fml.loading.moddiscovery.ModFileParser; import org.sinytra.connector.ConnectorEarlyLoader; import org.slf4j.Logger; import org.spongepowered.asm.mixin.FabricUtil; @@ -49,13 +50,13 @@ public static void init() { Map configToModMap = new HashMap<>(); for (ModFileInfo modFile : LoadingModList.get().getModFiles()) { - List mixinConfigs = modFile.getFile().getMixinConfigs(); + List mixinConfigs = modFile.getFile().getMixinConfigs(); if (mixinConfigs != null) { - for (String config : mixinConfigs) { - if (Files.exists(modFile.getFile().findResource(config))) { - ModFileInfo prev = configToModMap.putIfAbsent(config, modFile); + for (ModFileParser.MixinConfig config : mixinConfigs) { + if (Files.exists(modFile.getFile().findResource(config.config()))) { + ModFileInfo prev = configToModMap.putIfAbsent(config.config(), modFile); if (prev != null) - LOGGER.debug("Non-unique Mixin config name {} used by the mods {} and {}", config, prev.moduleName(), modFile.moduleName()); + LOGGER.debug("Non-unique Mixin config name {} used by the mods {} and {}", config.config(), prev.moduleName(), modFile.moduleName()); } } } @@ -122,7 +123,7 @@ else if (dep.getKind() == ModDependency.Kind.BREAKS) { if (reqIntervals.isEmpty()) throw new IllegalStateException("mod " + metadata.getId() + " is incompatible with every loader version?"); // shouldn't get there - Version minLoaderVersion = reqIntervals.get(0).getMin(); // it is sorted, to 0 has the absolute lower bound + Version minLoaderVersion = reqIntervals.getFirst().getMin(); // it is sorted, to 0 has the absolute lower bound if (minLoaderVersion != null) { // has a lower bound for (LoaderMixinVersionEntry version : VERSIONS) { diff --git a/src/main/java/org/sinytra/connector/util/PriorityModLoadingException.java b/src/main/java/org/sinytra/connector/util/PriorityModLoadingException.java new file mode 100644 index 00000000..5d711422 --- /dev/null +++ b/src/main/java/org/sinytra/connector/util/PriorityModLoadingException.java @@ -0,0 +1,16 @@ +package org.sinytra.connector.util; + +import net.neoforged.fml.ModLoadingException; +import net.neoforged.fml.ModLoadingIssue; + +import java.util.List; + +public class PriorityModLoadingException extends ModLoadingException { + public PriorityModLoadingException(ModLoadingIssue issue) { + super(issue); + } + + public PriorityModLoadingException(List issues) { + super(issues); + } +} diff --git a/src/mod/resources/META-INF/neoforge.mods.toml b/src/mod/resources/META-INF/neoforge.mods.toml index 9fae89b1..d5909a34 100644 --- a/src/mod/resources/META-INF/neoforge.mods.toml +++ b/src/mod/resources/META-INF/neoforge.mods.toml @@ -21,7 +21,7 @@ config="connector.mixins.json" [[dependencies.connector]] modId="neoforge" type="required" - versionRange="*" + versionRange="[21.1.97,)" ordering="NONE" side="BOTH" [[dependencies.connector]]