FANDOM


Introduction Edit

Welcome to the next steps of setting up your Minecraft Environment for modding! This time, we are going to learn about a couple of different things...

  • Opening Eclipse
  • Setting up the files
  • Proxies
  • Instance
  • Logger

Without any more interruptions, here we go!

Mod Files Edit

Opening Eclipse Edit

EclipseOpen

Possibly one of the most simple steps is opening eclipse. When you open it, you will see something like the image to the right. What you need to do is change that to wherever your Forge file is. For us, our forge file is called Workspace, so what we would put in is E:\Desktop\Tutorial Mod\Workspace\eclipse. It's very important to add the \eclipse to the end of wherever your forge is, because that is the workspace we will be using. Once eclipse

EclipseFirsttime

fully opens, it should look something like the image to the left. Now that you have your workspace all ready, before we get started delete com.example.examplemod. We will not be using that file for this tutorial. Now we are all ready to start setting up the necessary files.

Setting up the files Edit

Now that you have eclipse open, right click on src/main/java. Press NEW, press PACKAGE, and in the Name area you are going to want to type the below...

com.<YOUR USERNAME>.<MODNAME>

You are not allowed to have spaces in any of it, so for me my thing will be named...

com.fire.tutorialmod

Now, once it's created, right click on your new package. Press NEW, press CLASS. Here we are going to name it "MainRegistry". Press finish, and we have our class all set up! At the moment, it should look like this...

Code1

Now, we're going to create another class under com.fire.tutorialmod, called Strings. In the strings class we are going to add three lines....

public static final String MODID = "<YOUR MOD NAME>";

This line will be the ID of our mod. It cannot have any spaces or captial letters. What I am going to type is going to be public static final String MODID = "tutorialmod";

public static final String NAME = "<YOUR MOD NAME>";

This line will be the NAME of our mod. It can have spaces and captial letters. What I am going to type is going to be public static final String NAME = "Tutorial Mod";

public static final String VERSION = "<YOUR MOD VERSION>";

This is going to be the version of our mod. It works the same as the NAME string we just made. My version will be public static final String VERSION = "0.0.1 Beta";

Now that our strings area is finished, it should look a bit something like this...

Code2

Go ahead and press CTRL + S, to save the file, and go back to your Main Registry. Right above the line public class MainRegistry {, we are going to type this...

@Mod(modid = Strings.MODID, name = Strings.NAME, version = Strings.VERSION)

Press CTRL + SHIFT + O to import everything, or you can hover over @Mod and press the button that says Import 'Mod' (net.minecraftforge.fml.common.Mod).

Now we are also going to be adding three things to the MainRegistry class. Within the bracks, type the three things below...

Code3-0

Now import everything to get rid of all of those errors. Once again you can hover over them and import them, or you can press CTRL + SHIFT + O to import everything, and we have finished the main files that we are going to need.

Proxies Edit

Now we are on to creating Proxies. Before we start to do anything, go to the top of your package explorer and look for a button that is an arrow pointing down. In there, hover over package presentation and press Hierarchical, as this will make it a lot easier to understand folder and things like that.

Our first step is going to be creating a new folder. So, right click on com.fire.tutorialmod or whatever your modname was. Press NEW, press FOLDER. In the folder name area, type "Proxies", and press Finish or Enter. Now, right click on Proxies. Press NEW, press CLASS. You are going to name this class "CommonProxy". In the brackets you are going to type the below...

9

Press CTRL + S to save the file, and then right click on Proxies again. Press NEW, press CLASS. This time we are going to name it "ClientProxy". In between the word ClientProxy and the opening bracket ({), type extends CommonProxy. Then, inside the brackets, type the same thing as we did in Common Proxy, public void registerRenderInfo(){}. Press CTRL + S, and open Strings again. In here we are going to type two things...

public static final String COMMONPROXY = "";

and

public static final String CLIENTPROXY = "";

Once you have typed those two things, we must let the MainRegistry know what these strings mean. Inside of the COMMONPROXY string, we are going to type public static final String COMMONPROXY = "com.fire.tutorialmod.Proxies.CommonProxy";, and instead of typing com.fire.tutorialmod you are going to type whatever you made your com. It could be com.username.butts or com.myusername.mymodname, it doesn't really matter, as long as it is the same as what you have under src/main/java. Now we are going to type it again, but this time for the CLIENTPROXY class. So this time ours will be public static final String CLIENTPROXY = "com.fire.tutorialmod.Proxies.ClientProxy";. So, now our strings area should look something like this...

Code5

Press CTRL + S to save, and go back to your MainRegistry. Right above the line public void PreLoad(), we are going to type this...

@SidedProxy(clientSide = Strings.CLIENTPROXY, serverSide = Strings.COMMONPROXY)

And don't worry about the errors, because those will be fixed with the next two lines,

public static CommonProxy proxy;
public static ClientProxy cproxy;

So now yours should look something like this,

Code6

Now there is one last thing that we need to do. Inside of the public void Load() event, type this line,

proxy.registerRenderInfo();

Once you have done all this, press CTRL + SHIFT + O to import everything, press CTRL + S to save, and you have finished your proxies!

Instance Edit

Probably a really easy thing to do but is very required, is to create the 'instance' of your MainRegistry. Go into your MainRegistry, and right below all the SidedProxy stuff we did, type this...

@Instance(Strings.MODID)

This line will tell Forge that there is a new instance being created, but it will give errors until we do this next line,

public static MainRegistry instance;

Where you replace MainRegistry with whatever you called your main class. My line looks like this: public static MainRegistry instance;. Press CTRL + S to save, press CTRL + SHIFT + O to import everything, and you have finished your instance!

Logger Edit

Another thing you will need to do very quickly is the Logger. To get started, right below your new Instance line, you are going to type this...

public static Logger logger;

Now this will give you an error, but something to know is DO NOT PRESS CTRL + SHIFT + O to import this object! You will have to hover over it and import it manually. Look for the one that says Import 'Logger' (org.apache.logging.log4j), or else you will import the WRONG logger!

Now we will go inside of your MainRegistry, and inside of your PreLoad function, you will type this line,

logger = event.getModLog();

You have finished your logger!

Finishing Up Edit

Phew! That was a lot of stuff we did in this session! Let's review what we did! We made our Strings and MainRegistry class, and we have also made our Proxies. We learned about the SidedProxy, Instance, and Logger. We also learned about the EventHandler, and what they do. If you would like to review everything that we did, you can find the whole thing on my github, by clicking this link. Click here to return back to the home page.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.