Step 5: Creating a Texture For Your Block!

In this part of the tutorial, I'll show you how to create a texture for your block. First you're going to need the default sprite sheets. A sprite sheet is basically a series of separate images that a game can load as it pleases. In minecraft, it is programmed to take the correct sprite from the terrain.png and items.png files. Basically what you're doing with the help of Forge, is making your own terrain.png sprite sheet and items.png sprite sheet for your mod to link to your block. Here is a link to two blank sprite sheets ready for you to use. One for items and the other for blocks. Download Default Sprite Sheets You can open that file up in the editor of your choice, either Photoshop (paid) or GIMP (free). You'll see exactly 256 purple squares, you can now edit them as you please! Keep in mind that your textures will be 16x16 and arranged like so: Are you wondering why it starts at zero? Well remember when we put "(blockID, 0)" in our block code before? Well that 0 represents which texture it will use from that file. If I kept it as 0 and loaded the sprite sheet above, I'd have a blue block with a zero in the middle. If I changed the 0 to a 1 in the code, the block texture would be red with a big one. Once you're done and your block texture(s) are looking good, you can save that to an accessible place for now. Also, make sure you save it as a .png file or minecraft won't load it correctly. Now remember the getTextureFile() method that we used before? Well whatever file path you used there is where Forge is looking for the texture for that block, so make a series of folders so that it matches. Now open up YourMCPFolder/jars/bin/minecraft.jar and drag that series of folders with your sprite sheet inside. Whatever you returned in getTextureFile() should be the exact same file path as your sprite sheet's location inside minecraft.jar. That may have been confusing, so lets see if you got it. One more thing before we run the client. We should let Forge preload the texture: MinecraftForgeClient.preloadTexture("/New/Untitled-1.png"); Just make sure you put the same file path in this method invoke as what you returned in your getTextureFile() method. The reason why you are using Minecraft Forge Client instead of just the regular forge class is that textures are only handled client-side, and you wouldn't have to use this on a server mod. Now you can run the file and see if that worked. If you returned the right file path in getTextureFile() and your image is set up correctly, your block should now look like the texture you designed. Hooray!

Previous                 Back to Tutorials Index                 Next
Minecraft and Forge are always changing, found something wrong with this tutorial?

external links