Modding 1.4.7: Proxy’s

In this tutorial I will show you how to add a Proxy’s to your mod. You will need them if you want to do any rendering in your mod. So if you want custom textures on items, blocks, mobs or other things you will need this. A big part of the code is done in the mod file. This is the file I will start with.


package tutorial;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = “Tutorial_Tutorialmod”, name = “Tutorial”, version = “1.0”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial 
{
@Init
public void load(FMLInitializationEvent event)
{

}
}


The first line of code you will have to add to your mod file is this one.


@SidedProxy(clientSide = “tutorial.ClientProxyTutorial”, serverSide = “tutorial.CommonProxyTutorial”)


This line of code has to be between the start of the class and the @Init. It doesn’t really matter if there is anything above or below it, but it has to be between those 2 places.
The code between the first pair of quotation marks has to be the package you are in and after that you put the ClientProxyModName. The second pair needs to have the exact same, but with the CommonProxy. So it should be the package.CommonProxyModName.
The next line of code has to be below the @SidedProxy line.


public static CommonProxyTutorial proxy;


You need to copy this line exactly and the only thing that you should change is Tutorial into your mod name. You will get an error under the CommonProxy, because you haven’t made that file yet.
There is one more line of code that you have to add to this file. It has to be the very first line of code inside of your load method. If it isn’t the first your textures will break so make sure you get the location right.


proxy.registerRenderThings();


registerRenderThings() is a method that you will have to add to the Common and Client Proxy.

This is all the code you need inside of your mod file. Now you should create your CommonProxy file. Do this by hovering your mouse over CommonProxy and clicking create Class. You should make the file look like this.


package tutorial;

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


There will never really be anything in here, because all of the rendering is done client side.
Next up is the ClientProxy. Right click your mod package and click create new Class. Give the class exactly the same name as the one you have in the @SidedProxy line. The file should look like this.


package tutorial;

import tutorial.CommonProxyTutorial;

public class ClientProxyTutorial extends CommonProxyTutorial
{
@Override
    public void registerRenderThings()
    {
   
    }
}


You need to make sure that it extends the CommonProxy from your mod. In this file you will be adding all the code that is used for rendering.

You can download the source code for this tutorial here.

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="">