From 99cff4438382b5fe71eec476a5dfeae568cdb178 Mon Sep 17 00:00:00 2001 From: Jonathing Date: Tue, 2 Jul 2024 16:00:12 -0400 Subject: [PATCH] Choose default JarJar mod file type based on parent JAR (#10026) Co-authored-by: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> --- .../fml/loading/moddiscovery/AbstractModLocator.java | 7 ++++++- .../loading/moddiscovery/JarInJarDependencyLocator.java | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModLocator.java index 96e8f3eb66..4f301ecc2c 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModLocator.java @@ -31,6 +31,11 @@ public abstract class AbstractModLocator implements IModLocator protected static final String MANIFEST = "META-INF/MANIFEST.MF"; protected Optional createMod(Path... path) { + return this.createMod(getDefaultJarModType(), path); + } + + // FORGE: Backporting artifact, the defaultType must be the first parameter since path is varargs + protected Optional createMod(String defaultType, Path... path) { var mjm = new ModJarMetadata(); var sj = SecureJar.from( Manifest::new, @@ -42,7 +47,7 @@ public abstract class AbstractModLocator implements IModLocator IModFile mod; var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE); if (type == null) { - type = getDefaultJarModType(); + type = defaultType; } if (sj.findFile(MODS_TOML).isPresent()) { LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/JarInJarDependencyLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/JarInJarDependencyLocator.java index 3b81f03715..0409befe0b 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/JarInJarDependencyLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/JarInJarDependencyLocator.java @@ -81,7 +81,14 @@ public class JarInJarDependencyLocator extends AbstractJarFileDependencyLocator final Map outerFsArgs = ImmutableMap.of("packagePath", pathInModFile); final FileSystem zipFS = FileSystems.newFileSystem(filePathUri, outerFsArgs); final Path pathInFS = zipFS.getPath("/"); - return createMod(pathInFS); + final IModFile.Type parentType = file.getType(); + final String modType; + if (parentType == IModFile.Type.LIBRARY || parentType == IModFile.Type.LANGPROVIDER) { + modType = IModFile.Type.LIBRARY.name(); + } else { + modType = IModFile.Type.GAMELIBRARY.name(); + } + return createMod(modType, pathInFS); } catch (Exception e) {