Minecraft Blogs / Tutorial

How to make a Minecraft Mod / Ep.4 Creating Proxies / Modding Tutorial Series

  • 902 views, 2 today
  • 4
  • 1
  • 2
TeamJaval's Avatar TeamJaval
Level 59 : Grandmaster Programmer
113
Hello and welcome back the the 4th "How to make a Minecraft Mod" tutorials by TeamJaval.

In this tutorial we will be looking at "Creating Proxies".
Now before we get into any coding, let me explain what proxies are.

In Minecraft's case, proxies are classes that will do different things depending on whether it is on a client or a server.

Index Tutorial: Click Here

undefined

After the last tutorial you should have created a basic mod file that doesn't do anything.

First you must right click on your package (e.g. "com.gegy1000.tutorial")
and click "New", "Class".
It should open a window looking something like this:

Spoiler
undefined



Name this class "CommonProxy".
Then click "Finish".



Now it will display code similar to this:

Spoiler
undefined

Now under the "public class CommonProxy {" line, put in this code (method):

Spoiler
public void init()
{
   
}

Now you must right click on your package (e.g. "com.gegy1000.tutorial")
and click "New", "Class".
It should open a window looking something like this:

Spoiler
undefined


Name this class "ClientProxy".
Then click "Finish".

Replace the "public class ClientProxy { ", line with:

Spoiler
public class ClientProxy extends CommonProxy {

Now your client proxy "extends" CommonProxy, which means it is a type of CommonProxy.

Now, underneath the "public class ClientProxy extends CommonProxy {" line put this code (method):

Spoiler
public void init()
{
   super.init();
}


The "super.init();" line basically calls the "init" method in the CommonProxy, as it "extends" CommonProxy.

undefined


Now go back into your main mod class. (e.g. "TutorialMod")

And above the "public void load(FMLPreInitializationEvent event)" line (method) put in this code:

Spoiler
@SidedProxy(clientSide = "com.yourusername.yourmodname.ClientProxy", serverSide = "com.yourusername.yourmodname.CommonProxy")
public static CommonProxy proxy;

Press Ctrl + Shift + O and it will fix that error.
Now inside your "load(FMLPreInitializationEvent event
)" put this code:

Spoiler
proxy.init();

Now your mod class should look like this:

Spoiler
undefined

undefined

That is all for this tutorial and I will see you all in the next tutorial!

To create these tutorials for you is quite a challenge, If 
you'd like to see more tutorials and more sections covered then please 
donate to our team as generously as you can. Every bit of it helps and supports us even more.


undefined

Donators will be able to get private lessons from myself or anyone else from TeamJavalIncluding their name posted on numerous blogs as a big thank you.

undefined

undefined

Tags

Create an account or sign in to comment.

1
06/02/2014 2:22 pm
Level 18 : Journeyman Mage
ZachDevv
ZachDevv's Avatar
I'm just interseted, what exactly can you do with a proxy?
1
06/03/2014 8:49 am
Level 59 : Grandmaster Programmer
TeamJaval
TeamJaval's Avatar
In Minecraft's case, proxies are classes that will do different things depending on whether it is on a client or a server.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome