Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mod addition feature not recognizing Quilt mods #789

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public void filesDragged(List<Path> paths) {
Path modsDirectory = FabricLoader.getInstance().getGameDir().resolve("mods");

// Filter out none mods
List<Path> mods = paths.stream().filter(ModsScreen::isFabricMod).collect(Collectors.toList());
List<Path> mods = paths.stream().filter(ModsScreen::isValidMod).collect(Collectors.toList());

if (mods.isEmpty()) {
return;
Expand Down Expand Up @@ -638,9 +638,15 @@ public void filesDragged(List<Path> paths) {
}, ModMenuScreenTexts.DROP_CONFIRM, Text.literal(modList)));
}

private static boolean isFabricMod(Path mod) {
private static boolean isValidMod(Path mod) {
try (JarFile jarFile = new JarFile(mod.toFile())) {
return jarFile.getEntry("fabric.mod.json") != null;
var isFabricMod = jarFile.getEntry("fabric.mod.json") != null;

if (!ModMenu.RUNNING_QUILT) {
return isFabricMod;
} else {
return isFabricMod || jarFile.getEntry("quilt.mod.json") != null;
}
} catch (IOException e) {
return false;
}
Expand Down
Loading