In these tutorials I will explain how to create basic mods. I am willing to help people learn how to mod and I will take requests on how to mod certain things. The aim of this thread is to create a central location for all tutorials.
Below is a tutorial list which has details about each mod. Note that no matter how old the tutorial is, what you should learn in the tutorial is how to go about modding that particular aspect of the game.
Note: MCP only works for the version of Minecraft it is released with. You CANNOT use MCP with a newer or older version of minecraft. For example: MCP 2.6 ONLY works with Minecraft 1.1_02.
Tutorial List (Game Mods): Create a new Block type Difficulty/Time: 2/10 Last Update: 21/Feb/2011 Minecraft Version: Alpha 1.2.6 - Beta 1.5_01 MCP Version: 2.7-3.1 Author: simo_415
Create a new Recipe Difficulty/Time: 1/10 Last Update: 12/Dec/2010 Minecraft Version: Alpha 1.2.6 - Beta 1.5_01 MCP Version: 2.5 - 3.1 Author: simo_415
Create a new Item type Difficulty/Time: 2/10 Last Update: 12/Dec/2010 Minecraft Version: Alpha 1.2.6 - Beta 1.5_01 MCP Version: 2.5 - 3.1 Author: simo_415
Create a new Block for the Furnace Difficulty/Time: 2/10 Last Update: 14/Dec/2010 Minecraft Version: 1.2.6 - ? MCP Version: 2.5 - ? Author: Marcus101RR
Customising a block class Difficulty/Time: 3/10 Last Update: 17/Dec/2010 Minecraft Version: Alpha 1.2.6 - Beta 1.5_01 MCP Version: 2.5 - 3.1 Author: simo_415
Create a new NPC Difficulty/Time: 6/10 Last Update: 17/Dec/2010 Minecraft Version: Beta 1.5_01 MCP Version: 2.7-3.1 Author: simo_415
Controlling NPC movement Difficulty/Time: 6/10 Last Update: 20/Jan/2011 Minecraft Version: 1.1_02 MCP Version: 2.6 Author: OgreSean
If you would like another tutorial added to this list please PM me the link to the thread/post and if it is a legitimate modding tutorial I will add it to this list.
1. Setup the minecraft coder pack (MCP)
1.1 Extract the ZIP to a directory on your computer, for this example; C:/MCP
1.2 Copy the whole .minecraft/bin and .minecraft/resources directories to C:/MCP/jars/
1.3 Run decompile.bat
2. Open two Windows, one to C:/MCP/sources/minecraft/net/minecraft/src the other to C:/MCP/
Running your mods
To run your mods you first need to compile, debug, and test.
1. To compile run 'recompile.bat' this will generate all the class files for minecraft.
2. Go to C:/MCP/logs/minecraft_compile.log and search for ^ if this character is not found, there are no compile errors. If there is you will need to fix your code where the errors are and try compiling again.
3. If there is no errors, run 'test_game.bat'.
4. This will bring up an alternate version of minecraft with your mod installed - test your mod.
Once satisfied that the mod is complete you need to obfuscate it so that it can be added to minecraft.jar
Using Eclipse
You can use Eclipse to write your mod in, debug your code, compile your code, run your code - it will save you a lot of time in the long run if you use it.
Obfuscating the Code
Obfuscating the code allows your mod to work in minecraft.jar for anyone
1. Open C:/MCP/conf/client_conf.txt
2. Remove all the lines in the file.
3. Add the classes you changed, for example:
BlockExample
Block
CraftingManager
4. Run 'reobf.bat'
5. All the classes contained within C:/MCP/final_out/minecraft/ are the mod classes. Add these to minecraft.jar to add your mod to the game.
Any questions about this feel free to ask. Please refer people who are posting on how to add a block/crafting recipe to this post. I will probably add a few more tutorials on how to do simple things. Any feedback is appreciated.
In this tutorial I will explain how to create a new block in Minecraft and how to make it craftable. This tutorial makes a standard block like stone.
Creating a new block
1. You need to make a new file called BlockExample.java in the src directory.
2. The basic structure of this file is this:
package net.minecraft.src;
import java.util.Random;
public class BlockExample extends Block
{
public BlockExample(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return 0;
}
}
3. You now need to add this block to minecraft so that it knows about it. To do this open up Block.java
4. You should see a whole bunch of variable declarations towards the bottom of the file, add a new one:
public static final Block example;
5. Below the declarations you should see initialisation of these instance variables, initialise your block.
example = (new BlockExample(92, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep);
Like mentioned before this example block is creating a new 'stone' block.
new BlockExample(92, 1) creates the new block, the first number is the block id - THIS HAS TO BE UNIQUE, the second number is the graphic of the block, in this case the same as stone.
setHardness(1.5F) is the same as stone, this is how long it takes to destroy a block.
setResistance(10F) is the same as stone, this is how strong the block is against explosions.
setStepSound(soundStoneFootstep) is the same as stone, this is the sound it makes when you walk on it.
You have now successfully created a new block class. To use this block you need to generate it, this can be done using the Single Player Commands mod using this command: "/give 92".
Continue on reading if you want to add a recipe to the crafting table to make this block.
Creating a new recipe
1. Open up CraftingManager.java
2. You should immediately see the constructor for the class and within it recipes being added using the addRecipe function.
3. Scroll to the bottom of this list of recipes and add in a new one:
addRecipe(new ItemStack(Block.example, 1), new Object[] {"##", "##", Character.valueOf('#'), Block.dirt});
This will add a recipe in which when you craft four dirt is a square share will give you your new block.
new ItemStack(Block.example, 1) - this specifies what item is going to be generated and the quantity.
new Object[] {"##", "##", Character.valueOf('#'), Block.dirt} - this specifies how it is created.
This should allow you to now craft a very basic new block using four dirt like so:
:tongue.gif:
1. You need to create a new file called ItemExample.java in the src directory.
2. The basic structure of the file is this:
package net.minecraft.src;
public class ItemExample extends Item
{
public ItemFood(int i)
{
super(i);
maxStackSize = 64;
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
}
}
3. You now need to add this item to minecraft so that it knows about it. To do this open up Item.java
4. Towards the bottom of the file there should be a whole heap of instance variables, add a new one:
public static Item example = (new ItemExample(95)).setIconIndex(42);
This will create a new item which is item id 256 + 95 and uses icon 42. Therefore it should look like a sign. Currently it has no properties, and you cannot craft it. But after you compile and run the mod it will add the new item to minecraft.
Thx for this tutorial, but Im stuck at "recompile.bat" because when I run it, it says:
Finding javac.exe... if you want to speed this up, add it to your PATH
'C:\Users\Hypothawits\minecraft' is not recognized as an internal or external command
,
operable program or batch file.
Path set.
Unable to locate javac.exe. Please verify that it is in the PATH.
If you don't know where to get it, please visit http://www.oracle.com/technetwor
k/java/javase/downloads/index.html and download a JDK.
Press any key to continue . . .
Yes I have JDK, but how can I change the PATH?
I gather you have no knowledge of Java in this case, I hope you have programming knowledge... Basically you need to add javac to the PATH there are ample guides on how to do this if you search google.
underneath the two recipes for a bow and arrows in RecipesWeapons.java
and lastly added
public static Item spear (new ItemSpear(101, 0)).setIconIndex(53);
to Item.java It should look like a stick. So what's wrong? I've recompiled, tested and it didn't work. So I reobfuscated and put the new class files into my minecraft.jar and it didn't work there either.
Have you checked your compile logs? Read my first post about it.
I copied your code and compiled it and found that there was a compile error "Item.sticks" not found. I changed it to Item.stick and this is what I got:
Also I gather you are using the ModLoader due to craftingmanager.addRecipe(...) I haven't used this and I am not sure the level of support that there is for MCP as well, if there is any other problem with your code it would be to do with that... The rest of it is perfect.
Another thing, I went into the jar folder and drew a spear sprite and put it in the slot that should be setIconIndex(255)
I tried that and the spear just returned no sprite. I also edited the item.png in the bin.minecraft jar to be the same, so how do I set up new sprites?
Another thing, I went into the jar folder and drew a spear sprite and put it in the slot that should be setIconIndex(255)
I tried that and the spear just returned no sprite. I also edited the item.png in the bin.minecraft jar to be the same, so how do I set up new sprites?
You need to edit the /temp/minecraft/gui/item.png file.
I`ve made a new block (just the example one). and I want to test the game,I haven`t any bugs in my scripts but it will not run. please helpme fast.
gameman
Some more information would help I guess. If there are no errors in the compile log and the game won't run this is very unusual. Will the minecraft GUI appear? Does the test_game.bat script print out any errors (put a "pause" at the end of the script to check)?
Im trying to make a Bacon block but i keep getting errors while compiling..
Note:I know it already exist but i'm new and i gotta start somewhere
MeatBlock.java
package net.minecraft.src;
import java.util.Random;
public class MeatBlock extends Block
{
public MeatBlock(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return 0;
}
}
Error
MeatBlock.java:5: cannot find symbol
symbol: class Block
public class MeatBlock extends Block
^
MeatBlock.java:5: cannot find symbol
symbol: variable Material
location: class net.minecraft.scr.MeatBlock
super(i, j, Material.rock);
2 errors
EDIT: I found it nvm :tongue.gif:
EDIT 2: I lied. When i recompile everything all the "block" classes are missing, "crafting" classes and MeatBlock(my custom block) is missing.. Help please D:
From the two errors I can one obvious problem "net.minecraft.scr.MeatBlock" should be "net.minecraft.src.MeatBlock". The other problem could be the same as the first, check the package name (first line of file) make sure that this is correct, it needs to be the same as all the other files.
Thanks, now is there a way to do it with a separate sprite sheet? I want to make it compatible with other mods so that if other mods use items.png my spear won't conflict.
Thanks, now is there a way to do it with a separate sprite sheet? I want to make it compatible with other mods so that if other mods use items.png my spear won't conflict.
Hmm.. I haven't delved that deeply into the actual sprites, I would assume that it is possible to do by changing RenderItem.java to pick up a new file or create a new Render class. Like I mentioned I haven't really had too good a look into how to do this though.
I tried making an item and did exactly what you did but i keep on coming up with
[parsing started sources\minecraft\net\minecraft\src\ItemExample.java]
sources\minecraft\net\minecraft\src\ItemExample.java:5: invalid method declaration; return type required
public ItemFood(int i)
^
I`ve made a new block (just the example one). and I want to test the game,I haven`t any bugs in my scripts but it will not run. please helpme fast.
gameman
Some more information would help I guess. If there are no errors in the compile log and the game won't run this is very unusual. Will the minecraft GUI appear? Does the test_game.bat script print out any errors (put a "pause" at the end of the script to check)?
There are no pauses i can see it real quck and it goes away. Even when I try it again it doesn`t work.
I did a cleanup it doesn`t work. I hope this is enough information.
Gameman
Umm... add a new line at the bottom of "recompile.bat" that is "pause" then show me the output.
I tried making an item and did exactly what you did but i keep on coming up with
[parsing started sources\minecraft\net\minecraft\src\ItemExample.java]
sources\minecraft\net\minecraft\src\ItemExample.java:5: invalid method declaration; return type required
public ItemFood(int i)
^
Any help would be greatly appreciated :smile.gif:
Java must have the same file name as class name as constructor name.
Therefore you need to rename your file to "ItemFood.java" or your class + constructor to "ItemExample"
In these tutorials I will explain how to create basic mods. I am willing to help people learn how to mod and I will take requests on how to mod certain things. The aim of this thread is to create a central location for all tutorials.
Below is a tutorial list which has details about each mod. Note that no matter how old the tutorial is, what you should learn in the tutorial is how to go about modding that particular aspect of the game.
Note: MCP only works for the version of Minecraft it is released with. You CANNOT use MCP with a newer or older version of minecraft. For example: MCP 2.6 ONLY works with Minecraft 1.1_02.
Tutorial List (Game Mods):
Create a new Block type
Difficulty/Time: 2/10
Last Update: 21/Feb/2011
Minecraft Version: Alpha 1.2.6 - Beta 1.5_01
MCP Version: 2.7-3.1
Author: simo_415
Create a new Recipe
Difficulty/Time: 1/10
Last Update: 12/Dec/2010
Minecraft Version: Alpha 1.2.6 - Beta 1.5_01
MCP Version: 2.5 - 3.1
Author: simo_415
Create a new Item type
Difficulty/Time: 2/10
Last Update: 12/Dec/2010
Minecraft Version: Alpha 1.2.6 - Beta 1.5_01
MCP Version: 2.5 - 3.1
Author: simo_415
Create a new Block for the Furnace
Difficulty/Time: 2/10
Last Update: 14/Dec/2010
Minecraft Version: 1.2.6 - ?
MCP Version: 2.5 - ?
Author: Marcus101RR
Customising a block class
Difficulty/Time: 3/10
Last Update: 17/Dec/2010
Minecraft Version: Alpha 1.2.6 - Beta 1.5_01
MCP Version: 2.5 - 3.1
Author: simo_415
Create a new NPC
Difficulty/Time: 6/10
Last Update: 17/Dec/2010
Minecraft Version: Beta 1.5_01
MCP Version: 2.7-3.1
Author: simo_415
Controlling NPC movement
Difficulty/Time: 6/10
Last Update: 20/Jan/2011
Minecraft Version: 1.1_02
MCP Version: 2.6
Author: OgreSean
Create custom world generation
Difficulty/Time: 5/10
Last Update: 17/Dec/2010
Minecraft Version: Alpha 1.2.6 - Beta 1.5_01
MCP Version: 2.5 - 3.1
Author: simo_415
Making an Item with ModLoader
Difficulty/Time: 3/10
Last Update: 20/Feb/2011
Minecraft Version: Beta 1.2_02
MCP Version: 2.7
Author: Gidding
Custom WorldGeneration (ModLoader)
Difficulty/Time: 5/10
Last Update: 20/Feb/2011
Minecraft Version: Beta 1.2_02
MCP Version: 2.7
Author: Club559
Creating a weapon (ModLoader)
Difficulty/Time: 3/10
Last Update: 18/Mar/2011
Minecraft Version: Beta 1.3_01
MCP Version: 2.9
Author: blahthing
Creating a pickaxe/shovel (ModLoader)
Difficulty/Time: 3/10
Last Update: 18/Mar/2011
Minecraft Version: Beta 1.3_01
MCP Version: 2.9
Author: blahthing
Create a Custom Block with Modloader
Difficulty/Time: 2/10
Last Update: 17/Jun/2011
Minecraft Version: Beta 1.6.6
MCP Version: 3.3
Author: BuilderJ3rk
Tutorial List (Other):
Making your mod compatible with the ModLoader
Difficulty/Time: 4/10
Last Update: 9/Jan/2011
Author: Club559
How to make a simple person mob (with ModLoader)
Difficulty/Time: 5/10
Last Update: 9/Jan/2011
Author: Club559
How to update a mod to the latest version of MC (without MCP)
Difficulty/Time: 8/10
Last Update: 28/Dec/2010
Author: simo_415
How to mod on a MAC
Difficulty/Time: 4/10
Last Update: 12/Jan/2011
Author: BHCS
Thorough guide to beginning Minecraft modding
Difficulty/Time: 1-3/10
Author: birjolaxew
Complete beginners guide to modding
Difficulty/Time: 1-3/10
Author: Mr. Hobo
Fixing common compile and runtime errors
Difficulty/Time: 1/10
Last Update: 21/May/2011
Author: simo_415
SMP Modding:
How to mod a SMP server
Difficulty/Time: Varies
Author: Mzaq
If you would like another tutorial added to this list please PM me the link to the thread/post and if it is a legitimate modding tutorial I will add it to this list.
Requirements
1. Java Development Kit 6 (JDK6)
2. Minecraft Coder Pack (latest)
3. EditPlus/Notepad++/Eclipse/Netbeans (text editor with syntax highlighting)
4. Programming knowledge, preferably Java
To begin with
1. Setup the minecraft coder pack (MCP)
1.1 Extract the ZIP to a directory on your computer, for this example; C:/MCP
1.2 Copy the whole .minecraft/bin and .minecraft/resources directories to C:/MCP/jars/
1.3 Run decompile.bat
2. Open two Windows, one to C:/MCP/sources/minecraft/net/minecraft/src the other to C:/MCP/
Running your mods
To run your mods you first need to compile, debug, and test.
1. To compile run 'recompile.bat' this will generate all the class files for minecraft.
2. Go to C:/MCP/logs/minecraft_compile.log and search for ^ if this character is not found, there are no compile errors. If there is you will need to fix your code where the errors are and try compiling again.
3. If there is no errors, run 'test_game.bat'.
4. This will bring up an alternate version of minecraft with your mod installed - test your mod.
Once satisfied that the mod is complete you need to obfuscate it so that it can be added to minecraft.jar
Using Eclipse
You can use Eclipse to write your mod in, debug your code, compile your code, run your code - it will save you a lot of time in the long run if you use it.
Obfuscating the Code
Obfuscating the code allows your mod to work in minecraft.jar for anyone
1. Open C:/MCP/conf/client_conf.txt
2. Remove all the lines in the file.
3. Add the classes you changed, for example:
4. Run 'reobf.bat'
5. All the classes contained within C:/MCP/final_out/minecraft/ are the mod classes. Add these to minecraft.jar to add your mod to the game.
Any questions about this feel free to ask. Please refer people who are posting on how to add a block/crafting recipe to this post. I will probably add a few more tutorials on how to do simple things. Any feedback is appreciated.
Creating a new block
1. You need to make a new file called BlockExample.java in the src directory.
2. The basic structure of this file is this:
3. You now need to add this block to minecraft so that it knows about it. To do this open up Block.java
4. You should see a whole bunch of variable declarations towards the bottom of the file, add a new one:
5. Below the declarations you should see initialisation of these instance variables, initialise your block.
Like mentioned before this example block is creating a new 'stone' block.
new BlockExample(92, 1) creates the new block, the first number is the block id - THIS HAS TO BE UNIQUE, the second number is the graphic of the block, in this case the same as stone.
setHardness(1.5F) is the same as stone, this is how long it takes to destroy a block.
setResistance(10F) is the same as stone, this is how strong the block is against explosions.
setStepSound(soundStoneFootstep) is the same as stone, this is the sound it makes when you walk on it.
You have now successfully created a new block class. To use this block you need to generate it, this can be done using the Single Player Commands mod using this command: "/give 92".
Continue on reading if you want to add a recipe to the crafting table to make this block.
Creating a new recipe
1. Open up CraftingManager.java
2. You should immediately see the constructor for the class and within it recipes being added using the addRecipe function.
3. Scroll to the bottom of this list of recipes and add in a new one:
This will add a recipe in which when you craft four dirt is a square share will give you your new block.
new ItemStack(Block.example, 1) - this specifies what item is going to be generated and the quantity.
new Object[] {"##", "##", Character.valueOf('#'), Block.dirt} - this specifies how it is created.
This should allow you to now craft a very basic new block using four dirt like so:
:tongue.gif:
1. You need to create a new file called ItemExample.java in the src directory.
2. The basic structure of the file is this:
3. You now need to add this item to minecraft so that it knows about it. To do this open up Item.java
4. Towards the bottom of the file there should be a whole heap of instance variables, add a new one:
This will create a new item which is item id 256 + 95 and uses icon 42. Therefore it should look like a sign. Currently it has no properties, and you cannot craft it. But after you compile and run the mod it will add the new item to minecraft.
I gather you have no knowledge of Java in this case, I hope you have programming knowledge... Basically you need to add javac to the PATH there are ample guides on how to do this if you search google.
For example... here is one: http://www.phoons.com/john/classes/aboutpath.html
You can test if it is set by opening up a shell/command prompt and typing 'javac' if it is found then it is configured correctly.
In a file called ItemSpear.java
then added
underneath the two recipes for a bow and arrows in RecipesWeapons.java
and lastly added
to Item.java It should look like a stick. So what's wrong? I've recompiled, tested and it didn't work. So I reobfuscated and put the new class files into my minecraft.jar and it didn't work there either.
Any help?
I copied your code and compiled it and found that there was a compile error "Item.sticks" not found. I changed it to Item.stick and this is what I got:
Also I gather you are using the ModLoader due to craftingmanager.addRecipe(...) I haven't used this and I am not sure the level of support that there is for MCP as well, if there is any other problem with your code it would be to do with that... The rest of it is perfect.
/me feels retarded O.o
Hehe it's ok
I tried that and the spear just returned no sprite. I also edited the item.png in the bin.minecraft jar to be the same, so how do I set up new sprites?
You need to edit the /temp/minecraft/gui/item.png file.
Sounds like the decompile.bat didn't rename all the classes correctly. Try running update_names.bat and try again
Some more information would help I guess. If there are no errors in the compile log and the game won't run this is very unusual. Will the minecraft GUI appear? Does the test_game.bat script print out any errors (put a "pause" at the end of the script to check)?
From the two errors I can one obvious problem "net.minecraft.scr.MeatBlock" should be "net.minecraft.src.MeatBlock". The other problem could be the same as the first, check the package name (first line of file) make sure that this is correct, it needs to be the same as all the other files.
Hmm.. I haven't delved that deeply into the actual sprites, I would assume that it is possible to do by changing RenderItem.java to pick up a new file or create a new Render class. Like I mentioned I haven't really had too good a look into how to do this though.
Any help would be greatly appreciated :smile.gif:
Umm... add a new line at the bottom of "recompile.bat" that is "pause" then show me the output.
Java must have the same file name as class name as constructor name.
Therefore you need to rename your file to "ItemFood.java" or your class + constructor to "ItemExample"