Class ModLoader

java.lang.Object
  extended by ModLoader

public final class ModLoader
extends java.lang.Object

ModLoader loads classes that inherit from BaseMod and adds them to a list for use.

Version:
Beta 1.2_02

Field Summary
static boolean DEBUG
          Whether debug mode is enabled.
static java.lang.String VERSION
          Current version.
 
Method Summary
static int AddAllFuel(int id)
          Used for adding new sources of fuel to the furnace.
static void AddAllRecipes(fg recipes)
          Used to add recipes from all the mods.
static void AddAllRenderers(java.util.Map<java.lang.Class<? extends nl>,ba> renderers)
          Used to add all mod entity renderers.
static void addAnimation(ah anim)
          Registers one animation instance.
static int AddArmor(java.lang.String armor)
          Use this when you need the player to have new armor skin.
static void AddLocalization(java.lang.String key, java.lang.String value)
          Method for adding raw strings to the translation table.
static void AddName(java.lang.Object instance, java.lang.String name)
          This method will allow adding name to item in inventory.
static int addOverride(java.lang.String fileToOverride, java.lang.String fileToAdd)
          Use this to add custom images for your items and blocks.
static void addOverride(java.lang.String path, java.lang.String overlayPath, int index)
          Deprecated. 
static void AddSmelting(int input, gm output)
          Used to add smelting recipes to the furnace.
static nl DispenseEntity(dn world, double x, double y, double z, float xVel, float zVel, int itemid)
          Dispenses the entity associated with the selected item.
static java.util.List<BaseMod> getLoadedMods()
          Use this method if you need a list of loaded mods.
static java.util.logging.Logger getLogger()
          Use this to get a reference to the logger ModLoader uses.
static net.minecraft.client.Minecraft getMinecraftInstance()
          Use this method to get a reference to Minecraft instance.
static
<T,E> T
getPrivateValue(java.lang.Class<? super E> instanceclass, E instance, int fieldindex)
          Used for getting value of private fields.
static
<T,E> T
getPrivateValue(java.lang.Class<? super E> instanceclass, E instance, java.lang.String field)
          Used for getting value of private fields.
static int getUniqueEntityId()
          Gets next Entity ID to use.
static int getUniqueSpriteIndex(java.lang.String path)
          Deprecated. 
static boolean isGUIOpen(java.lang.Class<? extends by> gui)
          Use this method to check if GUI is opened for the player.
static boolean isModLoaded(java.lang.String modname)
          Checks if a mod is loaded.
static void OpenModGUI(eu player, java.lang.Object instance)
          Opens GUI for use with mods.
static void PopulateChunk(bm generator, int chunkX, int chunkZ, dn world)
          Used for generating new blocks in the world.
static void RegisterAllTextureOverrides(gs texCache)
          Processes all registered texture overrides.
static void RegisterBlock(pj block)
          Adds block to list of blocks the player can use.
static void RegisterBlock(pj block, java.lang.Class<? extends bl> itemclass)
          Adds block to list of blocks the player can use.
static void RegisterEntityID(java.lang.Class<? extends nl> entityClass, java.lang.String entityName, int id)
          Registers an entity ID.
static void RegisterKey(BaseMod mod, lo keyHandler, boolean allowRepeat)
          Use this to add an assignable key to the options menu.
static void RegisterTileEntity(java.lang.Class<? extends kp> tileEntityClass, java.lang.String id)
          Registers a tile entity.
static void RegisterTileEntity(java.lang.Class<? extends kp> tileEntityClass, java.lang.String id, go renderer)
          Registers a tile entity.
static void RunOSDHooks(net.minecraft.client.Minecraft game)
          Runs all registered OSD hooks, run by GUIInGame.
static
<T,E> void
setPrivateValue(java.lang.Class<? super T> instanceclass, T instance, int fieldindex, E value)
          Used for setting value of private fields.
static
<T,E> void
setPrivateValue(java.lang.Class<? super T> instanceclass, T instance, java.lang.String field, E value)
          Used for setting value of private fields.
static void ThrowException(java.lang.String message, java.lang.Throwable e)
          Used for catching an error and generating an error report.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Whether debug mode is enabled. Not for use by others.

See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
Current version.

See Also:
Constant Field Values
Method Detail

getLogger

public static java.util.logging.Logger getLogger()
Use this to get a reference to the logger ModLoader uses.

Returns:
the logger instance.

AddAllFuel

public static int AddAllFuel(int id)
Used for adding new sources of fuel to the furnace.

Parameters:
id - ItemID for the item to use as fuel.
Returns:
Duration of fuel provided.
See Also:
BaseMod.AddFuel(int)

AddAllRecipes

public static void AddAllRecipes(fg recipes)
Used to add recipes from all the mods.

Parameters:
recipes - Recipe instance to add to.
See Also:
BaseMod.AddRecipes(fg)

AddAllRenderers

public static void AddAllRenderers(java.util.Map<java.lang.Class<? extends nl>,ba> renderers)
Used to add all mod entity renderers.

Parameters:
renderers - HashMap of the renderers. key is an entity class, value is the renderer.
See Also:
BaseMod.AddRenderer(java.util.Map, ba>)

AddSmelting

public static void AddSmelting(int input,
                               gm output)
Used to add smelting recipes to the furnace. See dj.class for details.

Parameters:
input - ID of the item, or block, to smelt.
output - the ItemStack created.

addAnimation

public static void addAnimation(ah anim)
Registers one animation instance.

Parameters:
anim - instance of animation handler.

AddLocalization

public static void AddLocalization(java.lang.String key,
                                   java.lang.String value)
Method for adding raw strings to the translation table.

Parameters:
key - tag for string.
value - string to add.

AddName

public static void AddName(java.lang.Object instance,
                           java.lang.String name)
This method will allow adding name to item in inventory. Requires name tag.

Parameters:
instance - A block, item, or item stack reference to name.
name - The name to give.

addOverride

@Deprecated
public static void addOverride(java.lang.String path,
                                          java.lang.String overlayPath,
                                          int index)
Deprecated. 

Registers one texture override to be done.

Parameters:
path - Path to the texture file to modify.
overlayPath - Path to the texture file which is to be overlaid.
index - Sprite index into the texture to be modified.

addOverride

public static int addOverride(java.lang.String fileToOverride,
                              java.lang.String fileToAdd)
Use this to add custom images for your items and blocks. This method should be called where you want to assign the index for the item or block to use.

Parameters:
fileToOverride - "/terrain.png" or "/gui/items.png".
fileToAdd - path to the image you want to add.
Returns:
index assigned to this image.

getLoadedMods

public static java.util.List<BaseMod> getLoadedMods()
Use this method if you need a list of loaded mods.

Returns:
a list of mods.

getMinecraftInstance

public static net.minecraft.client.Minecraft getMinecraftInstance()
Use this method to get a reference to Minecraft instance.

Returns:
Minecraft instance.

getPrivateValue

public static <T,E> T getPrivateValue(java.lang.Class<? super E> instanceclass,
                                      E instance,
                                      int fieldindex)
                         throws java.lang.IllegalArgumentException,
                                java.lang.SecurityException,
                                java.lang.NoSuchFieldException
Used for getting value of private fields.

Type Parameters:
T - Return type.
E - Type of instance.
Parameters:
instanceclass - Class to use with instance.
instance - Object to get private field from.
fieldindex - Name of the field.
Returns:
Value of private field.
Throws:
java.lang.IllegalArgumentException - if instance isn't compatible with instanceclass.
java.lang.SecurityException - if the thread is not allowed to access field.
java.lang.NoSuchFieldException - if field does not exist.

getPrivateValue

public static <T,E> T getPrivateValue(java.lang.Class<? super E> instanceclass,
                                      E instance,
                                      java.lang.String field)
                         throws java.lang.IllegalArgumentException,
                                java.lang.SecurityException,
                                java.lang.NoSuchFieldException
Used for getting value of private fields.

Type Parameters:
T - Return type.
E - Type of instance.
Parameters:
instanceclass - Class to use with instance.
instance - Object to get private field from.
field - Name of the field.
Returns:
Value of private field.
Throws:
java.lang.IllegalArgumentException - if instance isn't compatible with instanceclass.
java.lang.SecurityException - if the thread is not allowed to access field.
java.lang.NoSuchFieldException - if field does not exist.

getUniqueEntityId

public static int getUniqueEntityId()
Gets next Entity ID to use.

Returns:
Assigned ID.

getUniqueSpriteIndex

@Deprecated
public static int getUniqueSpriteIndex(java.lang.String path)
Deprecated. 

Gets next available index for this sprite map.

Parameters:
path - Sprite map to get available index from.
Returns:
Assigned sprite index to use.

isGUIOpen

public static boolean isGUIOpen(java.lang.Class<? extends by> gui)
Use this method to check if GUI is opened for the player.

Parameters:
gui - The type of GUI to check for. If null, will check for any GUI.
Returns:
True if GUI is open.

isModLoaded

public static boolean isModLoaded(java.lang.String modname)
Checks if a mod is loaded.

Parameters:
modname - Name of the mod to check for.
Returns:
Returns true if a mod with supplied name exists in the mod list.

OpenModGUI

public static void OpenModGUI(eu player,
                              java.lang.Object instance)
Opens GUI for use with mods.

Parameters:
player - Player instance to open GUI for.
instance - Used for identifying which mod this call is for. Allows for passing extra data to GUI.
See Also:
BaseMod.OpenModGUI(eu, java.lang.Object)

PopulateChunk

public static void PopulateChunk(bm generator,
                                 int chunkX,
                                 int chunkZ,
                                 dn world)
Used for generating new blocks in the world.

Parameters:
generator - Generator to pair with.
chunkX - X coordinate of chunk.
chunkZ - Z coordinate of chunk.
world - World to generate blocks in.
See Also:
BaseMod.GenerateSurface(dn, java.util.Random, int, int), BaseMod.GenerateNether(dn, java.util.Random, int, int)

RegisterAllTextureOverrides

public static void RegisterAllTextureOverrides(gs texCache)
Processes all registered texture overrides.

Parameters:
texCache - Reference to texture cache.
See Also:
BaseMod.RegisterTextureOverrides()

RegisterBlock

public static void RegisterBlock(pj block)
Adds block to list of blocks the player can use.

Parameters:
block - Block to add.

RegisterBlock

public static void RegisterBlock(pj block,
                                 java.lang.Class<? extends bl> itemclass)
Adds block to list of blocks the player can use. Includes the item to use for block.

Parameters:
block - Block to add.
itemclass - Class to use for block item.

DispenseEntity

public static nl DispenseEntity(dn world,
                                double x,
                                double y,
                                double z,
                                float xVel,
                                float zVel,
                                int itemid)
Dispenses the entity associated with the selected item.

Parameters:
world - reference to the World.
x - X coordinate.
y - Y coordinate.
z - Z coordinate.
xVel - X velocity.
zVel - Z velocity.
itemid - ID of item to chosen to dispense entity.
Returns:
entity to dispense.
See Also:
BaseMod.DispenseEntity(dn, double, double, double, float, float, int)

RegisterEntityID

public static void RegisterEntityID(java.lang.Class<? extends nl> entityClass,
                                    java.lang.String entityName,
                                    int id)
Registers an entity ID.

Parameters:
entityClass - Class of entity to register.
entityName - The given name of entity. Used for saving.
id - Numeric ID of entity.

RegisterKey

public static void RegisterKey(BaseMod mod,
                               lo keyHandler,
                               boolean allowRepeat)
Use this to add an assignable key to the options menu. A max of four should be used at a time.

Parameters:
mod - The mod which will use this. 99% of the time you should pass "this".
keyHandler - reference to the key to register. Define this in your mod file.
allowRepeat - when true the command will repeat. When false, only called once per press.

RegisterTileEntity

public static void RegisterTileEntity(java.lang.Class<? extends kp> tileEntityClass,
                                      java.lang.String id)
Registers a tile entity.

Parameters:
tileEntityClass - Class of tile entity to register.
id - The given name of entity. Used for saving.

RegisterTileEntity

public static void RegisterTileEntity(java.lang.Class<? extends kp> tileEntityClass,
                                      java.lang.String id,
                                      go renderer)
Registers a tile entity.

Parameters:
tileEntityClass - Class of tile entity to register.
id - The given name of entity. Used for saving.
renderer - Tile entity renderer to assign this tile entity.

RunOSDHooks

public static void RunOSDHooks(net.minecraft.client.Minecraft game)
Runs all registered OSD hooks, run by GUIInGame.

Parameters:
game - instance of the game class.
See Also:
BaseMod.OSDHook(net.minecraft.client.Minecraft, boolean)

setPrivateValue

public static <T,E> void setPrivateValue(java.lang.Class<? super T> instanceclass,
                                         T instance,
                                         int fieldindex,
                                         E value)
                            throws java.lang.IllegalArgumentException,
                                   java.lang.SecurityException,
                                   java.lang.NoSuchFieldException
Used for setting value of private fields.

Type Parameters:
T - Type of instance.
E - Type of value.
Parameters:
instanceclass - Class to use with instance.
instance - Object to get private field from.
fieldindex - Offset of field in class.
value - Value to set.
Throws:
java.lang.IllegalArgumentException - if instance isn't compatible with instanceclass.
java.lang.SecurityException - if the thread is not allowed to access field.
java.lang.NoSuchFieldException - if field does not exist.

setPrivateValue

public static <T,E> void setPrivateValue(java.lang.Class<? super T> instanceclass,
                                         T instance,
                                         java.lang.String field,
                                         E value)
                            throws java.lang.IllegalArgumentException,
                                   java.lang.SecurityException,
                                   java.lang.NoSuchFieldException
Used for setting value of private fields.

Type Parameters:
T - Type of instance.
E - Type of value.
Parameters:
instanceclass - Class to use with instance.
instance - Object to get private field from.
field - Name of the field.
value - Value to set.
Throws:
java.lang.IllegalArgumentException - if instance isn't compatible with instanceclass.
java.lang.SecurityException - if the thread is not allowed to access field.
java.lang.NoSuchFieldException - if field does not exist.

ThrowException

public static void ThrowException(java.lang.String message,
                                  java.lang.Throwable e)
Used for catching an error and generating an error report.

Parameters:
message - Title of error report.
e - Exception to report.

AddArmor

public static int AddArmor(java.lang.String armor)
Use this when you need the player to have new armor skin. This method will return the index of the skin. This will be located at "/armor/ARMORNAMEHERE_1.png" or "/armor/ARMORNAMEHERE_2.png", depending on armor type.

Parameters:
armor - Name of the armor skin.
Returns:
index assign for the armor skin.