Modding: Custom textures part 2

You will need the files as shown in part 1 of the custom textures tutorial.
After you have finished part 1 of this tutorial you will have several errors. This is because you tell java to take a look at the class CommonProxyTutorial, but it isn’t there yet. This is what the file should look like.


package Tutorial.common;

public class CommonProxyTutorial
{
    public void registerRenderThings()
    {
        
    }
}


This file goes into your common package.
As you can see this file is empty. This is because there are no renders on server side. Render is only done client side, because only the client can see the things. The server can’t see anything so it doesn’t need renders.

Now for the ClientProxyTutorial.


package Tutorial.client;

import Tutorial.common.CommonProxyTutorial;
import net.minecraftforge.client.MinecraftForgeClient;

public class ClientProxyTutorial extends CommonProxyTutorial
{
    @Override
    public void registerRenderThings()
    {
    MinecraftForgeClient.preloadTexture(“/TutTextures.png”);
    }
}


There are several special things in the class. It extends CommonProxyTutorial. This means that it has everything from that file in it.
Another thing is the @Override. This means that it will look at the class that it is extending and checks if the method under it is also in that one. If it isn’t it will give an error.
MinecraftForgeClient.preloadTexture(“/TutTextures.png”); the file location of the textures is between the brackets in a string.
In the way I have set it up right now you will have to add the texture outside of all the folders. If you want to load pictures for inside of your Eclipse you need to place this file in the minecraft.jar. The correct minecraft.jar to put it in can be found in the jars folder from the eclipse map.
For the texture to work properly you have to create a 256×256 texture sheet with 16×16 sqaures. For bigger mods it is suggested to have 2 serparate sprite sheets. 1 for items and 1 for blocks, but for this tutorial you don’t really need that. A useful file can be this one

This is a 256×256 picture with 16×16 squares. The squares end in the right bottom of the pink so not the 2 purple lines on the bottom and right of the texture.
The texture on the top left is 0 and the one to the right is number 1. All the way to texture 15 on the top right. The one under 0 is 16 and the one on the bottom right is 255.

Now if you want to get textures from this sprite sheet on your blocks and/or items you have to add these lines to your Block or Item file:


public String getTextureFile()
    {
            return “/TutTextures.png”;
    }


A complete item or block file should now look like this.


package Tutorial.common;

import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Item;

public class ItemTutorial extends Item
{
    public ItemTutorial(int i)
    {
        super(i);
        maxStackSize = 64;
        this.setTabToDisplayOn(CreativeTabs.tabMaterials);
    }
    
    public String getTextureFile()
    {
            return “/TutTextures.png”;
    }
}


This should make the item or block have a texture from the new sprite sheet.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">