NOTE TO ALL BROWSERS: I've created a forum especially for modding tutorials at http://zidmc.info
Please direct all questions to there as I did it easier to answer on our own website rather than one post.
I will migrate all current tutorials to there and I recommend that you go there as you will get the best help there.
THREAD ANNOUNCEMENTS: MCP is not updated for 1.5 yet! Be patient!
I am recruiting help for answering all the questions I get- I am now getting about 1-3 pages a day, and I have school and sleep to think about, so if you want to be an official assistant to me in answering posts, PM me with the following:
1.Forum name
2.Level of Java(It's your choice, but be truthful)
3.How long you have studied Java
4.How long you have ModLoader modded for
5.Links to any of your mods
Thanks!
In this topic, I will show you how to create mods using modloader. Do NOT ask for help concerning general modding; this thread is ModLoader modding only. I will cover topics such as adding blocks, adding items, custom world generation, adding tools, and adding armor. This is by no means the only tutorials I will have; these are just the basics.
I reccomend you follow these tutorials in the order above. Setting up ModLoader
First, download the latest version of MCP for your version of minecraft. For 1.4_01 (The current version), it is MCP 2.11. You can find MCP here: http://mcp.ocean-labs.de/index.php/MCP_Releases
Next, copy your /bin/ and /resources/ folders from .minecraft to /jars/ in mcp211. Install ModLoader in the minecraft.jar when it is inside the /jars/ folder. This will stop your usable minecraft.jar in /.minecraft/ from becoming modified. Remember to delete META-INF.
Run decompile.bat. It will bring up a command window that will begin the decompiling process. If it says something about your Java PATH, do the following:
<Placeholder for PATH Tutorial>
It should say before completion something about "Hunks FAILED". This is PERFECTLY FINE. DO NOT WORRY. Check your /sources/ folder and make sure the sources are in there. You can now move on to the actual tutorials!
This tutorial will teach you how to create a new ore, emerald, and add it to the game. This tutorial holds true with adding new blocks as well. First off, create a new file called mod_Emeralds.java and start it off with the standard
package net.minecraft.src;
public class mod_Emeralds extends BaseMod {
Now, for a ModLoader mod, it is essential that your mod extends BaseMod (or, for any basic ModLoader mod anyway). It is also incredibly important that you add the mod_ prefix to your class. As a note, you will notcie that it is not mod_EmeraldOre, but mod_Emeralds. This is because you can add emerald items, emerald ore, emerald block, emerald tools, emerald armor, emerald recipes, and everything to do with emeralds in this one class.
Next you want to add this bit:
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
All this does is set the name your classes will use (not the in game name so dont worry!), sets its TNT resistance, sets its hardness (difficulty to break), and its ID. That's all we need for this, heres what our code looks like now:
package net.minecraft.src;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
So now, we need to add it into the game. The game doesn't yet register it! You register all your ModLoader functions under this heading:
public mod_Emeralds()
{
Or whatever your mod's class is. Now, what you still need to do is:
Register the block;
Create on Override for textures (if you wish);
and Add an InGameName for your ore.
All this does is make the game recognize the emeraldOre, overrides the /terrain.png directory for it's sprite, and replaces it with the emeraldore.png file in the tutorials folder, and adds its ingame name as Emerald Ore. So, after this, our class looks like this:
package net.minecraft.src;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public mod_Emeralds()
{
ModLoader.RegisterBlock(emeraldOre);
emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorials/emeraldore.png");
ModLoader.AddName(emeraldOre, "Emerald Ore");
Now, to finish it off, we add:
public String Version()
{
return "1.4_01";
}
}
To the end, to show what version of MC it is for. Our code now looks like this:
package net.minecraft.src;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public mod_Emeralds()
{
ModLoader.RegisterBlock(emeraldOre);
emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorials/emeraldore.png");
ModLoader.AddName(emeraldOre, "Emerald Ore");
public String Version()
{
return "1.4_01";
}
}
Now, save your mod_Emeralds.java file and create a new file called BlockEmeraldOre.java. Open BlockEmeraldOre for editing. This is what you want in BlockEmeraldOre:
package net.minecraft.src;
public class BlockEmeraldOre extends Block
{
protected BlockEmeraldOre(int i, int j)
{
super(i, j, Material.iron);
}
}
mod_Emeralds calls on this once, so it is a necessary file. All this tells us is the material it is made of. If you save this and recompile, you should get no errors at all, except maybe java syntax errors. To obfuscate the code and make it into class files, go into /conf/ and add the lines mod_Emeralds and BlockEmeraldOre to client_obsfucation. Have fun with your new block!
Note: If you want it to return your emerald item, like an ore would, just change your BlockEmeraldOre.java to read like this:
package net.minecraft.src;
import java.util.Random;
public class BlockEmeraldOre extends Block
{
protected BlockEmeraldOre(int i, int j)
{
super(i, j, Material.iron);
}
public int idDropped(int i, Random random)
{
return mod_Emeralds.emeraldItem.shiftedIndex;
}
}
This will fail because you have no emeraldItem - read on to learn how to make an item.
Creating a new item with ModLoader is very simple. For this tutorial, I will assume that you have completed the "Creating a new Block" tutorial, and that you still have the two java files you created. First of all, open your mod_Emeralds.java file. It should read like this:
package net.minecraft.src;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public mod_Emeralds()
{
ModLoader.RegisterBlock(emeraldOre);
emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorials/emeraldore.png");
ModLoader.AddName(emeraldOre, "Emerald Ore");
public String Version()
{
return "1.4_01";
}
}
If it doesn't have this general look, go back and do the Creating a Block tutorial again. If your mod_Emeralds is good, then continue on.
Take a look at this code snippet:
public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
This tells us that there is a new Item called emeraldItem with an ID of 2000. This code is needed to show the game that the emeraldItem exists. This piece of code should fit in right below the block declerations, like so:
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public static final Block emeraldBlock = new BlockEmerald(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
Next, you need to create an Override (if you wish) to create your own picture for it. So, to that end, we create the following:
Note that it says iconIndex instead of blockIndexInTexture. This should be obvious, because obviously emeraldItem is not a block. Also note that it overrides /gui/items.png, instead of /terrain.png. This should go below the other overrides but above the AddNames.
Next, you want to add a name for your emeralds. There is no change from the way we add names for blocks - just put this code below the other AddNames:
ModLoader.AddName(emeraldItem, "Emerald");
After all of that, this is what our code should look like:
package net.minecraft.src;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public static final Block emeraldBlock = new BlockEmerald(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
public mod_Emeralds()
{
ModLoader.RegisterBlock(emeraldOre);
ModLoader.RegisterBlock(emeraldBlock);
emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/moreores/emeraldore.png");
emeraldBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/moreores/emeraldblock.png");
emeraldItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeralditem.png");
ModLoader.AddName(emeraldOre, "Emerald Ore");
ModLoader.AddName(emeraldBlock, "Emerald Block");
ModLoader.AddName(emeraldItem, "Emerald");
public String Version()
{
return "1.4_01";
}
}
Save your mod_Emeralds.java file and create a new file called ItemEmerald.java. In this file, we will create a maximum stack size for the emerald item. It's very basic, it looks like this:
package net.minecraft.src;
public class ItemEmerald extends Item {
public ItemEmerald (int i)
{
super(i);
maxStackSize = (your number here);
}
}
All you would need to change for that would be the maxStackSize = (your number here);
Remember to remove the brackets and make sure not to make it more than 64, or else it won't work. Save this file, add ItemEmerald to your client_obfuscation file, and recompile. There should be no errors except maybe Java syntax errors. Congrats on making your first item!
*** Minecraft Coder Pack Version 2.11 ***
MCP 2.11 running in C:\Users\DAM\Desktop\eclipse\MCP
Compiling Minecraft
sources\minecraft\net\minecraft\src\BlockoreFireDiamond.java:9: cannot find symb
ol
symbol : class Random
location: class net.minecraft.src.BlockoreFireDiamond
public int idDropped(int i, Random random)
^
1 error
*** minecraft_server.jar was not found, skipping
=== MCP 2.11 recompile script finished ===
Press any key to continue . . .
package net.minecraft.src;
public class BlockoreFireDiamond extends Block
{
public BlockoreFireDiamond(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_oreFireDiamond.firediamond.shiftedIndex;
}
}
*** Minecraft Coder Pack Version 2.11 ***
MCP 2.11 running in C:\Users\DAM\Desktop\eclipse\MCP
Compiling Minecraft
sources\minecraft\net\minecraft\src\BlockoreFireDiamond.java:9: cannot find symb
ol
symbol : class Random
location: class net.minecraft.src.BlockoreFireDiamond
public int idDropped(int i, Random random)
^
1 error
*** minecraft_server.jar was not found, skipping
=== MCP 2.11 recompile script finished ===
Press any key to continue . . .
package net.minecraft.src;
public class BlockoreFireDiamond extends Block
{
public BlockoreFireDiamond(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_oreFireDiamond.firediamond.shiftedIndex;
}
}
To create a new tool set takes a small amount of time. First of all, open up mod_Emeralds.java and take a look. Can you guess what we have to do? That's right, we need to register some more stuff. Find this line:
public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
And put this right under it:
public static final Item emeraldPick = new ItemPickaxe(2001, EnumToolMaterial.2EMERALD).setItemName("emeraldPick");
public static final Item emeraldShovel = new ItemSpade(2002, EnumToolMaterial.2EMERALD).setItemName("emeraldShovel");
public static final Item emeraldAxe = new ItemAxe(2003, EnumToolMaterial.2EMERALD).setItemName("emeraldAxe");
public static final Item emeraldHoe = new ItemHoe(2004, EnumToolMaterial.2EMERALD).setItemName("emeraldHoe");
public static final Item emeraldSword = new ItemSword(2005, EnumToolMaterial.2EMERALD).setItemName("emeraldSword");
This should be mostly obvious - it creates a bunch of new items which have IDs ranging from 2001-2005, called things like emeraldPick and emeraldHoe. But wait- what's this "EnumToolMaterial" thingy, you might ask? well, open up EnumToolMaterial and we'll find out!
In EnumToolMaterial, there are only 2 things we need to worry about. The first is this bit:
This is right at the top of the file. Each of the numbers means a different thing- I'll edit this to include them when I remember the rest. In WOOD, the 59 is the number of uses, the second 0 is its strength, the 2.0F determines what it can break.
The other part we have to worry about is here:
public static final EnumToolMaterial WOOD;
public static final EnumToolMaterial STONE;
public static final EnumToolMaterial IRON;
public static final EnumToolMaterial EMERALD;
public static final EnumToolMaterial GOLD;
All this does is declare each of the things described above. So now, we have to edit it to add in our own item's tool materials! But wait, you say! There's already an EMERALD decsribed! Well, that's why I called the one in mod_Emeralds.java 2EMERALD! So, to make 2EMERALD, we have to edit those two code lines to this:
This makes the 2EMERALD have 800 uses, and have 7F strength (among other things).
This is the second part you need to add:
public static final EnumToolMaterial WOOD;
public static final EnumToolMaterial STONE;
public static final EnumToolMaterial IRON;
public static final EnumToolMaterial EMERALD;
public static final EnumToolMaterial GOLD;
public static final EnumToolMaterial 2EMERALD;
Now, save EnumToolMaterial and open up mod_Emeralds again. By now, you should know how to add texture overrides, but here's a basic one just in case:
Now, this will compile and obfuscate, but you'll notice there are no recipes yet. This is why we need to move on to the next tutorial - Adding a Recipe!
You have to import java.util.Random in your BlockoreFireDiamond class - if you don't know what this means, put the line:
import java.util.Random;
One line below your package decleration, and one line above your class line.
If you get any more errors tell me.
wow i feel so stupid, sorry bout that i just re did my mod today during class and i did it so fast i knew i would miss something, i was trying to explain to my friend what each of the sections in the mod_ class do. (he and i will eventually make a decent collab mod together, even though i am the only one with knowledge of java lol)
thanks for correcting my stupidity... here for you
You have to import java.util.Random in your BlockoreFireDiamond class - if you don't know what this means, put the line:
import java.util.Random;
One line below your package decleration, and one line above your class line.
If you get any more errors tell me.
wow i feel so stupid, sorry bout that i just re did my mod today during class and i did it so fast i knew i would miss something, i was trying to explain to my friend what each of the sections in the mod_ class do. (he and i will eventually make a decent collab mod together, even though i am the only one with knowledge of java lol)
thanks for correcting my stupidity... here for you
For this tutorial, I will assume you have completed:
[*:y0diubmk]Creating a new Block
[*:y0diubmk]Creating a new Item
[*:y0diubmk]Creating a new Tool Set
[*:y0diubmk]Converted your EmeraldOre to an actual ore which drops the emerald item
Now, here goes the tutorial!
Adding a new recipe is the easiest function I know of in ModLoader- and the easiest to get an error over. Here's the base of the function:
ModLoader.AddRecipe(new ItemStack(ItemYouWantToProduce, ItemAmountForProducing), new Object[] {
"XXX", "XXX", "XXX" Character.valueOf('X'), The block/Item you want X to be
});
You can just use that as a base for all your recipes, it goes directly under AddNames. Just in case you don't understand, here's a basic recipe:
Note how it only says emeraldItem but says Item.stick? That's because the stick item is created within the Item.java file. So, you may need to use Block.anyblock or Item.anyitem in your recipes.
Heres all the recipes I made for my class (including the block which you make from emeralds which you won't have made in these tutorials):
Okay, so, theoretically, you've made this incredible new ore that makes you fly and heals you and makes you a god and extends the yaxis to 100000000 and does a bunch of other cool stuff(not really, I'm pretty sure one ore can't do all that :/). But anyway, you've made a cool emerald ore and you want it to generate in the ground. This will teach you how to do that. Here's the code for creating custom world generation:
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < (RARITY); i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(DEPTH);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_Emeralds.emeraldOre.blockID, 5)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
The only things you would need to edit in this are RARITY, DEPTH, the digit 5 and (if you are not doing emerald ore) the mod_Emeralds.emeraldOre bit. It should be pretty obvious, but, I'll explain. Rarity is how often it appears per chunk(coal is 20 i think, diamond is somewhere between 7 and 10), Depth is how high above bedrock (NOT HOW FAR BELOW SEA) that it will generate - so if it was 30, it'd be from bedrock to layer 30. The mod_Emeralds.emeraldOre defines the ore it's generating, and the digit 5 shows how big a vein is. This should be placed in just before the version bit - so, my mod_Emeralds class for my more ores mod (see my mod to learn more about more ores) would look like this:
package net.minecraft.src;
import java.util.Random;
public class mod_Emeralds extends BaseMod
{
public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
public static final Block emeraldBlock = new BlockEmerald(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
public static final Item emeraldPick = new ItemPickaxe(2001, EnumToolMaterial.EMERALD).setItemName("emeraldPick");
public static final Item emeraldShovel = new ItemSpade(2002, EnumToolMaterial.EMERALD).setItemName("emeraldShovel");
public static final Item emeraldAxe = new ItemAxe(2003, EnumToolMaterial.EMERALD).setItemName("emeraldAxe");
public static final Item emeraldHoe = new ItemHoe(2004, EnumToolMaterial.EMERALD).setItemName("emeraldHoe");
public static final Item emeraldSword = new ItemSword(2005, EnumToolMaterial.EMERALD).setItemName("emeraldSword");
public mod_Emeralds()
{
ModLoader.RegisterBlock(emeraldOre);
ModLoader.RegisterBlock(emeraldBlock);
emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/moreores/emeraldore.png");
emeraldBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/moreores/emeraldblock.png");
emeraldItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeralditem.png");
emeraldPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeraldpick.png");
emeraldShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeraldshovel.png");
emeraldAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeraldaxe.png");
emeraldHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeraldhoe.png");
emeraldSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/moreores/emeraldsword.png");
ModLoader.AddName(emeraldOre, "Emerald Ore");
ModLoader.AddName(emeraldBlock, "Emerald Block");
ModLoader.AddName(emeraldItem, "Emerald");
ModLoader.AddName(emeraldPick, "Emerald Pickaxe");
ModLoader.AddName(emeraldShovel, "Emerald Shovel");
ModLoader.AddName(emeraldAxe, "Emerald Axe");
ModLoader.AddName(emeraldHoe, "Emerald Hoe");
ModLoader.AddName(emeraldSword, "Emerald Sword");
ModLoader.AddRecipe(new ItemStack(emeraldItem, 9), new Object[] {
"X", Character.valueOf('X'), emeraldBlock
});
ModLoader.AddRecipe(new ItemStack(emeraldBlock, 1), new Object[] {
"XXX", "XXX", "XXX", Character.valueOf('X'), emeraldItem
});
ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
"XXX", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
});
ModLoader.AddRecipe(new ItemStack(emeraldShovel, 1), new Object[] {
" X ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
});
ModLoader.AddRecipe(new ItemStack(emeraldAxe, 1), new Object[] {
"XX ", "X| ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
});
ModLoader.AddRecipe(new ItemStack(emeraldHoe, 1), new Object[] {
"XX ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
});
ModLoader.AddRecipe(new ItemStack(emeraldSword, 1), new Object[] {
" X ", " X ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
});
}
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < 6; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(30);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_Emeralds.emeraldOre.blockID, 5)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
public String Version()
{
return "1.4_01";
}
}
Note that it is OUTSIDE of public mod_Emeralds(), and it is INSIDE the original class decleration instead. Also note that it imported java.util.Random, this is a requirement. Look at the top if you dont know what I mean.
It will only generate in new chunks, so it's best with a new world save.
To create a new smelting recipe, it's a pretty basic function whose basic structure looks like this:
ModLoader.AddSmelting(Block.block you want to be smeltable.blockID, new ItemStack(output, amount);
That's the BASIC function; if I wanted to make emerald ore smelt into emerald gems, for example, I would alter it like this:
ModLoader.AddSmelting(emeraldOre.blockID, new ItemStack(emeraldItem, 1));
That would give me 1 emerald when I smelt an emerald ore. This bit of code has to go after the last AddName but before the first AddRecipe, for neatness sake. Have fun!
Please direct all questions to there as I did it easier to answer on our own website rather than one post.
I will migrate all current tutorials to there and I recommend that you go there as you will get the best help there.
THREAD ANNOUNCEMENTS: MCP is not updated for 1.5 yet! Be patient!
I am recruiting help for answering all the questions I get- I am now getting about 1-3 pages a day, and I have school and sleep to think about, so if you want to be an official assistant to me in answering posts, PM me with the following:
1.Forum name
2.Level of Java(It's your choice, but be truthful)
3.How long you have studied Java
4.How long you have ModLoader modded for
5.Links to any of your mods
Thanks!
In this topic, I will show you how to create mods using modloader. Do NOT ask for help concerning general modding; this thread is ModLoader modding only. I will cover topics such as adding blocks, adding items, custom world generation, adding tools, and adding armor. This is by no means the only tutorials I will have; these are just the basics.
The Tutorials
[*:3qgw7rzq] Setting up ModLoader - Below
[*:3qgw7rzq] Creating a new Block
[*:3qgw7rzq] Creating a new Item
[*:3qgw7rzq] Creating a new Tool Set
[*:3qgw7rzq] Creating a new Recipe
[*:3qgw7rzq] Creating Armor
[*:3qgw7rzq] Making your ore generate
[*:3qgw7rzq] Creating a new Smelting Recipe
[*:3qgw7rzq] Creating a new Bucket
[*:3qgw7rzq] Creating a new Stair
[*:3qgw7rzq] UNTESTED-Creating a new Door
[*:3qgw7rzq] List of ModLoader Functions (External Link by KaeKae)
[*:3qgw7rzq] Creating a new Mob - Coming Soon
I reccomend you follow these tutorials in the order above.
Setting up ModLoader
First, download the latest version of MCP for your version of minecraft. For 1.4_01 (The current version), it is MCP 2.11. You can find MCP here: http://mcp.ocean-labs.de/index.php/MCP_Releases
Next, copy your /bin/ and /resources/ folders from .minecraft to /jars/ in mcp211. Install ModLoader in the minecraft.jar when it is inside the /jars/ folder. This will stop your usable minecraft.jar in /.minecraft/ from becoming modified. Remember to delete META-INF.
Run decompile.bat. It will bring up a command window that will begin the decompiling process. If it says something about your Java PATH, do the following:
<Placeholder for PATH Tutorial>
It should say before completion something about "Hunks FAILED". This is PERFECTLY FINE. DO NOT WORRY. Check your /sources/ folder and make sure the sources are in there. You can now move on to the actual tutorials!
Like my work? Get my banner in that sig!
This tutorial will teach you how to create a new ore, emerald, and add it to the game. This tutorial holds true with adding new blocks as well. First off, create a new file called mod_Emeralds.java and start it off with the standard
Now, for a ModLoader mod, it is essential that your mod extends BaseMod (or, for any basic ModLoader mod anyway). It is also incredibly important that you add the mod_ prefix to your class. As a note, you will notcie that it is not mod_EmeraldOre, but mod_Emeralds. This is because you can add emerald items, emerald ore, emerald block, emerald tools, emerald armor, emerald recipes, and everything to do with emeralds in this one class.
Next you want to add this bit:
All this does is set the name your classes will use (not the in game name so dont worry!), sets its TNT resistance, sets its hardness (difficulty to break), and its ID. That's all we need for this, heres what our code looks like now:
So now, we need to add it into the game. The game doesn't yet register it! You register all your ModLoader functions under this heading:
Or whatever your mod's class is. Now, what you still need to do is:
Register the block;
Create on Override for textures (if you wish);
and Add an InGameName for your ore.
To do this, we do the following:
All this does is make the game recognize the emeraldOre, overrides the /terrain.png directory for it's sprite, and replaces it with the emeraldore.png file in the tutorials folder, and adds its ingame name as Emerald Ore. So, after this, our class looks like this:
Now, to finish it off, we add:
To the end, to show what version of MC it is for. Our code now looks like this:
Now, save your mod_Emeralds.java file and create a new file called BlockEmeraldOre.java. Open BlockEmeraldOre for editing. This is what you want in BlockEmeraldOre:
mod_Emeralds calls on this once, so it is a necessary file. All this tells us is the material it is made of. If you save this and recompile, you should get no errors at all, except maybe java syntax errors. To obfuscate the code and make it into class files, go into /conf/ and add the lines mod_Emeralds and BlockEmeraldOre to client_obsfucation. Have fun with your new block!
Note: If you want it to return your emerald item, like an ore would, just change your BlockEmeraldOre.java to read like this:
This will fail because you have no emeraldItem - read on to learn how to make an item.
Maybe you should add a way to generate them like regular ores such as:
That would be cool!
Creating a new item with ModLoader is very simple. For this tutorial, I will assume that you have completed the "Creating a new Block" tutorial, and that you still have the two java files you created. First of all, open your mod_Emeralds.java file. It should read like this:
If it doesn't have this general look, go back and do the Creating a Block tutorial again. If your mod_Emeralds is good, then continue on.
Take a look at this code snippet:
This tells us that there is a new Item called emeraldItem with an ID of 2000. This code is needed to show the game that the emeraldItem exists. This piece of code should fit in right below the block declerations, like so:
Next, you need to create an Override (if you wish) to create your own picture for it. So, to that end, we create the following:
Note that it says iconIndex instead of blockIndexInTexture. This should be obvious, because obviously emeraldItem is not a block. Also note that it overrides /gui/items.png, instead of /terrain.png. This should go below the other overrides but above the AddNames.
Next, you want to add a name for your emeralds. There is no change from the way we add names for blocks - just put this code below the other AddNames:
After all of that, this is what our code should look like:
Save your mod_Emeralds.java file and create a new file called ItemEmerald.java. In this file, we will create a maximum stack size for the emerald item. It's very basic, it looks like this:
All you would need to change for that would be the maxStackSize = (your number here);
Remember to remove the brackets and make sure not to make it more than 64, or else it won't work. Save this file, add ItemEmerald to your client_obfuscation file, and recompile. There should be no errors except maybe Java syntax errors. Congrats on making your first item!
Previous Next- COMING SOON
I tried it, no recompile errors, but obfuscating absolutely killed me :tongue.gif:
I would love it if you could make me a tutorial, I will link it to the main page
Thankyou very much
Text please.
Show me your mod_oreFireDiamond class please?
One line below your package decleration, and one line above your class line.
If you get any more errors tell me.
To create a new tool set takes a small amount of time. First of all, open up mod_Emeralds.java and take a look. Can you guess what we have to do? That's right, we need to register some more stuff. Find this line:
And put this right under it:
This should be mostly obvious - it creates a bunch of new items which have IDs ranging from 2001-2005, called things like emeraldPick and emeraldHoe. But wait- what's this "EnumToolMaterial" thingy, you might ask? well, open up EnumToolMaterial and we'll find out!
In EnumToolMaterial, there are only 2 things we need to worry about. The first is this bit:
This is right at the top of the file. Each of the numbers means a different thing- I'll edit this to include them when I remember the rest. In WOOD, the 59 is the number of uses, the second 0 is its strength, the 2.0F determines what it can break.
The other part we have to worry about is here:
All this does is declare each of the things described above. So now, we have to edit it to add in our own item's tool materials! But wait, you say! There's already an EMERALD decsribed! Well, that's why I called the one in mod_Emeralds.java 2EMERALD! So, to make 2EMERALD, we have to edit those two code lines to this:
This makes the 2EMERALD have 800 uses, and have 7F strength (among other things).
This is the second part you need to add:
Now, save EnumToolMaterial and open up mod_Emeralds again. By now, you should know how to add texture overrides, but here's a basic one just in case:
Finally, you can add the names:
Now, this will compile and obfuscate, but you'll notice there are no recipes yet. This is why we need to move on to the next tutorial - Adding a Recipe!
wow i feel so stupid, sorry bout that i just re did my mod today during class and i did it so fast i knew i would miss something, i was trying to explain to my friend what each of the sections in the mod_ class do. (he and i will eventually make a decent collab mod together, even though i am the only one with knowledge of java lol)
thanks for correcting my stupidity... here for you
Thankyou very much!
For this tutorial, I will assume you have completed:
[*:y0diubmk]Creating a new Block
[*:y0diubmk]Creating a new Item
[*:y0diubmk]Creating a new Tool Set
[*:y0diubmk]Converted your EmeraldOre to an actual ore which drops the emerald item
Now, here goes the tutorial!
Adding a new recipe is the easiest function I know of in ModLoader- and the easiest to get an error over. Here's the base of the function:
You can just use that as a base for all your recipes, it goes directly under AddNames. Just in case you don't understand, here's a basic recipe:
Note how it only says emeraldItem but says Item.stick? That's because the stick item is created within the Item.java file. So, you may need to use Block.anyblock or Item.anyitem in your recipes.
Heres all the recipes I made for my class (including the block which you make from emeralds which you won't have made in these tutorials):
And here's the entire class(once again, including the block that you probably don't have, emeraldBlock):
Have fun and look out for the next tutorial- Creating an Armor Set (Now Available!)
Okay, so, theoretically, you've made this incredible new ore that makes you fly and heals you and makes you a god and extends the yaxis to 100000000 and does a bunch of other cool stuff(not really, I'm pretty sure one ore can't do all that :/). But anyway, you've made a cool emerald ore and you want it to generate in the ground. This will teach you how to do that. Here's the code for creating custom world generation:
The only things you would need to edit in this are RARITY, DEPTH, the digit 5 and (if you are not doing emerald ore) the mod_Emeralds.emeraldOre bit. It should be pretty obvious, but, I'll explain. Rarity is how often it appears per chunk(coal is 20 i think, diamond is somewhere between 7 and 10), Depth is how high above bedrock (NOT HOW FAR BELOW SEA) that it will generate - so if it was 30, it'd be from bedrock to layer 30. The mod_Emeralds.emeraldOre defines the ore it's generating, and the digit 5 shows how big a vein is. This should be placed in just before the version bit - so, my mod_Emeralds class for my more ores mod (see my mod to learn more about more ores) would look like this:
Note that it is OUTSIDE of public mod_Emeralds(), and it is INSIDE the original class decleration instead. Also note that it imported java.util.Random, this is a requirement. Look at the top if you dont know what I mean.
It will only generate in new chunks, so it's best with a new world save.
Have fun with your now-generating ore!
To create a new smelting recipe, it's a pretty basic function whose basic structure looks like this:
That's the BASIC function; if I wanted to make emerald ore smelt into emerald gems, for example, I would alter it like this:
That would give me 1 emerald when I smelt an emerald ore. This bit of code has to go after the last AddName but before the first AddRecipe, for neatness sake. Have fun!
Stuff extending it, I'll make one for it eventually...
Nice tutorials btw, could try and make them more suited for begginers but it's your tutorial, not mine :tongue.gif: