diff --git a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java index d8efdf9a4..4aaaf42cc 100644 --- a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java @@ -190,9 +190,12 @@ private void setup() throws ModResolutionException { boolean remapRegularMods = isDevelopmentEnvironment(); ModDiscoverer discoverer = new ModDiscoverer(); discoverer.addCandidateFinder(new ClasspathModCandidateFinder()); - discoverer.addCandidateFinder(new DirectoryModCandidateFinder(gameDir.resolve("mods"), remapRegularMods)); discoverer.addCandidateFinder(new ArgumentModCandidateFinder(remapRegularMods)); + Path modsFolder = gameDir.resolve("mods"); + discoverer.addCandidateFinder(new DirectoryModCandidateFinder(modsFolder, remapRegularMods, true)); + discoverer.addCandidateFinder(new DirectoryModCandidateFinder(modsFolder.resolve(getGameProvider().getNormalizedGameVersion()), remapRegularMods, false)); + modCandidates = discoverer.discoverMods(this); modCandidates = ModResolver.resolve(modCandidates); diff --git a/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java b/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java index eefcd4989..d7c5e4e0b 100644 --- a/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java +++ b/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java @@ -31,15 +31,21 @@ public class DirectoryModCandidateFinder implements ModCandidateFinder { private final Path path; private final boolean requiresRemap; + private final boolean shouldCreateFolder; public DirectoryModCandidateFinder(Path path, boolean requiresRemap) { + this(path, requiresRemap, true); + } + + public DirectoryModCandidateFinder(Path path, boolean requiresRemap, boolean shouldCreateFolder) { this.path = path; this.requiresRemap = requiresRemap; + this.shouldCreateFolder = shouldCreateFolder; } @Override public void findCandidates(ModCandidateConsumer out) { - if (!Files.exists(path)) { + if (shouldCreateFolder && !Files.exists(path)) { try { Files.createDirectory(path); } catch (IOException e) { @@ -47,6 +53,11 @@ public void findCandidates(ModCandidateConsumer out) { } } + // If the folder does not exist at this point it shouldn't be searched for mods + if (!Files.exists(path)) { + return; + } + if (!Files.isDirectory(path)) { throw new RuntimeException(path + " is not a directory!"); }