Skip to content

Commit

Permalink
Fix mod addition feature not recognizing Quilt mods (#789)
Browse files Browse the repository at this point in the history
- Fix drag-n-drop not supporting Quilt mods
  • Loading branch information
LostLuma authored Oct 14, 2024
1 parent 54c9ef0 commit fcca915
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit fcca915

Please sign in to comment.