Add in a mechanism to get the modcontainer for a mod - so things can be programmatically changed
This commit is contained in:
parent
a7caad10ba
commit
5a5ff97f39
|
@ -581,7 +581,7 @@ public class ModLoader
|
||||||
*/
|
*/
|
||||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||||
{
|
{
|
||||||
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel);
|
FMLCommonHandler.instance().registerChannel(FMLCommonHandler.instance().findContainerFor(mod), channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -150,7 +150,22 @@ public class FMLCommonHandler
|
||||||
{
|
{
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Find the container that associates with the supplied mod object
|
||||||
|
* @param mod
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ModContainer findContainerFor(Object mod)
|
||||||
|
{
|
||||||
|
for (ModContainer mc : Loader.getModList())
|
||||||
|
{
|
||||||
|
if (mc.matches(mod))
|
||||||
|
{
|
||||||
|
return mc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Lookup the mod for a channel
|
* Lookup the mod for a channel
|
||||||
* @param channel
|
* @param channel
|
||||||
|
|
|
@ -163,11 +163,11 @@ public class Loader
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
try {
|
try {
|
||||||
properties.load(stream);
|
properties.load(stream);
|
||||||
major = properties.getProperty("fmlbuild.major.number");
|
major = properties.getProperty("fmlbuild.major.number","none");
|
||||||
minor = properties.getProperty("fmlbuild.minor.number");
|
minor = properties.getProperty("fmlbuild.minor.number","none");
|
||||||
rev = properties.getProperty("fmlbuild.revision.number");
|
rev = properties.getProperty("fmlbuild.revision.number","none");
|
||||||
build = properties.getProperty("fmlbuild.build.number");
|
build = properties.getProperty("fmlbuild.build.number","none");
|
||||||
mcversion = properties.getProperty("fmlbuild.mcversion");
|
mcversion = properties.getProperty("fmlbuild.mcversion","none");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Loader.log.log(Level.SEVERE,"Could not get FML version information - corrupted installation detected!", ex);
|
Loader.log.log(Level.SEVERE,"Could not get FML version information - corrupted installation detected!", ex);
|
||||||
throw new LoaderException(ex);
|
throw new LoaderException(ex);
|
||||||
|
@ -545,9 +545,10 @@ public class Loader
|
||||||
extendClassLoader(modFile);
|
extendClassLoader(modFile);
|
||||||
boolean foundAModClass = false;
|
boolean foundAModClass = false;
|
||||||
|
|
||||||
|
ZipFile jar = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ZipFile jar = new ZipFile(modFile);
|
jar = new ZipFile(modFile);
|
||||||
|
|
||||||
for (ZipEntry ze : Collections.list(jar.entries()))
|
for (ZipEntry ze : Collections.list(jar.entries()))
|
||||||
{
|
{
|
||||||
|
@ -571,6 +572,19 @@ public class Loader
|
||||||
state = State.ERRORED;
|
state = State.ERRORED;
|
||||||
capturedError = e;
|
capturedError = e;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (jar != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jar.close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return foundAModClass;
|
return foundAModClass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ModLoaderHelper
|
||||||
*/
|
*/
|
||||||
private static ModLoaderModContainer findOrBuildModContainer(BaseMod mod)
|
private static ModLoaderModContainer findOrBuildModContainer(BaseMod mod)
|
||||||
{
|
{
|
||||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
ModLoaderModContainer mlmc=(ModLoaderModContainer) FMLCommonHandler.instance().findContainerFor(mod);
|
||||||
if (mlmc==null) {
|
if (mlmc==null) {
|
||||||
mlmc=notModCallbacks.get(mod);
|
mlmc=notModCallbacks.get(mod);
|
||||||
if (mlmc==null) {
|
if (mlmc==null) {
|
||||||
|
|
|
@ -363,17 +363,10 @@ public class ModLoaderModContainer implements ModContainer
|
||||||
return mod != null ? mod.getName() : modClazz.getSimpleName();
|
return mod != null ? mod.getName() : modClazz.getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static ModContainer findContainerFor(BaseMod mod)
|
public static ModContainer findContainerFor(BaseMod mod)
|
||||||
{
|
{
|
||||||
for (ModContainer mc : Loader.getModList())
|
return FMLCommonHandler.instance().findContainerFor(mod);
|
||||||
{
|
|
||||||
if (mc.matches(mod))
|
|
||||||
{
|
|
||||||
return mc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -565,7 +565,7 @@ public class ModLoader
|
||||||
*/
|
*/
|
||||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||||
{
|
{
|
||||||
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel);
|
FMLCommonHandler.instance().registerChannel(FMLCommonHandler.instance().findContainerFor(mod), channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue