Hi all! This is my first post and I think I would like to make it helpful to everyone out there reading this. If you follow this closely, you will have a block made for minecraft by the end. There are many ways to do this, but this is probably the easiest. This will hopefully help set you on your minecraft modding adventure! (this mod is NOT made with MinecraftForge or Modloader )
I will assume you have already downloaded MCP, but if you don't, get it because you will need it. You will need to locate the following files (in your /src/minecraft.../src):
Block.java
CraftingManager.java
You will need to make the following file:
BlockAwesome.java (make sure it starts with Block ... .java)
In your BlockAwesome file, type the following at the top:
The package is declaring the package the file is in. If you are using eclipse, you will get LOTS of errors! Don't worry! It's right! We will need random later on in the code. Below that, type:
class BlockAwesome extends Block{
public BlockAwesome(int blockID){
}
}
We are now declaring the class and that it shares variables with Block.java. Then we make the constructor for the class. Next, we need to get in to the good suff! Type:
package minecraft.net.src;
import java.util.Random;
public class BlockAwesome extends Block{
public BlockAwesome(int blockID){
//Declaring material
super(blockID, 74, Material.wood);
//Getting texture
blockIndexInTexture = x;
//Creative mode
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int quantityDropped(Random random){
//How many items you get when you mine the block
return 64;
}
public int idDropped(int i, Random random){
//CHANGE THIS TO WHATEVER IS DROPPED WHEN YOU MINE THE BLOCK!!!
return Block.wood.blockID;
}
}
Now that's quite a bit of code. The good news is that is the most we will be typing in one file The obvious values you can change (like how many items are dropped when you mine the block) but try to keep most of it the same. The comment saying "Change this!" you should change.
Notice I put "x" in the blockIndexInTexture() thing. That is because if you open your terrain.png, there are different square id's. All the purple ones are vacant. If you count left to right from 0 at the top, you will get the id's. For example, gravel is 0. Stone is 1. Dirt is 2. So on and so forth. When you get to the end of a line, keep counting up until you get to a purple square. Colour that square to your liking and type the square id where "x" is. Save the terrain.png file.
Save BlockAwesome.java in your src file. Now, open up the Block.java file. This is a big file so read carefully. At the bottom of all the "public static final blabla = ..." type the following:
///ADDED BLOCKS!////
public static final awesome = (new BlockAwesome(146)).setHardness(1.0F).setResistance(3000.0F).setBlockName("BlockAwesome").setStepSound(soundStoneFootstep);
Feel free to play with these numbers to find the right one. The "146" near the beginning is the item id. If you have no extra mods installed and you are running minecraft 1.4.7, that should be the next id. (1.5 users, use 200 because of the new blocks added!(i.e. redstone blocks)) You can always choose something like 200 to be safe if you get errors. The only other footsteps I would use are "soundWoodFootstep", and "soundGrassFootstep". Refer to the top of Block.java to see all the options. Now, save that file and open CraftingManager.java. Scroll to the bottom of all the "this.addRecipe(..." and type
this.addRecipe(new ItemStack(Block.awesome, 1), new Object[] {" I ", "I I", " I ", 'I', Block.dirt});
The part with the quotes is where you have your actual recipe. The first set is the top row, then middle row, then bottom row. If need help with this, look at all the others and see what you did wrong! Save this file. We are almost done our mod. If you recompiled and reobfuscated now, you would get your block, but there would be no name when you put your mouse over it. To fix this, go to your minecraft.jar (not in mcp) and open your "lang" file. Look for en_US.lang and open it with any text editor. At the bottom of all the "Tile..." type:
tile.awesome.name=Awesome!
Save that and you're DONE! Recompile and reobfuscate and place the new classes in minecraft.jar. Thanks for reading and enjoy your new Block! (Don't forget to delete META-INF and put your new terrain.png file in minecraft.jar!). Comment if you have errors. I would gladly fix them!
///ADDED BLOCKS!////
public static final awesome = (new BlockAwesome(146)).setHardness(1.0F).setResistance(3000.0F).setBlockName("BlockAwesome").setStepSound(soundStoneFootstep);
just like to add that it aint a good idea to mod the core mincraft files, theres ways round doing that and i for one really dont like to mod or add to them files
just saying
All of this editing would be done in MCP. You are not editing directly from minecraft.jar. The en_US.land is an exception, but it's not really "Code." It is more like a properties file. I would however say that you shouldn't edit terrain.png directly from minecraft.jar.
That doesn't seems right, were it is getting the method from? pretty sure it needs to be like this:
.setStepSound(Block.soundStoneFootstep);
Be sure to double check your stuff before posting tutorials.
What I wrote is correct. Because you are typing IN the block.java file, you don't need to reference it like an external variable. Please make sure you have a for sure error before posting it :)!
It doesn't seem like you know about the word 'incompatibility'. When 'proper' modders "create" mods for Minecraft, they use MinecraftForge. THE best API for Minecraft.
It doesn't seem like you know about the word 'incompatibility'. When 'proper' modders "create" mods for Minecraft, they use MinecraftForge. THE best API for Minecraft.
Did I say that this was for advanced modders? NO! This is for BEGINNERS! Maybe I will make OTHER tutorials using MinecraftForge. Did I say this was going to be COMPLICATED? NO! So how about you shut up and read the first paragraph and title BEFORE you start uploading comments!
It doesn't seem like you know about the word 'incompatibility'. When 'proper' modders "create" mods for Minecraft, they use MinecraftForge. THE best API for Minecraft.
Was there a reason to be rude? Who cares that he doesn't use forge. Get out. You arent wanted here.
Dude there is a much simpler way to do this. Just copy the Block.Dirt file and rename it and change what needs to be changed the copy the declaration and edit hardness and all of that.
Was there a reason to be rude? Who cares that he doesn't use forge. Get out. You arent wanted here.
Dude there is a much simpler way to do this. Just copy the Block.Dirt file and rename it and change what needs to be changed the copy the declaration and edit hardness and all of that.
It is probably a better learning experience to type it out, but that works too.
I will assume you have already downloaded MCP, but if you don't, get it because you will need it. You will need to locate the following files (in your /src/minecraft.../src):
Block.java
CraftingManager.java
You will need to make the following file:
BlockAwesome.java (make sure it starts with Block ... .java)
In your BlockAwesome file, type the following at the top:
The package is declaring the package the file is in. If you are using eclipse, you will get LOTS of errors! Don't worry! It's right! We will need random later on in the code. Below that, type:
We are now declaring the class and that it shares variables with Block.java. Then we make the constructor for the class. Next, we need to get in to the good suff! Type:
Now that's quite a bit of code. The good news is that is the most we will be typing in one file The obvious values you can change (like how many items are dropped when you mine the block) but try to keep most of it the same. The comment saying "Change this!" you should change.
Notice I put "x" in the blockIndexInTexture() thing. That is because if you open your terrain.png, there are different square id's. All the purple ones are vacant. If you count left to right from 0 at the top, you will get the id's. For example, gravel is 0. Stone is 1. Dirt is 2. So on and so forth. When you get to the end of a line, keep counting up until you get to a purple square. Colour that square to your liking and type the square id where "x" is. Save the terrain.png file.
Save BlockAwesome.java in your src file. Now, open up the Block.java file. This is a big file so read carefully. At the bottom of all the "public static final blabla = ..." type the following:
Feel free to play with these numbers to find the right one. The "146" near the beginning is the item id. If you have no extra mods installed and you are running minecraft 1.4.7, that should be the next id. (1.5 users, use 200 because of the new blocks added!(i.e. redstone blocks)) You can always choose something like 200 to be safe if you get errors. The only other footsteps I would use are "soundWoodFootstep", and "soundGrassFootstep". Refer to the top of Block.java to see all the options. Now, save that file and open CraftingManager.java. Scroll to the bottom of all the "this.addRecipe(..." and type
The part with the quotes is where you have your actual recipe. The first set is the top row, then middle row, then bottom row. If need help with this, look at all the others and see what you did wrong! Save this file. We are almost done our mod. If you recompiled and reobfuscated now, you would get your block, but there would be no name when you put your mouse over it. To fix this, go to your minecraft.jar (not in mcp) and open your "lang" file. Look for en_US.lang and open it with any text editor. At the bottom of all the "Tile..." type:
tile.awesome.name=Awesome!
Save that and you're DONE! Recompile and reobfuscate and place the new classes in minecraft.jar. Thanks for reading and enjoy your new Block! (Don't forget to delete META-INF and put your new terrain.png file in minecraft.jar!). Comment if you have errors. I would gladly fix them!
Hmmm....
That doesn't seems right, were it is getting the method from? pretty sure it needs to be like this:
Be sure to double check your stuff before posting tutorials.
this is a tutorial without modloader or forge so that this block of code is inside the Block.java so the Block. is not required
Not sure why I though he was using ModLoader.
My bad. XD
All of this editing would be done in MCP. You are not editing directly from minecraft.jar. The en_US.land is an exception, but it's not really "Code." It is more like a properties file. I would however say that you shouldn't edit terrain.png directly from minecraft.jar.
What I wrote is correct. Because you are typing IN the block.java file, you don't need to reference it like an external variable. Please make sure you have a for sure error before posting it :)!
Did I say that this was for advanced modders? NO! This is for BEGINNERS! Maybe I will make OTHER tutorials using MinecraftForge. Did I say this was going to be COMPLICATED? NO! So how about you shut up and read the first paragraph and title BEFORE you start uploading comments!
Was there a reason to be rude? Who cares that he doesn't use forge. Get out. You arent wanted here.
Dude there is a much simpler way to do this. Just copy the Block.Dirt file and rename it and change what needs to be changed the copy the declaration and edit hardness and all of that.
Click the dragon. You know you want too.
It is probably a better learning experience to type it out, but that works too.