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
6 changed files with 159 additions and 137 deletions
|
@ -38,7 +38,7 @@ public class ModLoader
|
|||
public static final Map<String,Map<String,String>> localizedStrings=Collections.emptyMap();
|
||||
/**
|
||||
* Not used on the server.
|
||||
*
|
||||
*
|
||||
* @param achievement
|
||||
* @param name
|
||||
* @param description
|
||||
|
@ -52,9 +52,9 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
*
|
||||
*
|
||||
* {@link FMLCommonHandler#fuelLookup(int, int)}
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
|
@ -144,7 +144,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
*
|
||||
* @param fileToOverride
|
||||
* @param fileToAdd
|
||||
* @return
|
||||
|
@ -158,7 +158,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* @param overlayPath
|
||||
* @param index
|
||||
|
@ -217,7 +217,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
|
@ -246,7 +246,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
*
|
||||
* @param entityName
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
|
@ -262,7 +262,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
|
@ -365,7 +365,7 @@ public class ModLoader
|
|||
/**
|
||||
* This is not the server
|
||||
* {@link FMLClientHandler#getServer()}
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Object getMinecraftServerInstance()
|
||||
|
@ -390,7 +390,7 @@ public class ModLoader
|
|||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
|
@ -403,7 +403,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Stubbed method on the server to return a unique model id
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
|
@ -425,11 +425,11 @@ public class ModLoader
|
|||
{
|
||||
return SpriteHelper.getUniqueSpriteIndex(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your
|
||||
* channel is active prior to sending the packet
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param channel
|
||||
* @return
|
||||
|
@ -447,7 +447,7 @@ public class ModLoader
|
|||
/**
|
||||
* Is the named mod loaded?
|
||||
* {@link Loader#isModLoaded(String)}
|
||||
*
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
|
@ -499,7 +499,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
|
||||
*
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -520,7 +520,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
public static void registerBlock(Block block)
|
||||
|
@ -530,7 +530,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
*
|
||||
* @param block
|
||||
* @param itemclass
|
||||
*/
|
||||
|
@ -541,7 +541,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
|
@ -553,7 +553,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
|
@ -575,18 +575,18 @@ public class ModLoader
|
|||
* channel with Forge Mod Loader, not with clients connecting- use
|
||||
* BaseMod.onClientLogin to tell them about your custom channel
|
||||
* {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)}
|
||||
*
|
||||
*
|
||||
* @param mod
|
||||
* @param channel
|
||||
*/
|
||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||
{
|
||||
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel);
|
||||
FMLCommonHandler.instance().registerChannel(FMLCommonHandler.instance().findContainerFor(mod), channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new tile entity class
|
||||
*
|
||||
*
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
*/
|
||||
|
@ -602,7 +602,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a biome from the list of generated biomes
|
||||
*
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void removeBiome(BiomeGenBase biome)
|
||||
|
@ -612,7 +612,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
*/
|
||||
|
@ -623,7 +623,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
|
@ -635,7 +635,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
*/
|
||||
|
@ -646,7 +646,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
|
@ -689,7 +689,7 @@ public class ModLoader
|
|||
/**
|
||||
* Send a chat message to the server
|
||||
* {@link FMLClientHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -716,7 +716,7 @@ public class ModLoader
|
|||
ModLoaderHelper.updateStandardTicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateGUITicks(mod, enable, useClock);
|
||||
|
@ -725,7 +725,7 @@ public class ModLoader
|
|||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
|
@ -739,7 +739,7 @@ public class ModLoader
|
|||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
|
@ -753,7 +753,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
|
@ -766,7 +766,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#onItemSmelted(EntityPlayer, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
|
@ -778,7 +778,7 @@ public class ModLoader
|
|||
/**
|
||||
* Throw the offered exception. Likely will stop the game.
|
||||
* {@link FMLClientHandler#raiseException(Throwable, String, boolean)}
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param e
|
||||
*/
|
||||
|
@ -786,7 +786,7 @@ public class ModLoader
|
|||
{
|
||||
FMLCommonHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
|
||||
public static void throwException(Throwable e)
|
||||
{
|
||||
throwException("Exception in ModLoader", e);
|
||||
|
|
|
@ -41,14 +41,14 @@ import cpw.mods.fml.common.ModContainer.SourceType;
|
|||
|
||||
/**
|
||||
* The main class for non-obfuscated hook handling code
|
||||
*
|
||||
* Anything that doesn't require obfuscated or client/server specific code should
|
||||
*
|
||||
* Anything that doesn't require obfuscated or client/server specific code should
|
||||
* go in this handler
|
||||
*
|
||||
*
|
||||
* It also contains a reference to the sided handler instance that is valid
|
||||
* allowing for common code to access specific properties from the obfuscated world
|
||||
* without a direct dependency
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
|
@ -72,18 +72,18 @@ public class FMLCommonHandler
|
|||
*/
|
||||
private Map<Object, Set<String>> activeChannels = new HashMap<Object, Set<String>>();
|
||||
/**
|
||||
* The delegate for side specific data and functions
|
||||
* The delegate for side specific data and functions
|
||||
*/
|
||||
private IFMLSidedHandler sidedDelegate;
|
||||
|
||||
|
||||
private int uniqueEntityListId = 220;
|
||||
|
||||
private List<ModContainer> auxilliaryContainers = new ArrayList<ModContainer>();
|
||||
|
||||
private Map<String,Properties> modLanguageData=new HashMap<String,Properties>();
|
||||
|
||||
|
||||
private Set<ITickHandler> tickHandlers = new HashSet<ITickHandler>();
|
||||
|
||||
|
||||
private Set<IWorldGenerator> worldGenerators = new HashSet<IWorldGenerator>();
|
||||
/**
|
||||
* We register our delegate here
|
||||
|
@ -113,7 +113,7 @@ public class FMLCommonHandler
|
|||
}
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
|
||||
|
||||
public void tickEnd(EnumSet<TickType> ticks, Object ... data)
|
||||
{
|
||||
sidedDelegate.profileStart("modTickEnd$"+ticks);
|
||||
|
@ -130,7 +130,7 @@ public class FMLCommonHandler
|
|||
}
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
|
||||
|
||||
public List<IKeyHandler> gatherKeyBindings() {
|
||||
List<IKeyHandler> allKeys=new ArrayList<IKeyHandler>();
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
|
@ -150,7 +150,22 @@ public class FMLCommonHandler
|
|||
{
|
||||
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
|
||||
* @param channel
|
||||
|
@ -308,7 +323,7 @@ public class FMLCommonHandler
|
|||
{
|
||||
return sidedDelegate.loadBaseModMod(clazz, canonicalFile);
|
||||
}
|
||||
|
||||
|
||||
public File getMinecraftRootDirectory() {
|
||||
return sidedDelegate.getMinecraftRootDirectory();
|
||||
}
|
||||
|
@ -342,7 +357,7 @@ public class FMLCommonHandler
|
|||
modLanguageData.put(lang, langPack);
|
||||
}
|
||||
langPack.put(key,value);
|
||||
|
||||
|
||||
handleLanguageLoad(sidedDelegate.getCurrentLanguageTable(), lang);
|
||||
}
|
||||
|
||||
|
@ -367,7 +382,7 @@ public class FMLCommonHandler
|
|||
{
|
||||
return sidedDelegate.getSide();
|
||||
}
|
||||
|
||||
|
||||
public void addAuxilliaryModContainer(ModContainer ticker)
|
||||
{
|
||||
auxilliaryContainers.add(ticker);
|
||||
|
@ -375,7 +390,7 @@ public class FMLCommonHandler
|
|||
|
||||
/**
|
||||
* Called from the furnace to lookup fuel values
|
||||
*
|
||||
*
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
|
@ -383,24 +398,24 @@ public class FMLCommonHandler
|
|||
public int fuelLookup(int itemId, int itemDamage)
|
||||
{
|
||||
int fv = 0;
|
||||
|
||||
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage));
|
||||
}
|
||||
|
||||
|
||||
return fv;
|
||||
}
|
||||
|
||||
|
||||
public void addNameForObject(Object minecraftObject, String lang, String name) {
|
||||
String label=sidedDelegate.getObjectName(minecraftObject);
|
||||
addStringLocalization(label, lang, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Raise an exception
|
||||
*
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
* @param stopGame
|
||||
|
@ -411,10 +426,10 @@ public class FMLCommonHandler
|
|||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Class<?> forge;
|
||||
private boolean noForge;
|
||||
|
||||
|
||||
private Class<?> findMinecraftForge()
|
||||
{
|
||||
if (forge==null && !noForge)
|
||||
|
@ -432,7 +447,7 @@ public class FMLCommonHandler
|
|||
}
|
||||
return forge;
|
||||
}
|
||||
|
||||
|
||||
private Object callForgeMethod(String method)
|
||||
{
|
||||
if (noForge)
|
||||
|
@ -551,12 +566,12 @@ public class FMLCommonHandler
|
|||
generator.generate(fmlRandom, chunkX, chunkZ, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerTickHandler(ITickHandler handler)
|
||||
{
|
||||
tickHandlers.add(handler);
|
||||
}
|
||||
|
||||
|
||||
public void registerWorldGenerator(IWorldGenerator generator)
|
||||
{
|
||||
worldGenerators.add(generator);
|
||||
|
|
|
@ -40,10 +40,10 @@ import cpw.mods.fml.common.toposort.TopologicalSort;
|
|||
|
||||
/**
|
||||
* The loader class performs the actual loading of the mod code from disk.
|
||||
*
|
||||
*
|
||||
* <p>There are several {@link State}s to mod loading, triggered in two different stages from the FML handler code's hooks into the
|
||||
* minecraft code.</p>
|
||||
*
|
||||
*
|
||||
* <ol>
|
||||
* <li>LOADING. Scanning the filesystem for mod containers to load (zips, jars, directories), adding them to the {@link #modClassLoader}
|
||||
* Scanning, the loaded containers for mod classes to load and registering them appropriately.</li>
|
||||
|
@ -54,11 +54,11 @@ import cpw.mods.fml.common.toposort.TopologicalSort;
|
|||
* <li>ERRORED. The loader encountered an error during the LOADING phase and dropped to this state instead. It will not complete
|
||||
* loading from this state, but it attempts to continue loading before abandoning and giving a fatal error.</li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* Phase 1 code triggers the LOADING and PREINIT states. Phase 2 code triggers the INIT and POSTINIT states.
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Loader
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ public class Loader
|
|||
private File canonicalMinecraftDir;
|
||||
private Exception capturedError;
|
||||
|
||||
|
||||
|
||||
public static Loader instance()
|
||||
{
|
||||
if (instance == null)
|
||||
|
@ -141,7 +141,7 @@ public class Loader
|
|||
Loader.log.setUseParentHandlers(false);
|
||||
Loader.log.addHandler(ch);
|
||||
ch.setFormatter(formatter);
|
||||
|
||||
|
||||
}
|
||||
Loader.log.setLevel(Level.ALL);
|
||||
try
|
||||
|
@ -163,11 +163,11 @@ public class Loader
|
|||
if (stream != null) {
|
||||
try {
|
||||
properties.load(stream);
|
||||
major = properties.getProperty("fmlbuild.major.number");
|
||||
minor = properties.getProperty("fmlbuild.minor.number");
|
||||
rev = properties.getProperty("fmlbuild.revision.number");
|
||||
build = properties.getProperty("fmlbuild.build.number");
|
||||
mcversion = properties.getProperty("fmlbuild.mcversion");
|
||||
major = properties.getProperty("fmlbuild.major.number","none");
|
||||
minor = properties.getProperty("fmlbuild.minor.number","none");
|
||||
rev = properties.getProperty("fmlbuild.revision.number","none");
|
||||
build = properties.getProperty("fmlbuild.build.number","none");
|
||||
mcversion = properties.getProperty("fmlbuild.mcversion","none");
|
||||
} catch (IOException ex) {
|
||||
Loader.log.log(Level.SEVERE,"Could not get FML version information - corrupted installation detected!", ex);
|
||||
throw new LoaderException(ex);
|
||||
|
@ -238,12 +238,12 @@ public class Loader
|
|||
mod.nextState();
|
||||
}
|
||||
// Link up mod metadatas
|
||||
|
||||
|
||||
for (ModContainer mod : mods) {
|
||||
if (mod.getMetadata()!=null) {
|
||||
mod.getMetadata().associate(namedMods);
|
||||
}
|
||||
|
||||
|
||||
FMLCommonHandler.instance().injectSidedProxyDelegate(mod);
|
||||
}
|
||||
log.fine("Mod pre-initialization complete");
|
||||
|
@ -287,18 +287,18 @@ public class Loader
|
|||
|
||||
/**
|
||||
* The primary loading code
|
||||
*
|
||||
* This is visited during first initialization by Minecraft to scan and load the mods
|
||||
*
|
||||
* This is visited during first initialization by Minecraft to scan and load the mods
|
||||
* from all sources
|
||||
* 1. The minecraft jar itself (for loading of in jar mods- I would like to remove this if possible but forge depends on it at present)
|
||||
* 2. The mods directory with expanded subdirs, searching for mods named mod_*.class
|
||||
* 3. The mods directory for zip and jar files, searching for mod classes named mod_*.class again
|
||||
*
|
||||
*
|
||||
* The found resources are first loaded into the {@link #modClassLoader} (always) then scanned for class resources matching the specification above.
|
||||
*
|
||||
*
|
||||
* If they provide the {@link Mod} annotation, they will be loaded as "FML mods", which currently is effectively a NO-OP.
|
||||
* If they are determined to be {@link BaseMod} subclasses they are loaded as such.
|
||||
*
|
||||
*
|
||||
* Finally, if they are successfully loaded as classes, they are then added to the available mod list.
|
||||
*/
|
||||
private void load()
|
||||
|
@ -387,7 +387,7 @@ public class Loader
|
|||
}
|
||||
}
|
||||
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
|
||||
|
@ -545,9 +545,10 @@ public class Loader
|
|||
extendClassLoader(modFile);
|
||||
boolean foundAModClass = false;
|
||||
|
||||
ZipFile jar = null;
|
||||
try
|
||||
{
|
||||
ZipFile jar = new ZipFile(modFile);
|
||||
jar = new ZipFile(modFile);
|
||||
|
||||
for (ZipEntry ze : Collections.list(jar.entries()))
|
||||
{
|
||||
|
@ -571,6 +572,19 @@ public class Loader
|
|||
state = State.ERRORED;
|
||||
capturedError = e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jar.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundAModClass;
|
||||
}
|
||||
|
@ -612,7 +626,7 @@ public class Loader
|
|||
|
||||
/**
|
||||
* Query if we know of a mod named modname
|
||||
*
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
|
@ -628,7 +642,7 @@ public class Loader
|
|||
{
|
||||
return canonicalConfigDir;
|
||||
}
|
||||
|
||||
|
||||
public String getCrashInformation()
|
||||
{
|
||||
StringBuffer ret = new StringBuffer();
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ModLoaderHelper
|
|||
} else {
|
||||
ticks.remove(TickType.RENDER);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get game ticks
|
||||
// If we're enabled but we want clock ticks, or we're server side we get game ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.GAME);
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ public class ModLoaderHelper
|
|||
} else {
|
||||
ticks.remove(TickType.GUI);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get world ticks
|
||||
// If we're enabled but we want clock ticks, or we're server side we get world ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.WORLDGUI);
|
||||
} else {
|
||||
|
@ -72,7 +72,7 @@ public class ModLoaderHelper
|
|||
*/
|
||||
private static ModLoaderModContainer findOrBuildModContainer(BaseMod mod)
|
||||
{
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) FMLCommonHandler.instance().findContainerFor(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=notModCallbacks.get(mod);
|
||||
if (mlmc==null) {
|
||||
|
@ -82,7 +82,7 @@ public class ModLoaderHelper
|
|||
}
|
||||
return mlmc;
|
||||
}
|
||||
|
||||
|
||||
public static ModLoaderModContainer registerRenderHelper(BaseMod mod) {
|
||||
ModLoaderModContainer mlmc=findOrBuildModContainer(mod);
|
||||
return mlmc;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
private ModMetadata metadata;
|
||||
private ProxyInjector sidedProxy;
|
||||
private BaseModTicker tickHandler;
|
||||
|
||||
|
||||
public ModLoaderModContainer(Class <? extends BaseMod > modClazz, File modSource)
|
||||
{
|
||||
this.modClazz = modClazz;
|
||||
|
@ -83,7 +83,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
this.mod=instance;
|
||||
this.tickHandler = new BaseModTicker(instance);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean wantsPreInit()
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
|
||||
boolean existingConfigFound = false;
|
||||
boolean mlPropFound = false;
|
||||
|
||||
|
||||
if (modConfig.exists())
|
||||
{
|
||||
try
|
||||
|
@ -241,7 +241,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
Loader.log.fine(String.format("No MLProp configuration for %s found or required. No file written", modConfigName));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!mlPropFound && existingConfigFound)
|
||||
{
|
||||
File mlPropBackup = new File(modConfig.getParent(),modConfig.getName()+".bak");
|
||||
|
@ -255,7 +255,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
{
|
||||
Loader.log.fine(String.format("Unused MLProp configuration file for %s renamed UNSUCCESSFULLY to %s", modConfigName, mlPropBackup.getName()));
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
|
@ -363,17 +363,10 @@ public class ModLoaderModContainer implements ModContainer
|
|||
return mod != null ? mod.getName() : modClazz.getSimpleName();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ModContainer findContainerFor(BaseMod mod)
|
||||
{
|
||||
for (ModContainer mc : Loader.getModList())
|
||||
{
|
||||
if (mc.matches(mod))
|
||||
{
|
||||
return mc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return FMLCommonHandler.instance().findContainerFor(mod);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -392,7 +385,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* Find all the BaseMods in the system
|
||||
* Find all the BaseMods in the system
|
||||
* @param <A>
|
||||
* @return
|
||||
*/
|
||||
|
@ -498,7 +491,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ("required-before".equals(depparts[0]) || "before".equals(depparts[0]))
|
||||
{
|
||||
postDependencies.add(depparts[1]);
|
||||
|
@ -509,7 +502,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
parseFailure=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parseFailure) {
|
||||
FMLCommonHandler.instance().getFMLLogger().warning(String.format("The mod %s has an incorrect dependency string {%s}", mod.getName(), mod.getPriorities()));
|
||||
}
|
||||
|
@ -604,7 +597,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
if (keyHandlers==null) {
|
||||
keyHandlers=new ArrayList<IKeyHandler>();
|
||||
}
|
||||
|
||||
|
||||
Iterator<IKeyHandler> itr = keyHandlers.iterator();
|
||||
while(itr.hasNext())
|
||||
{
|
||||
|
@ -614,7 +607,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
keyHandlers.add(handler);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
*
|
||||
*
|
||||
* {@link FMLCommonHandler#fuelLookup(int, int)}
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
|
@ -134,7 +134,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
*
|
||||
* @param fileToOverride
|
||||
* @param fileToAdd
|
||||
* @return
|
||||
|
@ -146,7 +146,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* @param overlayPath
|
||||
* @param index
|
||||
|
@ -248,7 +248,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
|
@ -374,7 +374,7 @@ public class ModLoader
|
|||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
|
@ -387,7 +387,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Stubbed method on the server to return a unique model id
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
|
@ -409,11 +409,11 @@ public class ModLoader
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your
|
||||
* channel is active prior to sending the packet
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param channel
|
||||
* @return
|
||||
|
@ -431,7 +431,7 @@ public class ModLoader
|
|||
/**
|
||||
* Is the named mod loaded?
|
||||
* {@link Loader#isModLoaded(String)}
|
||||
*
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
|
@ -483,7 +483,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
|
||||
*
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -504,7 +504,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
public static void registerBlock(Block block)
|
||||
|
@ -514,7 +514,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
*
|
||||
* @param block
|
||||
* @param itemclass
|
||||
*/
|
||||
|
@ -525,7 +525,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
|
@ -537,7 +537,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
|
@ -559,18 +559,18 @@ public class ModLoader
|
|||
* channel with Forge Mod Loader, not with clients connecting- use
|
||||
* BaseMod.onClientLogin to tell them about your custom channel
|
||||
* {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)}
|
||||
*
|
||||
*
|
||||
* @param mod
|
||||
* @param channel
|
||||
*/
|
||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||
{
|
||||
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel);
|
||||
FMLCommonHandler.instance().registerChannel(FMLCommonHandler.instance().findContainerFor(mod), channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new tile entity class
|
||||
*
|
||||
*
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
*/
|
||||
|
@ -586,7 +586,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a biome from the list of generated biomes
|
||||
*
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void removeBiome(BiomeGenBase biome)
|
||||
|
@ -596,7 +596,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
*/
|
||||
|
@ -607,7 +607,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
|
@ -619,7 +619,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
*/
|
||||
|
@ -630,7 +630,7 @@ public class ModLoader
|
|||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
|
@ -670,7 +670,7 @@ public class ModLoader
|
|||
/**
|
||||
* Send a chat message to the server
|
||||
* {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -697,7 +697,7 @@ public class ModLoader
|
|||
ModLoaderHelper.updateStandardTicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateGUITicks(mod, enable, useClock);
|
||||
|
@ -706,7 +706,7 @@ public class ModLoader
|
|||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
|
@ -720,7 +720,7 @@ public class ModLoader
|
|||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
|
||||
*
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
|
@ -734,7 +734,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
|
@ -747,7 +747,7 @@ public class ModLoader
|
|||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#onItemSmelted(EntityPlayer, ItemStack)}
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
|
@ -766,7 +766,7 @@ public class ModLoader
|
|||
{
|
||||
FMLCommonHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
|
||||
public static void throwException(Throwable e)
|
||||
{
|
||||
throwException("Exception in ModLoader", e);
|
||||
|
|
Loading…
Reference in a new issue