Skip to content

Commit

Permalink
Detect neoforge.mods.toml on NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Apr 4, 2024
1 parent 7226922 commit 377c0e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public final class ModMetadataFiles {
private static final Map<String, Function<byte[], ModMetadataFile>> SINGLE_FILE_METADATA_TYPES = ImmutableMap.<String, Function<byte[], ModMetadataFile>>builder()
.put(QuiltModJson.FILE_NAME, QuiltModJson::of)
.put(ArchitecturyCommonJson.FILE_NAME, ArchitecturyCommonJson::of)
.put(ModsToml.FILE_PATH, onError(ModsToml::of, "Could not load mods.toml", () -> new ErroringModMetadataFile("mods.toml")))
.put(ModsToml.FILE_PATH, onError(ModsToml::of, "Could not load mods.toml", () -> new ErroringModMetadataFile(ModsToml.FILE_PATH)))
.put(ModsToml.NEOFORGE_FILE_PATH, onError(ModsToml::of, "Could not load mods.toml", () -> new ErroringModMetadataFile(ModsToml.NEOFORGE_FILE_PATH)))
.build();

private static <A, B> Function<A, B> onError(Function<A, B> fn, String message, Supplier<B> onError) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/architectury/loom/metadata/ModsToml.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

public final class ModsToml implements ModMetadataFile {
public static final String FILE_PATH = "META-INF/mods.toml";
public static final String NEOFORGE_FILE_PATH = "META-INF/neoforge.mods.toml";
private final Config config;

private ModsToml(Config config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static boolean isModJar(File file, ModPlatform platform) {

public static boolean isModJar(Path input, ModPlatform platform) {
if (platform.isForgeLike()) {
return ZipUtils.contains(input, "META-INF/mods.toml");
return ZipUtils.contains(input, "META-INF/mods.toml") || (platform == ModPlatform.NEOFORGE && ZipUtils.contains(input, "META-INF/neoforge.mods.toml"));
} else if (platform == ModPlatform.QUILT) {
return ZipUtils.contains(input, "quilt.mod.json") || isModJar(input, ModPlatform.FABRIC);
}
Expand All @@ -201,7 +201,7 @@ public static boolean containsMod(FileSystemUtil.Delegate fs, ModPlatform platfo
}

if (platform.isForgeLike()) {
return Files.exists(fs.getPath("META-INF/mods.toml"));
return Files.exists(fs.getPath("META-INF/mods.toml")) || (platform == ModPlatform.NEOFORGE && Files.exists(fs.getPath("META-INF/neoforge.mods.toml")));
} else if (platform == ModPlatform.QUILT) {
return Files.exists(fs.getPath("quilt.mod.json")) || containsMod(fs, ModPlatform.FABRIC);
}
Expand Down

0 comments on commit 377c0e9

Please sign in to comment.