Skip to content

Commit

Permalink
Fix Quilt mods not being recognized as valid when dragged over the mo…
Browse files Browse the repository at this point in the history
…ds screen
  • Loading branch information
LostLuma committed Oct 13, 2024
1 parent 51c25d3 commit 8b0059b
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 8b0059b

Please sign in to comment.