[color="#FF0000"][size="5"]MORE TUTORIALS ARE COMING[/size][/color]
[list=list]
[*] Adding Blocks
[*] Adding Items
[*] World Generation
[*] Weapons
[*] Armor
[*] Achievements
[*] Mobs (if I ever figure out what I'm doing with them)
[*] Things you suggest
[/list]
When I'm done, you should have everything you need to make all of you're epic mods.
Every detail in the tutorial is as clear and concise as I can make them.
If not and you feel it needs more explaining, send me a PM describing EXACTLY what you want to know.
This main post is simply for posting topics, you will click the links below to get to the actual tutorials.
These tutorials assume you already have MCP V4 installed properly and you already have ModLoader for 1.6.6 installed properly.
If you do not meet these requirements, do not read these tutorials. They will confuse you.
These tutorials have quizes that it is recommended you answer before continuing.
If you're wrong, read the post again. If you're right, read the post again.
You won't get it unless you try it, so actually do what's in the tutorials.
Know it. Understand it. Be able to do it without looking.
Tutorials are either crutches or jump starts. If you're new its jump start, if not, you're crippled.
[size="5"][url="http://www.minecraftforum.net/topic/363184-tutorial-everything-modloader-using-mcp/#entry5202413"]Basics of creating a mod[/url]
[url="http://www.minecraftforum.net/topic/363184-tutorial-everything-modloader-using-mcp/#entry5202419"]Adding a structured recipe[/url]
[url="http://www.minecraftforum.net/topic/363184-creating-modsmc-166-everything-modloader-using-mcp-june-5-2011/page__p__5202402#entry5202402"]Adding a shapeless recipe[/url]
[url="http://www.minecraftforum.net/topic/363184-creating-modsmc-166-everything-modloader-using-mcp-june-5-2011/#entry5202430"]Block basics[/url][/size]
List tags are malformed.
As the title suggests, these are the VERY basics. Nothing complicated and can hardly be considered coding.
The VERY first step to any ModLoader mod is the mod file.
ModLoader loads any mod with the "mod_" prefix in the name.
Your mod MUST have this prefix for it to be recognized by ModLoader.
It MUSTMUSTMUST have it to be loaded.
It must be lower case EXACTLY like it is above.
POP QUIZ: Yes a quiz already. I don't know how dumb you are.
Which of these can be loaded?
Mod_ThisIsAMod
MOD_MyFirstMod
mod_ImNewToModding
modYayForModding
The answer is :Green:. Only can be loaded because it has a lowercase prefix.
is wrong because the "M" in "mod_" is capitalized.
is wrong because every letter in "mod_" is capitalized.
is wrong because the "_" in "mod_" is missing.
If you got this answer wrong, you probably need to ACTUALLY READ THE POST.
If you get it wrong a second time, you probably shouldn't be modding.
Now that this is out of the way, what does the mod file actually look like?
Good question. The most basic file (we'll call it "mod_FirstMod.java") is this:
package net.minecraft.src;
public class mod_FirstMod extends BaseMod
{
public mod_FirstMod()
{
}
public String Version()
{
return "Current Version";
}
}
The name of this file (in case you didn't notice the bold before the spoiler) MUST be "mod_FirstMod.java"
That's the second time its in bold... you better understand that.
package net.minecraft.src;
This must be here. It won't compile properly without it. It tells MCP where the file is in minecraft.
Actually I'm not sure about that, it just sounds good, but it won't work without it. I DARE you to try it.
public class mod_FirstMod extends BaseMod
Defines mod_FirstMod as a class and it inherits all the methods (functions, but we're calling them methods because this is java), and variables from BaseMod. BaseMod is the type of instance (look in the Extras spoiler if you don't know what this means) ModLoader looks for when loading mods. mod_FirstMod must be an instance of BaseMod to be recognized as a mod.
public mod_FirstMod()
This is the constructor (again, check Extras) for mod_FirstMod. It doesn't have to have anything in it, but it will later.
public String Version()
It is a abstract public class (Extras) of type String (Extras). It displays when your mod is loaded, but you may never see it unless you open the java console while playing.
POP QUIZ:
What's wrong with this file named "mod_Example.java"?
package net.minecraft.src
public class mod_Example
{
public mod_Example()
{
}
public String Version()
{
}
}
There should be a ";" after "package net.minecraft.src". The ";" tells the compiler that this is the end of that line, otherwise is keeps reading and produces and error. This goes at the end of every line, and you'll see this as we go.
"public class mod_Example" should extend BaseMod. It doesn't have to, but ModLoader won't read it if it doesn't.
Version() has no return statement. It is a method called to give a value of type String. The return statement gives that value.
Extras:
instance: Open minecraft, push f3, and look at a mob. That number above their head identifies them. Pigs are instances of EntityPig. Every pig is and EntityPig, but they are all different. EntityPig defines what a pig is, but they are all different. Different locations and different movements. Your mod is BaseMod. BaseMod defines what it is, but each mod is different in what they do. constructor: Let's say you have no idea what a ladder is and someone says to build a ladder. You need blueprints. The constructor is the blueprints for an instance. Without the blueprints, you can't build the ladder. Without the constructor, java can't "build" an instance. abstract method: An abstract method is inherited to other things, but it hasn't defined what it does yet. Every class that inherits an abstract method must overwrite it and tell java what it does, otherwise it's confused and can't do anything. public method: These can be accessed from any class, at any time. They are available to the public. String: A variable type such as int (integer) or char (character). A String is a string of characters enclosed by qoutation marks.
This should help you create at least a file that doesn't give errors. We'll get into actually doing something to the game in the next tutorial.
If there are any more questions, PM them to me.
This is by far one of the easiest things to do in modding.
It's not hard to define what you want made, or how to make it.
We already know how to make a mod file ModLoader will actually load.
If not, go to the first tutorial.
Let's say you wanted a way to craft grass.
Maybe the recipe looks like this:
In the constructor of a mod called "mod_GrassMod.java" we want to add a couple of lines of code.
mod_GrassMod()
{
ModLoader.AddRecipe(new ItemStack(Block.grass, 1), new Object[] {
" ", " S ", " D ", Character.valueOf('S'), Item.seeds, Character.valueOf('D'), Block.dirt
});
}
Now, you may be wondering what the HELL this all means. I'll tell you.
ModLoader.AddRecipe()
The method in ModLoader.java that adds a recipe to the game.
new ItemStack()
Constructor to make a new instance of the ItemStack class.
Block.grass, 1
Tells ItemStack() that its made of grass. Because the variable grass is declared in the class Block, we use it by saying Block.grass. The 1 tells it that its only made of 1 grass instead of 10 or 12 or 64.
new Object[]
Makes a new Object, which is basically just an array, but doesn't all have to be one type.
This tells ModLoader.AddRecipe() what the actual recipe is to create what's in the ItemStack.
" ", " S ", " D "
Tells AddRecipe what is actually going to be in the crafting grid. " " has 3 spaces, meaning 3 blank boxes in the first row. " S " has a space, an S, and a space. This means blank box, whatever the hell S is going to be, blank box. " D " is the same way.
Character.valueOf('S'), Item.seeds
Tells AddRecipe what S means. This tells it that S is going to be seeds. The variable seeds was declared in the class Item, so we have to say Item.seeds to use it, just like we use Block.grass to get grass.
Now you know what all of this means, but this makes it so the recipe is always in those specific squares. What if you want to make this in the 2x2 grid?
Well, the beautiful thing about this is that we can remove parts, and this will still work.
Shorten it to this:
What if I want to use a specific type of sapling to get wood, like birch or redwood?
Well let's say you wanted to use 4 BIRCH sapling to get 1 BIRCH log.
ItemStack has 2 different constructors.
It can be ItemStack(block/item, amount)
or it can be ItemStack(block/item, amount, type)
type is the damage value of the item, except i'm using it for wood, so I'm just going to call it type. Its just a variable. It doesn't matter.
For both saplings and logs, the type for Birch is 2 and the variable wood in Block is for logs.
So to get a Birch log, you put ItemStack(Block.wood, 1, 2)
But how do I use the right sapling?
You know where we said that D was Block.dirt?
Well, we can use an ItemStack here as well.
ItemStack(Block.sapling, 1, 2) is a stack of 1 birch sapling.
If you haven't read "Adding a structured recipe", please read it before continuing.
This tutorial is a short one. I promise.
It's also the easiest one because you don't have to think as much.
We know that ModLoader.AddRecipe adds a structured recipe that we define, structured meaning it must be a specific shape.
Now we will learn how to make SHAPELESS recipes... you know, like dyed wool and things.
We're now going to use the function ModLoader.AddShapelessRecipe()... go figure...
It takes the same general structure as a structured recipe, but we're not going to have the shape defined.
All we need is a list of blocks that are going to be in recipe.
This adds a SHAPELESS recipe to make a sapling from dirt and logs... totally unrealistic...
ModLoader.AddShapelessRecipe(new ItemStack(Block.sapling, 1), new Object[] {
Block.dirt, Block.wood
});
You got some Deja Vu there didn't you?
I did.
It's almost the same as AddRecipe... well thats because they both add recipes...
Now, it's important that you notice we didn't add "D", "L", Character.valueOf('D'), Block.dirt, Character.valueOf('L'), Block.wood. We don't need it for this because that made a specific shape and specific blocks for each space. The funny thing about a shapeless recipe is that it's shapeless... We define what we want to be in the recipe and then those blocks can go anywhere in the crafting grid.
That's it... no quizes like the others because if you could handle structured recipes, this was a walk in the park.
All right... You know how to make a mod that adds recipes... What good is that without something new to make?
That's where this tutorial comes in.
We'll be making a block... and not a complicated one.
This block will be purely aesthetic. No functions unless you want to add it to a recipe for something.
More advanced Blocks will be in later tutorials.
Time to make a new file :biggrin.gif:.
We're going to make a Block that looks like smooth stone.
But when you break it, it doesn't drop cobblestone.
It'll drop itself, which looks loke smooth stone.
It'll be like magic. Do you want to be a magician?
Since It's going to be like magic... let's call the file BlockMagicStone.java.
That sounds interesting enough.
package net.minecraft.src
public class BlockMagicStone extends Block
{
public BlockMagicStone(int i, int j)
{
super(i, j, Material.rock);
}
}
super(i, j, Material.rock);
Well, let's talk about constructors a bit. You know how I said that they were essentially the blueprints for how to make something? Well it is. I haven't lied to you. We have our constructor and the super is the constructor for Block. Block's blueprints make you tell it specifics before it makes it. It's kind of like placing an order. Because we've extended Block, we have to specify things for Block, hence the super. Also, because we've inherited from Block and used its super, everything in the constructor for Block happens in the constructor for BlockMagicStone.
Material.rock
I won't go into a lot of detail, and it's fairly self explanatory. Every Block has a Material and rock is a material that needs to be mined with a pick to get.
Other materials include tnt, circuit, ground, iron plants, portal, etc...
Back to the constructor for Block. The actual constructor we use with super is
protected Block(int i, int j, Material material)
{
this(i, material);
blockIndexInTexture = j;
}
this(i, material);
This code means that Block has a second constructor.
Dang, this is really helpfull, thanks a ton, i have been modding for a while now, but never new how to get my mods Modloader compatible, i looked and looked and could not find a tut that would explain it enough that i could understand it, thanks a ton, and please continue doing these!
I plan on adding a lot more tutorials. I added a list of tutorials I plan on making. The World generation one should be fun, it's by far my favorite thing to do.
I'll keep my eye out for this, great tutorial. When/if you make your mob tutorial, can you make a custom model, instead of human? (e.g. using Techne) because I'm struggling with that kind of thing. D:
I don't know about using techne because it's windows only and I'd like to let everyone do it, but I would certainly make a custom model. What fun is it if you don't have you're own creature running around?
these are awesome tutorials, btw could you make one to make a block with a different texture on every side face the player and not North? Thanks heaps if you can
[list=list]
[*] Adding Blocks
[*] Adding Items
[*] World Generation
[*] Weapons
[*] Armor
[*] Achievements
[*] Mobs (if I ever figure out what I'm doing with them)
[*] Things you suggest
[/list]
When I'm done, you should have everything you need to make all of you're epic mods.
Every detail in the tutorial is as clear and concise as I can make them.
If not and you feel it needs more explaining, send me a PM describing EXACTLY what you want to know.
This main post is simply for posting topics, you will click the links below to get to the actual tutorials.
These tutorials assume you already have MCP V4 installed properly and you already have ModLoader for 1.6.6 installed properly.
If you do not meet these requirements, do not read these tutorials. They will confuse you.
These tutorials have quizes that it is recommended you answer before continuing.
If you're wrong, read the post again. If you're right, read the post again.
You won't get it unless you try it, so actually do what's in the tutorials.
Know it. Understand it. Be able to do it without looking.
Tutorials are either crutches or jump starts. If you're new its jump start, if not, you're crippled.
[size="5"][url="http://www.minecraftforum.net/topic/363184-tutorial-everything-modloader-using-mcp/#entry5202413"]Basics of creating a mod[/url]
[url="http://www.minecraftforum.net/topic/363184-tutorial-everything-modloader-using-mcp/#entry5202419"]Adding a structured recipe[/url]
[url="http://www.minecraftforum.net/topic/363184-creating-modsmc-166-everything-modloader-using-mcp-june-5-2011/page__p__5202402#entry5202402"]Adding a shapeless recipe[/url]
[url="http://www.minecraftforum.net/topic/363184-creating-modsmc-166-everything-modloader-using-mcp-june-5-2011/#entry5202430"]Block basics[/url][/size]
List tags are malformed.
Main Page
As the title suggests, these are the VERY basics. Nothing complicated and can hardly be considered coding.
The VERY first step to any ModLoader mod is the mod file.
ModLoader loads any mod with the "mod_" prefix in the name.
Your mod MUST have this prefix for it to be recognized by ModLoader.
It MUST MUST MUST have it to be loaded.
It must be lower case EXACTLY like it is above.
POP QUIZ: Yes a quiz already. I don't know how dumb you are.
Which of these can be loaded?
Mod_ThisIsAMod
MOD_MyFirstMod
mod_ImNewToModding
modYayForModding
is wrong because the "M" in "mod_" is capitalized.
is wrong because every letter in "mod_" is capitalized.
is wrong because the "_" in "mod_" is missing.
If you get it wrong a second time, you probably shouldn't be modding.
Now that this is out of the way, what does the mod file actually look like?
Good question. The most basic file (we'll call it "mod_FirstMod.java") is this:
The name of this file (in case you didn't notice the bold before the spoiler) MUST be "mod_FirstMod.java"
That's the second time its in bold... you better understand that.
package net.minecraft.src;
This must be here. It won't compile properly without it. It tells MCP where the file is in minecraft.
Actually I'm not sure about that, it just sounds good, but it won't work without it. I DARE you to try it.
public class mod_FirstMod extends BaseMod
Defines mod_FirstMod as a class and it inherits all the methods (functions, but we're calling them methods because this is java), and variables from BaseMod. BaseMod is the type of instance (look in the Extras spoiler if you don't know what this means) ModLoader looks for when loading mods. mod_FirstMod must be an instance of BaseMod to be recognized as a mod.
public mod_FirstMod()
This is the constructor (again, check Extras) for mod_FirstMod. It doesn't have to have anything in it, but it will later.
public String Version()
It is a abstract public class (Extras) of type String (Extras). It displays when your mod is loaded, but you may never see it unless you open the java console while playing.
POP QUIZ:
What's wrong with this file named "mod_Example.java"?
"public class mod_Example" should extend BaseMod. It doesn't have to, but ModLoader won't read it if it doesn't.
Version() has no return statement. It is a method called to give a value of type String. The return statement gives that value.
constructor: Let's say you have no idea what a ladder is and someone says to build a ladder. You need blueprints. The constructor is the blueprints for an instance. Without the blueprints, you can't build the ladder. Without the constructor, java can't "build" an instance.
abstract method: An abstract method is inherited to other things, but it hasn't defined what it does yet. Every class that inherits an abstract method must overwrite it and tell java what it does, otherwise it's confused and can't do anything.
public method: These can be accessed from any class, at any time. They are available to the public.
String: A variable type such as int (integer) or char (character). A String is a string of characters enclosed by qoutation marks.
This should help you create at least a file that doesn't give errors. We'll get into actually doing something to the game in the next tutorial.
If there are any more questions, PM them to me.
Main Page
This is by far one of the easiest things to do in modding.
It's not hard to define what you want made, or how to make it.
We already know how to make a mod file ModLoader will actually load.
If not, go to the first tutorial.
Let's say you wanted a way to craft grass.
Maybe the recipe looks like this:
In the constructor of a mod called "mod_GrassMod.java" we want to add a couple of lines of code.
Now, you may be wondering what the HELL this all means. I'll tell you.
ModLoader.AddRecipe()
The method in ModLoader.java that adds a recipe to the game.
new ItemStack()
Constructor to make a new instance of the ItemStack class.
Block.grass, 1
Tells ItemStack() that its made of grass. Because the variable grass is declared in the class Block, we use it by saying Block.grass. The 1 tells it that its only made of 1 grass instead of 10 or 12 or 64.
new Object[]
Makes a new Object, which is basically just an array, but doesn't all have to be one type.
This tells ModLoader.AddRecipe() what the actual recipe is to create what's in the ItemStack.
" ", " S ", " D "
Tells AddRecipe what is actually going to be in the crafting grid. " " has 3 spaces, meaning 3 blank boxes in the first row. " S " has a space, an S, and a space. This means blank box, whatever the hell S is going to be, blank box. " D " is the same way.
Character.valueOf('S'), Item.seeds
Tells AddRecipe what S means. This tells it that S is going to be seeds. The variable seeds was declared in the class Item, so we have to say Item.seeds to use it, just like we use Block.grass to get grass.
Now you know what all of this means, but this makes it so the recipe is always in those specific squares. What if you want to make this in the 2x2 grid?
Well, the beautiful thing about this is that we can remove parts, and this will still work.
Shorten it to this:
Now that we've used " S" and " D" (note the spaces before the letters), the recipe is this:
This is okay, but not versatile enough.
We're going to remove the a space to make " S" (still has space) and "D".
Well, this makes the recipe:
That's not right, so now let's use just "S" and "D" (neither with spaces).
Now we have the glorious recipe:
We can move it anywhere in the crafting grid and it works. Examples:
| |
| |
| |
POP QUIZ:
What recipe does this define, and what does it make?
result:
64
What if I want to use a specific type of sapling to get wood, like birch or redwood?
Well let's say you wanted to use 4 BIRCH sapling to get 1 BIRCH log.
ItemStack has 2 different constructors.
It can be ItemStack(block/item, amount)
or it can be ItemStack(block/item, amount, type)
type is the damage value of the item, except i'm using it for wood, so I'm just going to call it type. Its just a variable. It doesn't matter.
For both saplings and logs, the type for Birch is 2 and the variable wood in Block is for logs.
So to get a Birch log, you put ItemStack(Block.wood, 1, 2)
But how do I use the right sapling?
You know where we said that D was Block.dirt?
Well, we can use an ItemStack here as well.
ItemStack(Block.sapling, 1, 2) is a stack of 1 birch sapling.
This code produces the desired recipe:
See how I used S again?
You can use it as many times as you want.
It's only a sapling in this specific recipe. It can be anything else in another.
POP QUIZ:
Write code to define this recipe. (Hint: use Block.planks for :wood:)
= 36
Again, questions can be sent via PM.
Main Page
If you haven't read "Adding a structured recipe", please read it before continuing.
This tutorial is a short one. I promise.
It's also the easiest one because you don't have to think as much.
We know that ModLoader.AddRecipe adds a structured recipe that we define, structured meaning it must be a specific shape.
Now we will learn how to make SHAPELESS recipes... you know, like dyed wool and things.
We're now going to use the function ModLoader.AddShapelessRecipe()... go figure...
It takes the same general structure as a structured recipe, but we're not going to have the shape defined.
All we need is a list of blocks that are going to be in recipe.
This adds a SHAPELESS recipe to make a sapling from dirt and logs... totally unrealistic...
You got some Deja Vu there didn't you?
I did.
It's almost the same as AddRecipe... well thats because they both add recipes...
Now, it's important that you notice we didn't add "D", "L", Character.valueOf('D'), Block.dirt, Character.valueOf('L'), Block.wood. We don't need it for this because that made a specific shape and specific blocks for each space. The funny thing about a shapeless recipe is that it's shapeless... We define what we want to be in the recipe and then those blocks can go anywhere in the crafting grid.
That's it... no quizes like the others because if you could handle structured recipes, this was a walk in the park.
UNDER CONSTRUCTION
All right... You know how to make a mod that adds recipes... What good is that without something new to make?
That's where this tutorial comes in.
We'll be making a block... and not a complicated one.
This block will be purely aesthetic. No functions unless you want to add it to a recipe for something.
More advanced Blocks will be in later tutorials.
Time to make a new file :biggrin.gif:.
We're going to make a Block that looks like smooth stone.
But when you break it, it doesn't drop cobblestone.
It'll drop itself, which looks loke smooth stone.
It'll be like magic. Do you want to be a magician?
Since It's going to be like magic... let's call the file BlockMagicStone.java.
That sounds interesting enough.
super(i, j, Material.rock);
Well, let's talk about constructors a bit. You know how I said that they were essentially the blueprints for how to make something? Well it is. I haven't lied to you. We have our constructor and the super is the constructor for Block. Block's blueprints make you tell it specifics before it makes it. It's kind of like placing an order. Because we've extended Block, we have to specify things for Block, hence the super. Also, because we've inherited from Block and used its super, everything in the constructor for Block happens in the constructor for BlockMagicStone.
Material.rock
I won't go into a lot of detail, and it's fairly self explanatory. Every Block has a Material and rock is a material that needs to be mined with a pick to get.
Other materials include tnt, circuit, ground, iron plants, portal, etc...
Back to the constructor for Block. The actual constructor we use with super is
this(i, material);
This code means that Block has a second constructor.
I'm doing this one step at a time, but I can do that next if you want.
FINALLY! A MCP TUTORIAL IN 1.6.6 USING MODLOADER!!!
I don't know about using techne because it's windows only and I'd like to let everyone do it, but I would certainly make a custom model. What fun is it if you don't have you're own creature running around?
these are awesome tutorials, btw could you make one to make a block with a different texture on every side face the player and not North? Thanks heaps if you can