From 7eee9dcbcdcedbc2587dc3613048961840fff92e Mon Sep 17 00:00:00 2001 From: Jonathing Date: Sat, 29 Jun 2024 01:55:31 -0400 Subject: [PATCH] Choose default JarJar mod file type based on parent JAR (#10023) Co-authored-by: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> --- .../fml/loading/moddiscovery/AbstractModProvider.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/AbstractModProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java index d88cf407ac..3f8b98be36 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java @@ -34,6 +34,11 @@ public abstract class AbstractModProvider implements IModProvider protected static final String MANIFEST = "META-INF/MANIFEST.MF"; protected IModLocator.ModFileOrException createMod(Path... path) { + return this.createMod(getDefaultJarModType(), path); + } + + // FORGE: Backporting artifact, the defaultType must be the first parameter since path is varargs + protected IModLocator.ModFileOrException createMod(String defaultType, Path... path) { var mjm = new ModJarMetadata(); var sj = SecureJar.from( Manifest::new, @@ -45,7 +50,7 @@ public abstract class AbstractModProvider implements IModProvider IModFile mod; var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE); if (type == null) { - type = getDefaultJarModType(); + type = defaultType; } if (sj.moduleDataProvider().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 10f26579f1..1c9e0b6213 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 Optional.of(createMod(pathInFS).file()); + 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 Optional.of(createMod(modType, pathInFS).file()); } catch (Exception e) {