Hello to all the Mod Creators out there, Does not include you leechers Cheers :P.
I Just wanted to share some more info on Modloader, specifically Method references!
ModLoader Methods:
AddName
Code:
ModLoader.AddName(Object o, String name);
Returns: void
Info: This is a very useful method that allows you to set the tooltip text of a custom block or item. If you do not set the tooltip text, the item/block will have no name.
Usage:
Code:
public static Block myBlock = new Block(200, 1); //Create a custom block
ModLoader.AddName(myBlock, "My Block"); //Set the block's name.
-----------------------------------------------------------------------------------------------------------------------
addOverride
Code:
ModLoader.addOverride(String fileToOverride, String file);
Returns: int
Info: This method is also a very useful one that modders use a lot. What it does is it
override Minecraft's texture indexes and allows you to use your own custom textures for blocks
and items.
Usage:
Code:
public static Block myBlock = new Block(200, 1); //Create a custom block
myBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/blockImage.png"); //Set the block's texture.
Notes: If you are setting a block's texture, you must override "/terrain.png". If
you are setting an item's texture, you must override "/gui/items.png".
-----------------------------------------------------------------------------------------------------------------------
AddSmelting
Code:
ModLoader.AddOverride(int id, ItemStack result);
Returns: void
Info: This method makes it very easy to add your own custom smelting recipes to the game. All you have to do is tell it the original item's ID and the ItemStack result.
Usage:
Code:
public static Block myBlock = new Block(200, 1); //Create a custom block
ModLoader.AddSmelting(myBlock.blockID, new ItemStack(Item.diamond)); //Make it smelt in to a diamond.
-----------------------------------------------------------------------------------------------------------------------
DispenseEntity
Code:
ModLoader.DispenseEntity(World w, double x, double y, double z, int xVel, int yVel, ItemStack item);
Returns: boolean
Info: A not very well known method, this allows you to create an item in the world, similar to the way dispensers spit out items or how mobs drop loot. You can set the item's coordinates as well as it's velocity.
Usage:
Code:
World world = ModLoader.getMinecraftInstance().theWorld; //get the current world.
ModLoader.DispenseEntity(world, 0, 64, 0, 0, 0, new ItemStack(Item.diamond));
//Create a diamond at 0, 64, 0 with 0 velocity.
Notes: Returns true if item was handled, false if it failed to create the item.
-----------------------------------------------------------------------------------------------------------------------
getMinecraftInstance
Code:
ModLoader.getMinecraftInstance();
Returns: net.minecraft.client.Minecraft
Info: This method is a little "hack" that returns the current instance of the Minecraft class. This is useful if you want to access the current world or the player.
Usage:
Minecraft mc = ModLoader.getMinecraftInstance();
World world = mc.theWorld; //get the current world.
EntityPlayer player = mc.thePlayer; //get the player entity.
-----------------------------------------------------------------------------------------------------------------------
isGUIOpen
Code:
ModLoader.isGUIOpen(Gui gui);
Returns: boolean
Info: A neat little method that allows you to check if the specified Gui is currently open.
Usage:
Code:
boolean isFurnaceOpen = ModLoader.isGUIOpen(new GuiFurnace()); //check a furnace gui is open
Notes: If you set the parameter to null, it will check is any gui is opened.
-----------------------------------------------------------------------------------------------------------------------
isModLoaded
Code:
ModLoader.isModLoaded(String name);
Returns: boolean
Info: A simple little method that checks if the mod with the specified name has been loaded.
Usage:
Code:
boolean isAetherLoaded = ModLoader.isModLoaded("mod_Aether"); //check if the Aether mod is loaded
-----------------------------------------------------------------------------------------------------------------------
OpenGUI
Code:
ModLoader.OpenGUI(EntityPlayer player, Gui gui);
Returns: void
Info: This method allows you to display a gui on the screen. Not too much to say about it.
Usage:
Code:
GuiContainerCreative gui = new GuiContainerCreative(new ConatinerCreative()); create a creative gui
EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer; //get the player
ModLoader.OpenGUI(player, gui); //display the gui on the screen
-----------------------------------------------------------------------------------------------------------------------
RegisterBlock
Code:
ModLoader.RegisterBlock(Block block);
Returns: void
Info: An essential method for mods that add new blocks. You must register the block for it to show up in the game. I recommend that you register the block before doing anything else with it.
Usage:
Code:
public static Block myBlock = new Block(200, 1); //create the block.
ModLoader.RegisterBlock(myBlock); //register the block.
And there's alot more!!
I Posted an attachment which contains all of the information you need on modloader and modloader references
Virus Scan:
VirusTotal
Virus Chief
Credits:
InCapacitated - For Posting and Making this thread.
Risugami - For Making Modloader of course.
Please post if there is any problems or misconception with this post.
Glad to Help You!