In this tutorial I will show you how to add custom textures to your block. All of the code for this tutorial is done in the Block file. This is the file I will start with.
The first thing you will have to do before you can add the texture to the block is to actually make the texture and make sure it is saved correctly etc.
To do this you will have to make a 16×16 sprite for the Block. I’m not going into detail about this, because I’m no artist. However, I use GIMP to make the textures I use.
The next part is saving the file. I know much more about that, so this is what you will have to do. For a block you need to make sure that the name for the file is your unlocalized block name.png.
Then there is also the part where you need to make sure that it is in the right folder. In the newest versions of Forge for 1.5.1 Forge will load the images for you. You don’t have to add any code for that like you used to in earlier versions. However, because this is automated you also have to follow a couple of rules for the folder structure where you will have to save the images. This structure goes like this.
If you follow these rules you should be able to assign a texture to your block quite easily.
Now to get those textures to load in MCP you will have to open the forge folder where you have mcp installed in. Then enter the mcp folder and then the jars folder in there. When you are there you should be able to find the Minecraft.jar. In here you will have to paste the complete folder structure.
When you have done that your textures will be loaded in for you by Forge. The next part is to actually use them in your blocks. To do this you will have to add this one simple method.
publicvoid registerIcons(IconRegister par1IconRegister)
The only thing you have to change in here is Tutorial into whatever your mod file name is. Then your textures should load just fine in the game.
The whole file should now look like this.
This method simply sets the blockIcon which is the Icon used to render the block to an Image located in the folder structure you made earlier. par1IconRegister.registerIcon is the method that loads this image.
In the next Block tutorials there will be more customization for the blocks.