Tutorial 2. Base File

So, now we can make the fun begin!

Make sure you watched Tutorial 1


Code is on Github

NOTE: I cant write pr0xies right, because of the webhost. Note that pr0xies are not written with a 0, but with an o!

To start off, in tutorial 1, I made you think of a name. A name which we would use a lot.
That name is now gonna be referenced at as your mod-id.
So. In intelliJ, create a new package, inside the Java folder, with your mod-id as name.
Inside the package, create a new java class, with your mod-id as name.
This java file, will be the main class of our mod!

So, Lets get started!!

This is the file I start with, when i create a new class.

Anything grey astrixes, is for learning purposes, or documentation. In this case, the info is for documentation.


So, in order for forge to load our mod, we need to tell it, that we have a new ModFile. We do that, by placing the @Mod notation in our file, before we declare the class.
The @Mod takes 3 params. Modid, Modname, and Modversion.
To keep things saved properly, I store all my global references in a class called References.
This class, will be located in the package lib. Therefor, i click on mcmodtutorial package, and select new package. I name it lib. In that package, i create a class called References.

fd4185ffb2a54b6aa3077287050ffce9

So, in References, i create 3 final variables. These vars will be the same for the entire mod.

 

Now we can use those references in our main mod file

So, now atleast forge knows we have a mod.
But we cant load anything yet. In order to have anything loaded at all, we need to call 3 events. FMLPre- , -Post- and FMLInitializationEvent.
This requires the annotation EventHandler

 

The preInit loads things like blocks, items, loggers, and config handlers.
The init loads stuff like renderers, Gui’s, etc.
The post init loads add-ons.

One more thing we need to add. Its the hardest part to understand.
In Minecraft, you have 2 sides. Client and Server.
Client handles everything that you SEE on your screen. So textures, models etc etc.
Server handels all calculations. So rigstering blocks, events etc etc.
The pr0xies are there, to seperate client and server.
Everythign you do in the ClientPr0xy, will happen on the client.
Everything you do in the CommonPr0xy, will happen on the server.

Now, to add those 2 pr0xies, i make a new package called core, and inside that package another package called pr0xy.

f250a149a62a223c4f3f9bc603de6ca9

Add 2 files, CommonPr0xy and ClientPr0xy
Make ClientPr0xy extend CommonPr0xy
Now, one more thing we have to do to make minecraft run, is register the pr0xies.
We do that by telling forge, which files are pr0xy files.
Therefor, in References, I declare where they are.
The localtion is [modid]+.core.pr0xy.+[classname].
In my case my location is:

 

Now, in your main class, tell forge where our pr0xies are.
The way to do that is:

Now, when you run, you can see that your mod work!

Back to List
Next tutorial


4 Responses to Tutorial 2. Base File

  1. Jared says:

    The “Back to List” and “Next Tutorial” links send people to your old website.

  2. Stephanie says:

    Nowhere in here do you tell anyone to extend the Commonproxy in Clientproxy. This will cause run errors. Just sayin.

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=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">