In these tutorials we will learn the basics of modding by creating a ruby mod with ores, tools and other awesome stuff.
I assume you have basic computing knowledge and know how to install a mod.
If there is anything that are not clear, please say so.
Also if you get any errors please post them here.
With that said, lets get into it
Tutorial 1: Planning
First tutorial. Wow!
Lets start.
The first thing you should do in any mod is plan. So lets start doing that.
I like creating a new text file.
For the tutorial mod we will be making a ruby.
It will set things on fire,
It will have tools that can set things on fire.
There will be an ore block and a gem block which when set on fire burns forever.
You have to smelt the ore to get it out.
Any other things we can think of.
Tutorial 2: Setting up MCP
To set up MCP (Minecraft Coder Pack), follow these steps.
Copy your bin folder(the folder that contains minecraft.jar) into the jars folder in MCP
If you are making a SMP mod, copy minecraft_server.jar into the jars folder
make sure you have the Java Development Kit(JDK) and Python installed
make sure the minecraft.jar has no mods except modloader
run decompile.bat
You now have a modding environment set up
there are other tutorials for installing on Mac and Linux.
Tutorial 3: Creating the basic mod
So, if you have followed the last two tutorials you now have MCP set up.
Go into the folder called src.
Then go into minecraft then net then minecraft then src then you should see a whole bunch of java files.
This is where you spend most of your time making a mod.
Start by creating a new file called mod_Ruby.java
You need to have it start with mod_ to get Modloader to pick it up.
So, inside it start by putting this line:
package net.minecraft.src;
that means that it is part of minecraft.
then put this:
public class mod_Ruby extends BaseMod
{
public class means that this is a class which essentially means a type of thing.
mod_Ruby is the name of the class. it has to be the same name as the file without the .java
extends BaseMod means that this is a sub class of BaseMod. That means that this class is a specialized kind of that type. BaseMod is a class for mods.
{ is an opening bracket for something. in this case it is the class that is opened.
Next put this:
public String Version()
{
return "1.8.1";
}
Whoa thats a lot! let me explain it quickly.
public means that this can be accessed by anything. Which is generally good.
the other things that could be here are:
protected: only can be accessed by it and its family.
private: only can be accessed by it.
String means this is a String which is a bit of text within quotes e.g. "Hello World!"
Version() means this is a function called Version which is some code that usually returns something. Version is a required function for all mods. Without it the mod doesn't work.
{ you already know.
return means to say "I've done this now i'm giving you the results."
"1.8.1" "Hang on" you say "Isn't that the version number of minecraft?" Yes it is and if your mod doesn't have it's own version number you can put this in.
} ends something like this function or a class.
public mod_Ruby()
{
}
"Hang on a second" you say "This function doesn't have String or anything else next to it?"
that's right because this function is a constructor which is run when a new thing of this type is made. constructors have to have the same name as the class and the file.
}
} ends the class.
This should be where you are up to now: Current Files:
mod_Ruby.java
package net.minecraft.src;
public class mod_Ruby extends BaseMod
{
public String Version()
{
return "1.8.1";
}
public mod_Ruby()
{
}
}
Well thats enough for now until next time when we create our blocks.
Tutorial 4: Ore Block
If you remember last time we had just created our mod class and learnt the basics of java. YAY!
Now it is time to make our first block. How about our Ore block.
Start by making a new file called BlockOreRuby.java
Inside it put this.
package net.minecraft.src;
public class BlockOreRuby extends Block
{
public BlockOreRuby(int id, int texture)
{
super(id, texture, Material.rock);
}
}
OK a couple of things to explain here.
first what are those things between the ()?
those are arguments and are used when you want to give the function arguments.
super means go to the superclass (the class that's extended) and run the same function there.
Material.rock is a blocks material. this one is things like cobblestone and ores.
Oops there's something i forgot to go over earlier and thats ;.
; is the most important thing in java. it means the end of a line of code.
OK that's the block made but it won't show up in game yet.
To do that we need to go over to the mod_Ruby.java and add something.
We need to add:
Anywhere in the class:
public static final Block oreRuby = new BlockOreRuby(130, 51).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreRuby");
Wow! A lot of new things to explain here.
static means that it is the same to all things.
final means that it can't be changed.
= means that you are assigning to a variable, in this case oreRuby.
new means that you are creating a new thing of a certain class.
. is calling a function of a thing.
other functions are certain properties that it can have.
130 is the block id
51 is the texture which is that of redstone ore.
Finally a mention to ModLoader.
RegisterBlock(oreRuby); is a certain function you have to call for any new block.
AddName(oreRuby, "Ruby Ore"); is a function to add the name for the inventory.
Current Files:
mod_Ruby.java
package net.minecraft.src;
public class mod_Ruby extends BaseMod
{
public static final Block oreRuby = new BlockOreRuby(130, 51).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreRuby");
public String Version()
{
return "1.8.1";
}
public mod_Ruby()
{
ModLoader.RegisterBlock(oreRuby);
ModLoader.AddName(oreRuby, "Ruby Ore");
}
}
BlockOreRuby.java
package net.minecraft.src;
public class BlockOreRuby extends Block
{
public BlockOreRuby(int id, int texture)
{
super(id, texture, Material.rock);
}
}
Next time we'll see how to make the block naturally spawn
Tutorial 5: Naturally Spawned Block
OK so we now have a block but it can't be found. Let's make it spawn in a vein underground.
Add this to your mod_Ruby.java file in the class:
public void GenerateSurface(World world, Random random, int chunkX, int chunkZ)
{
//how much to generate on a 16x16x128 chunk of space in the world
int posX; //16 across
int posY; //128 down
int posZ; //16 deep
int tries;
int vein;
int level;
//oreRuby
tries = 10;
vein = 10;
level = 30;
for (int i = 0; i < tries; i++)
{
posX = chunkX + random.nextInt(16); //random x in the chunk from 0 - 15
posY = random.nextInt(level);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(oreRuby.blockID, vein)).generate(world, random, posX, posY, posZ);
}
}
Wow that's alot.
let me just explain something.
// is a comment. it is some text that explains something that you can put in.
if you have other ores you can copy the bit past //oreRuby to make them spawn naturally.
for is probably the best thing in java. it has this syntax(way it goes) for (at the start;check if continue;every time afterwards).
Random is a class that creates random numbers using the nextInt(maximum number +1) function.
you may want to change the level(highest level it can be put at), tries(attempts at putting the vein) or vein(how big the vein can be).
and add this to the top underneath package:
import java.util.Random;
import is something that brings something in. in this case it is the Random class.
you don't need to import anything inside the MCP/src/minecraft/net/minecraft/src folder because they have the same package as your mods.
Current Progress:
mod_Ruby.java
package net.minecraft.src;
import java.util.Random;
public class mod_Ruby extends BaseMod
{
public static final Block oreRuby = new BlockOreRuby(130, 51).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreRuby");
public String Version()
{
return "1.8.1";
}
public mod_Ruby()
{
ModLoader.RegisterBlock(oreRuby);
ModLoader.AddName(oreRuby, "Ruby Ore");
}
public void GenerateSurface(World world, Random random, int chunkX, int chunkZ)
{
//how much to generate on a 16x16x128 chunk of space in the world
int posX; //16 across
int posY; //128 down
int posZ; //16 deep
int tries;
int vein;
int level;
//oreRuby
tries = 10;
vein = 10;
level = 30;
for (int i = 0; i < tries; i++)
{
posX = chunkX + random.nextInt(16); //random x in the chunk from 0 - 15
posY = random.nextInt(level);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(oreRuby.blockID, vein)).generate(world, random, posX, posY, posZ);
}
}
}
BlockOreRuby.java
package net.minecraft.src;
public class BlockOreRuby extends Block
{
public BlockOreRuby(int id, int texture)
{
super(id, texture, Material.rock);
}
}
Next time we will be adding the item.
Tutorial 6: The Ruby and making it set things on fire.
Ok so now it is time to add the ruby.
In mod_Ruby.java add this:
public static Item ruby = new ItemRuby(4000).setName("ruby");
this gives it a name and a picture.
you can do the same for blocks just replacing iconIndex with blockIndexInTexture and gui/items.png with terrain.png.
now we will add a item class. if the item doesn't do anything special you don't need this and can just use Item.
make a ItemRuby.java file and put this in it:
package net.minecraft.src;
public class ItemRuby extends ItemFlintAndSteel
{
public ItemRuby(id)
{
super(id);
}
}
the reason why we extended ItemFlintAndSteel and not just Item is because this item will do the same thing as a flint and steel and thats set things on fire. Current Progress:
mod_Ruby.java
package net.minecraft.src;
import java.util.Random;
public class mod_Ruby extends BaseMod
{
public static final Block oreRuby = new BlockOreRuby(130, 51).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreRuby");
public static Item ruby = new ItemRuby(4000).setName("ruby");
public String Version()
{
return "1.8.1";
}
public mod_Ruby()
{
ModLoader.RegisterBlock(oreRuby);
ModLoader.AddName(oreRuby, "Ruby Ore");
ModLoader.AddName(ruby, "Ruby Gem");
ruby.iconIndex = ModLoader.AddOverride("/gui/items.png", "/ruby.png");
}
public void GenerateSurface(World world, Random random, int chunkX, int chunkZ)
{
//how much to generate on a 16x16x128 chunk of space in the world
int posX; //16 across
int posY; //128 down
int posZ; //16 deep
int tries;
int vein;
int level;
//oreRuby
tries = 10;
vein = 10;
level = 30;
for (int i = 0; i < tries; i++)
{
posX = chunkX + random.nextInt(16); //random x in the chunk from 0 - 15
posY = random.nextInt(level);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinable(oreRuby.blockID, vein)).generate(world, random, posX, posY, posZ);
}
}
}
ItemRuby.java
package net.minecraft.src;
public class ItemRuby extends ItemFlintAndSteel
{
public ItemRuby(id)
{
super(id);
}
}
BlockOreRuby.java
package net.minecraft.src;
public class BlockOreRuby extends Block
{
public BlockOreRuby(int id, int texture)
{
super(id, texture, Material.rock);
}
}
Thats about it for now until next time when we will add how to obtain this item.
Good Tutorials! I haven't done any moding at all before and this has really encouraged me! I've read through them all and I can't (if they ever come out) for the next ones!
In these tutorials we will learn the basics of modding by creating a ruby mod with ores, tools and other awesome stuff.
I assume you have basic computing knowledge and know how to install a mod.
If there is anything that are not clear, please say so.
Also if you get any errors please post them here.
With that said, lets get into it
Tutorial 1: Planning
First tutorial. Wow!
Lets start.
The first thing you should do in any mod is plan. So lets start doing that.
I like creating a new text file.
For the tutorial mod we will be making a ruby.
To set up MCP (Minecraft Coder Pack), follow these steps.
So, if you have followed the last two tutorials you now have MCP set up.
Go into the folder called src.
Then go into minecraft then net then minecraft then src then you should see a whole bunch of java files.
This is where you spend most of your time making a mod.
Start by creating a new file called mod_Ruby.java
You need to have it start with mod_ to get Modloader to pick it up.
So, inside it start by putting this line:
that means that it is part of minecraft.
then put this:
public class means that this is a class which essentially means a type of thing.
mod_Ruby is the name of the class. it has to be the same name as the file without the .java
extends BaseMod means that this is a sub class of BaseMod. That means that this class is a specialized kind of that type. BaseMod is a class for mods.
{ is an opening bracket for something. in this case it is the class that is opened.
Next put this:
Whoa thats a lot! let me explain it quickly.
public means that this can be accessed by anything. Which is generally good.
the other things that could be here are:
protected: only can be accessed by it and its family.
private: only can be accessed by it.
String means this is a String which is a bit of text within quotes e.g. "Hello World!"
Version() means this is a function called Version which is some code that usually returns something. Version is a required function for all mods. Without it the mod doesn't work.
{ you already know.
return means to say "I've done this now i'm giving you the results."
"1.8.1" "Hang on" you say "Isn't that the version number of minecraft?" Yes it is and if your mod doesn't have it's own version number you can put this in.
} ends something like this function or a class.
"Hang on a second" you say "This function doesn't have String or anything else next to it?"
that's right because this function is a constructor which is run when a new thing of this type is made. constructors have to have the same name as the class and the file.
} ends the class.
This should be where you are up to now:
Current Files:
mod_Ruby.java
Well thats enough for now until next time when we create our blocks.
Tutorial 4: Ore Block
If you remember last time we had just created our mod class and learnt the basics of java. YAY!
Now it is time to make our first block. How about our Ore block.
Start by making a new file called BlockOreRuby.java
Inside it put this.
OK a couple of things to explain here.
first what are those things between the ()?
those are arguments and are used when you want to give the function arguments.
super means go to the superclass (the class that's extended) and run the same function there.
Material.rock is a blocks material. this one is things like cobblestone and ores.
Oops there's something i forgot to go over earlier and thats ;.
; is the most important thing in java. it means the end of a line of code.
OK that's the block made but it won't show up in game yet.
To do that we need to go over to the mod_Ruby.java and add something.
We need to add:
Anywhere in the class:
Wow! A lot of new things to explain here.
static means that it is the same to all things.
final means that it can't be changed.
= means that you are assigning to a variable, in this case oreRuby.
new means that you are creating a new thing of a certain class.
. is calling a function of a thing.
other functions are certain properties that it can have.
130 is the block id
51 is the texture which is that of redstone ore.
In the constructor:
Finally a mention to ModLoader.
RegisterBlock(oreRuby); is a certain function you have to call for any new block.
AddName(oreRuby, "Ruby Ore"); is a function to add the name for the inventory.
Current Files:
mod_Ruby.java
Next time we'll see how to make the block naturally spawn
OK so we now have a block but it can't be found. Let's make it spawn in a vein underground.
Add this to your mod_Ruby.java file in the class:
Wow that's alot.
let me just explain something.
// is a comment. it is some text that explains something that you can put in.
if you have other ores you can copy the bit past //oreRuby to make them spawn naturally.
for is probably the best thing in java. it has this syntax(way it goes) for (at the start;check if continue;every time afterwards).
Random is a class that creates random numbers using the nextInt(maximum number +1) function.
you may want to change the level(highest level it can be put at), tries(attempts at putting the vein) or vein(how big the vein can be).
and add this to the top underneath package:
import is something that brings something in. in this case it is the Random class.
you don't need to import anything inside the MCP/src/minecraft/net/minecraft/src folder because they have the same package as your mods.
Current Progress:
mod_Ruby.java
Next time we will be adding the item.
Ok so now it is time to add the ruby.
In mod_Ruby.java add this:
and add this in the constructor:
this gives it a name and a picture.
you can do the same for blocks just replacing iconIndex with blockIndexInTexture and gui/items.png with terrain.png.
now we will add a item class. if the item doesn't do anything special you don't need this and can just use Item.
make a ItemRuby.java file and put this in it:
the reason why we extended ItemFlintAndSteel and not just Item is because this item will do the same thing as a flint and steel and thats set things on fire.
Current Progress:
mod_Ruby.java
Thats about it for now until next time when we will add how to obtain this item.
http://www.minecraftforum.net/topic/2695349-172-forge-awesome-sauce-mods/
http://www.minecraftforum.net/topic/2695349-172-forge-awesome-sauce-mods/
they should if you use the ModLoader.AddName("Ruby Ore"); function.
I haven't got around to them yet
Sorry about not having updated this.
http://www.minecraftforum.net/topic/2695349-172-forge-awesome-sauce-mods/