diff --git a/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java b/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java index c266b19ba..81fe60db9 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java @@ -371,7 +371,7 @@ public class CoreModManager { ignoredModFiles.add(coreMod.getName()); continue; } - ModListHelper.additionalMods.putAll(extractContainedDepJars(jar, versionedModDir)); + ModListHelper.additionalMods.putAll(extractContainedDepJars(jar, coreMods, versionedModDir)); fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin"); if (fmlCorePlugin == null) { @@ -424,7 +424,7 @@ public class CoreModManager { } } - private static Map extractContainedDepJars(JarFile jar, File versionedModsDir) throws IOException + private static Map extractContainedDepJars(JarFile jar, File baseModsDir, File versionedModsDir) throws IOException { Map result = Maps.newHashMap(); if (!jar.getManifest().getMainAttributes().containsKey(MODCONTAINSDEPS)) return result; @@ -433,7 +433,8 @@ public class CoreModManager { String[] depList = deps.split(" "); for (String dep : depList) { - if (skipContainedDeps.contains(dep)) + String depEndName = new File(dep).getName(); // extract last part of name + if (skipContainedDeps.contains(dep) || skipContainedDeps.contains(depEndName)) { FMLRelaunchLog.log(Level.ERROR, "Skipping dep at request: %s", dep); continue; @@ -444,26 +445,34 @@ public class CoreModManager { FMLRelaunchLog.log(Level.ERROR, "Found invalid ContainsDeps declaration %s in %s", dep, jar.getName()); continue; } - File target = new File(versionedModsDir, dep); + File target = new File(versionedModsDir, depEndName); + File modTarget = new File(baseModsDir, depEndName); if (target.exists()) { FMLRelaunchLog.log(Level.DEBUG, "Found existing ContainsDep extracted to %s, skipping extraction", target.getCanonicalPath()); result.put(dep,target); continue; } - FMLRelaunchLog.log(Level.DEBUG, "Extracted ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath()); + else if (modTarget.exists()) + { + FMLRelaunchLog.log(Level.DEBUG, "Found ContainsDep in main mods directory at %s, skipping extraction", modTarget.getCanonicalPath()); + result.put(dep, modTarget); + continue; + } + + FMLRelaunchLog.log(Level.DEBUG, "Extracting ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath()); try { Files.createParentDirs(target); FileOutputStream targ = new FileOutputStream(target); ByteStreams.copy(jar.getInputStream(jarEntry), targ); targ.close(); + FMLRelaunchLog.log(Level.DEBUG, "Extracted ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath()); + result.put(dep,target); } catch (IOException e) { FMLRelaunchLog.log(Level.ERROR, e, "An error occurred extracting dependency"); - continue; } - result.put(dep,target); } return result; }