mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
Should load from whatever minecraft comes from now...
This commit is contained in:
1 parent
55fe1aa1e3
commit
765194e8db
2 files changed
+33
-7
No files matched your search
@@ -324,14 +324,26 @@ public class Loader
|
||||
throw loaderException;
|
||||
}
|
||||
|
||||
state = State.LOADING;
|
||||
modClassLoader = new ModClassLoader();
|
||||
log.fine("Attempting to load mods contained in the minecraft jar file");
|
||||
attemptFileLoad(new File(minecraftDir, "minecraft_server.jar"));
|
||||
File minecraftSource=modClassLoader.getParentSource();
|
||||
if (minecraftSource.isFile()) {
|
||||
log.fine(String.format("Minecraft is a file at %s, loading",minecraftSource.getName()));
|
||||
attemptFileLoad(minecraftSource);
|
||||
} else if (minecraftSource.isDirectory()) {
|
||||
log.fine(String.format("Minecraft is a directory at %s, loading",minecraftSource.getName()));
|
||||
attemptDirLoad(minecraftSource);
|
||||
} else {
|
||||
log.severe(String.format("Unable to locate minecraft data at %s\n",minecraftSource.getName()));
|
||||
throw new LoaderException();
|
||||
}
|
||||
log.fine("Minecraft jar mods loaded successfully");
|
||||
|
||||
log.info(String.format("Loading mods from %s", canonicalModsPath));
|
||||
File[] modList = modsDir.listFiles();
|
||||
// Sort the files into alphabetical order first
|
||||
Arrays.sort(modList);
|
||||
state = State.LOADING;
|
||||
|
||||
for (File modFile : modList)
|
||||
{
|
||||
@@ -437,11 +449,6 @@ public class Loader
|
||||
|
||||
private void extendClassLoader(File file)
|
||||
{
|
||||
if (modClassLoader == null)
|
||||
{
|
||||
modClassLoader = new ModClassLoader();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
modClassLoader.addFile(file);
|
||||
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
@@ -38,4 +39,22 @@ public class ModClassLoader extends URLClassLoader
|
||||
URL url = modFile.toURI().toURL();
|
||||
super.addURL(url);
|
||||
}
|
||||
|
||||
public File getParentSource() {
|
||||
ClassLoader cl=getParent();
|
||||
if (cl instanceof URLClassLoader) {
|
||||
URLClassLoader ucl=(URLClassLoader) cl;
|
||||
URL pUrl=ucl.getURLs()[0];
|
||||
try
|
||||
{
|
||||
return new File(pUrl.toURI());
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
Loader.log.severe("Unable to process our input to locate the minecraft code");
|
||||
throw new LoaderException();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user