The Ultimate Guide to Minecraft Modding with Java in 2019 (1.12)

 

In this Minecraft Modding tutorial, we will be providing you with step by step instructions on how to get started with Minecraft modding while creating an awesome custom Sword that you’ll get to play in the game.

 

We’ll be using Minecraft 1.12.2 as it is the most stable version for Minecraft modding at the time of writing.

 

You’ll need a PC or Mac computer for this tutorial, as Chromebooks or mobile devices will not run the software properly.

 

At CodaKid we have taught over 30,000 students Minecraft coding, and have won numerous industry awards for online courses including a Parents’ Choice Gold Award and CODiE Finalist for Best Coding and Computational Thinking Solution.

 

While we teach coding for kids, this guide can be used by teachers, parents, or anyone with an interest in creating a custom Sword Mod for Minecraft.

 

We hope that you enjoy this free step by step guide to covering one of the first courses we teach in our Minecraft Modding series.

 

We’ll cover the very basics of what you’ll need to start Minecraft modding, and you will learn how to use Java, one of the most popular programming languages in the world.

 

We’ll also teach you how to download and use the Eclipse IDE, a text editor used by professional  developers at companies such as Facebook, Google, and Amazon.

 

We will continue to update this blog in the coming months and transition to more recent versions of Minecraft as they become stable for mod creation.

 

Minecraft modding

 

Step 1: Set up your Text Editor

 

Before we begin Minecraft modding, we’ll need to download some tools.

 

First we are going to download the Eclipse IDE, one of the most popular professional text editors for Java in the world.

 

To download the installer CLICK HERE and look for the Get Eclipse IDE 2019-03 Download area that looks like this:

 

Minecraft Modding - Eclipse link

 

Click the Download 64 bit button and the next page will appear where you can download. Click the Download button shown and wait for the Eclipse file to finish downloading.

 

Minecraft modding

 

Find the executable file in your download file and open it to launch the eclipse downloader.

 

 

When the launcher opens, select the Eclipse IDE for Java Developers.

 

Minecraft modding - Eclipse instructions

 

Then on the next window, keep the default install location and then click the INSTALL button.

 

 

The next window will appear and you need to accept the agreement for Eclipse. 

 

 

Then the next window will prompt to make sure you accept the license Agreement.

 

Checkmark the Remember accepted licenses and Accept the Eclipse Foundation Software User Agreement.

 

 

Once this is accepted, you are almost done with the install.

 

Just accept the Eclipse Foundation certificate as shown in the image below.

 

 

Once this is done, Eclipse will be downloaded and ready for when we need to use it to write our code.

 

The next step is going to be installing the Java Developer Kit which will let our code work properly with Minecraft.

 

Step 2: Set up Java Developer Kit (JDK)

 

What we need to do next is download the Java Developer Kit that will let our Minecraft Modding in Eclipse work correctly.

 

You can find the download link HERE for JDK 8. The version of JDK you need is JDK8 to work properly with Minecraft Modding.

 

When you are at the download page, find the correct product version for your computer, accept the license Agreement and then select the download link.

 

The version I am downloading that is shown in the picture is for windows x64.

 

Minecraft modding Java

 

The next page will prompt you to sign into Oracle.

 

You do need an Oracle account to download JDK so select Create Account.

 

 

On the next page fill out all the required fields needed to create an account and then click the Create Account button.

 

 

You will then see a notification to verify your email address.

 

Make sure to verify the email address and the account is ready to download the version.

 

 

Now go back to the download page HERE and download the correct JDK version.

 

Then sign in to your account this time.

 

 

Now the download of the executable file will start.

 

Once this is finished, find the file in your downloads folder and run the executable to install JDK.

 

 

Run through the pop up window guide to install JDK for your computer and click on each next keeping the default settings until JDK finishes installing.

 

Minecraft modding Java installation

 

Let Java run its installation until it is finished.

 

 

Now that JDK is finished, we can set up and install forge in the next step.

 

Step 3: Set up Forge

 

Next you will need to download the 1.12.2 version Minecraft Forge, as this will allow us to mod Minecraft 1.12.

 

You can find the download link HERE, and just follow the instructions we’ve laid out below.

 

On this page you should see the latest and recommended version for Forge. Download the Recommended version Mdk (Mod Development Kit) file for 1.12.2 as shown.

 

Minecraft modding Forge

 

Once this is downloaded, find it in your downloads folder, right click on the zipped up folder and then select Extract All…

 

Minecraft modding Forge 1.12

 

On the next window click the Extract button.

 

 

This is going to be our project folder. So we want to make a copy and rename and move it to a new location on our computer.

 

We recommend putting a copy in your Documents folder or on your Desktop.

 

Right click and copy and paste the unzipped forge folder in a location you want and make sure to rename it to something descriptive.

 

In this example we will be naming it ForgePractice.

 

 

There is one important file that may not copy over from the old folder.

 

Go inside the folder from the download location and copy the build.gradle file in it.

 

 

Once this is copied, return to the area we pasted the new folder into and now paste in the build.gradle into this.

 

 

We have the Forge folder set up and are ready to create our new project!

 

Step 4: Install Pinta

 

Next we want to install the Pinta program we will use to change the look of our Sword Texture.

 

Go the the link HERE to get to the Pinta download page.

 

On this page click the download link for the OS you are on Mac or Windows.

 

Minecraft modding Pinta

 

Once you have the installer downloaded, open it up in your downloads folder and run the installer.

 

Fully install the application and accepting any agreements along the way. 

 

 

Close out of the installation when it is finished.

 

 

Now we have the programs we need to create our mod.

 

The next step is creating our project.

 

Step 5: Create Your Project

 

Make sure you have the new Forge folder we set up earlier open.

 

Once inside, hold the shift button and right click in and open space in the folder.

 

In the options that show up in the pop up window, select “Open command window here” or “Open PowerShell window here.”

 

 

Inside of this new window we will be typing in a few code commands to make sure we are setup to work in Eclipse.

 

Type into the command window “.\gradlew setupDecompWorkspace” and then press enter to run the command.

 

 

Once this runs, you should see something similar to what is shown.

 

Make sure it has a “BUILD SUCCESSFUL” message.

 

If you do not have this, make sure you copied the correct file over including the build.gradle.

 

 

Since we are programming in Eclipse we need to run a command that will setup our project file to be usable inside of the Eclipse Editor.

 

Enter in a second command “.\gradlew eclipse” and then press enter.

 

 

Once this runs you should see something similar to what is shown.

 

Again make sure you see “BUILD SUCCESSFUL” as a message.

 

If you do not have this, double check to make sure you entered in the command correctly.

 

 

Now we need to open eclipse and then navigate to the workspace folder.

 

Search for Eclipse Java and open the Eclipse program we downloaded earlier.

 

Minecraft modding Eclipse setup

 

When this opens you will be prompted to pick a Workspace.

 

Click the Browse… button and in the pop up window search for the eclipse folder inside our Forge workspace we have been setting up.

 

Click “Select Folder” to choose this eclipse folder.

 

 

Once this is selected, make sure the path is correct and then click launch.

 

 

Eclipse will now open up and you will have the project opened inside of it.

 

We are now ready to start Creating a Mod and learning Java.

 

Step 6: Make Your Own Mod – A Custom Sword!

 

Finally our Minecraft modding tutorial begins!

 

Once Eclipse is loaded up and opened, we are ready to start typing in java code.

 

Let’s open an example Mod java file that is provided for us that we will be starting from.

 

On the left side of the window, open the MDKExample folder by clicking the arrow next to the name.

 

Now open the “src/main/java” folder and then open the “com.example.examplemod” file and inside you will find ExampleMod.java.

 

Double click this to open up this java code file.

 

Minecraft modding Java code

 

The first thing we want to do in ExampleMod is find the lines that define our MODID and NAME.

 

Change the MODID to sword making sure it is all lower case.

 

This is the unique ID for our mod we will make.

 

The NAME is the name of the mod as it will appear in Minecraft.

 

Name this what you prefer.

 

Make sure these are inside quotation marks because they are String variables.

 

Strings are variables that are words or characters.

 

(We will be covering variables in a little bit).

 

 

The next thing we want to do is open the mcmod.info file to edit our modid here as well as the name and description.

 

Go to the src/main/resources folder and open it.

 

Open mcmod.info here and change the modid to “sword” and change the name, description, author, and credits to whatever you like.

 

Make sure these are inside quotation marks again as they are Strings that will be read by the code.

 

 

The next step is to create variables for our ToolMaterial and sword.

 

Place these lines beneath the private static Logger logger line.

 

Variables are helpful in code because they act as boxes with names that store information inside of them we can use easily.

 

What we are doing here is we are creating to variables myToolMaterial and mySword.

 

The types of variables are the ToolMaterial and Item.

 

 

Once we have the variables created, we need to import the code files that define what a ToolMaterial and an Item do.

 

We can do this by mousing over the red error lines underneath ToolMaterial and Item.

 

In the dropdown list that appears, import the code shown.

 

Start with the ToolMaterial as shown below.

 

 

Next import the Item as shown below.

 

 

Now because we are making a customized sword in Minecraft, we need to define what the material is for the sword tool is we will be using.

 

This is where we define our custom tool material variable we created.

 

Go into the preInit function shown and inside below the logger line, write out  the myToolMaterial line shown.

 

 

What that line does is it fills in our myToolMaterial variable with information on what the material does for tools we apply it on.

 

We will be applying this tool material to our sword.  But let’s actually fill in the name, harvest level, damage etc.

 

Change out the name to a String variable that is the material name.

 

You can name this whatever you like.

 

The harvest level indicates which minerals it can get resources from.

 

If we applied this material to a pickaxe, this is where we would define if it can get diamonds from Diamond Ore.

 

Putting this at 4 lets it mine whatever we want it to.

 

maxUses is how many times we can use it before it breaks, the efficiency is applied for harvesting tools for how quickly it will mine or harvest a block.

 

The damage is how much damage it will do when you hit an entity with it.

 

The enchantability is related to how easy it is to enchant.

 

 

After this material line add in a definition for what our sword is.

 

This line defines the sword as a new class called CustomSword. 

 

 

We need to create this new class and we do that by mousing over the red error line and clicking

 

Create class ‘CustomSword’. 

 

 

A new window will open up, keep these values at the default settings and just click Finish.

 

 

This will create a new Java code file CustomSword and automatically open it up for it.

 

This is a Class which is code that defines what the CustomSword is and how it behaves.

 

What is convenient for us is we can make sure to change the import and public class lines to say “ItemSword” instead of “Item” and this defines our class with all of the information that already exists for swords in Minecraft.

 

This lets us swing it and damage creatures as well as pick it up and drop it and any small interaction a sword will have in the code.

 

 

Now what we need to do is add a constructor for our class.

 

This defines how the sword is made. Think of it as how blueprints are used when creating buildings.

 

We are defining specific rules for how our sword will be created.

 

 

Once the constructor is added in, change it to remove the Material reference in the parentheses and then fill in our ExampleMod.myToolMaterial.

 

After these changes are made, we need to set the RegistryName, UnlocalizedName, and CreativeTab for our sword.

 

The Registry and Unlocalized names of our sword need to specifically be “my_sword” because these are the names our code uses to identify our sword and link our texture to it.

 

The CreativeTab can be changed to the tab you want the sword to appear in.

 

We chose COMBAT but there is a list that will appear where you can choose the tab you want your sword to be in.

 

 

Once this is done, our class is ready to go.

 

We need to create a new java class that we will use to register our sword into Minecraft.

 

Go to the Package Explorer on the left side of Eclipse and right click on the com.example.examplemod package and create a new Class (as shown below).

 

 

This will open the class window we saw earlier.

 

This time we want to name it CommonProxy and then select Finish.

 

 

Now we want to go above the public class CommonProxy line and write the @mod.EventBusSubscriber.

 

This will let the class be run during the loading of Minecraft so it can register our sword into the game.

 

 

We need to import the code for mod just like how we imported Item and ToolMaterial earlier.

 

 

Once that is imported, we need to create a new function that will run specific code to register the sword Item in Minecraft.

 

Make sure to include the ExampleMod.mySword inside the registerAll() parentheses because this tells the register function specifically to register our sword item.

 

 

Now we need to import the code that is missing from this Class.

 

We need to import SubscribeEvent, RegistryEvent, and Item.

 

Just like before, we are importing code that already exists to help us with our register code.

 

Start with SubscribeEvent as shown below.

 

Next Import RegistryEvent as shown below.

 

 

Finally, Import Item (net.minecraft.item) as shown below.

 

 

Once these imports are done, we can actually test out or “sword” except it will not look like a sword just yet.

 

In order to test out our code, make sure you are clicked inside a code window and then go up to the green play button and press it only once.

 

Make sure you press the button that is just the green button and not the ones with little icons in the corner.

 

After some time, you should see a window start opening Forge Minecraft.

 

Wait until it fully loads Minecraft to its main menu.

 

 

Once you have finished waiting, select Single Player at the main menu.

 

Minecraft modding with 1.12

 

Next, select Create New World to start setting up a Creative mode game. 

 

 

Then change the game mode to Creative and change the name, then select Create New World.

 

This will open the new world and take a bit of time to open the Minecraft world.

 

 

Once the world is opened, click the “e” button to open the Creative Tab inventory.

 

Go to the Combat tab or whatever tab you picked when we set the Creative Tab in our code.

 

Scroll to the bottom of the tab and make sure you have your sword.

 

We will be updating the look and the name but if you put it in your inventory, you will have a sword that will function as we coded it to!

 

 

Once you are done testing your purple and black block sword, let’s go back to our code to make the model and texture linked up in our code.

 

Exit out of the Minecraft window and open CommonProxy.java and add a new registerRender function inside of the CommonProxy class as outlined below.

 

This will register the model for the sword based on the item we want to register.

 

We will link this to our sword in the next couple of steps.

 

 

We now need to import more code.

 

Make sure to import ModelLoader and ModelResourceLocation.

 

Start with ModelLoader.

 

 

Next, Import ModelResourceLocation as shown below.

 

 

Now let’s render our sword!

 

Make a registerRenders function that we will register our ExampleMod.mySword variable.

 

 

Now we need to import the ModelRegistryEvent code so our models will properly render in Minecraft.

 

 

Now we need to name our sword.

 

Right click on the scr/main/resources and make a new untitled Text file inside.

 

 

Now add in a code line that will name the sword.

 

You can customize the name of your sword by changing the name to the right of the equals (=) symbol.

 

 

Now let’s save this untitled filed.

 

Go to File > Save as and a window will open asking you to select the location of the file.

 

Select the MDKExample>src>main>resources folder and change the file name to be en_us.lang and then click OK to make the file

 

 

Now we need to make our sword texture and import it into our project.

 

I have a picture of an Iron Sword in Minecraft below.

 

Go ahead and right click on it and select “Save image as…” then save the file as “my_sword.png”.

 

It is a small file because Minecraft needs a smaller image.

Once you have it saved, right click on the picture wherever it is saved on your computer and then copy it.

 

 

Once it is copied, let’s find the folder we need to paste it in.

 

Go to our project folder ForgePractice and open the src > main > resources folder and paste in the my_sword.png into here.

 

 

Now return to Eclipse and add a new Text file into the src/main/resources folder like we did before.

 

 

In this new file, type in code that will define the item sword resources.

 

 

We will now save this file as a json file so go to File > Save as and save the untitled file as my_sword.json inside of MDKExample > src > main > java > resources.

 

 

Now click the small dropdown Triangle next to Package Explorer and change the Package Presentation to Hierarchical. We do this because we will be adding in more packages to organize our code and set it up so our sword files can be properly managed by our code.

 

 

Now we need to create Packages for our resources folder.

 

Right click on this folder and add a New Package.

 

 

In the pop up window, name it assets.sword and then click Finish to create the package that will hold our other three packages.

 

 

Now right click on assets.sword package and add a New Package. 

 

 

In the pop up window name it assets.sword.lang.

 

 

Now make two more packages inside of assets.sword.

 

Name these “assets.sword.textures” and “assets.sword.lang”.

 

Once these are made, drag in the en_us.lang, my_sword.json, and my_sword.png to their respective folders as shown in the image below.

 

 

The last thing to do is customize our sword.

 

Open Pinta by searching for Pinta in our search bar and opening the Pinta program.

 

 

With Pinta opened, go to File > Open where a new window will open up.

 

 

Let’s now find our sword imagine in our project folder ForgePractice > src > main > resources > assets > sword > textures > items.

 

 

Now we need to actually paint the sword!

 

Zoom all the way in and turn anti aliasing to the off position and change brush width to 1.  All of these settings are highlighted in the image below.

 

 

Now all you need to do is paint your sword and erase or add anything you want.

 

Use the colors, the brush, and eraser tool.

 

Make sure to change your eraser anti aliasing and brush width as needed just like what we changed with the paint brush.

 

Then paint your sword to look like whatever you want! If you make a mistake you can hold down CNTL then press down on Z to undo changes. On a Mac, you’ll hold down the Command button and press down on z.

 

Minecraft modding - make a sword mod

 

Once you are done go to file > Save and make sure the new changes are saved you made.

 

 

Once this is all finished we are done with our custom Sword mod!

 

You can now test it by clicking on the Green play button just like what we did earlier!

 

Make sure everything is perfect and as you want it and then get ready to Compile your Mod and test it in Minecraft.

 

Step 7: Compile your Mod

 

Now that our code is finished, we need to compile and build our mod.

 

In order to build it, we need to go to the project folder we made and right click in an open space and select “Open Powershell window here” or “Open command window here”.

 

Minecraft modding compiling

 

Once the window is open, write in the command “./gradlew build” and press Enter to run this command. 

 

 

Then wait for the BUILD SUCCESSFUL message to display.

 

 

Once this build is finished, return to your project folder ForgePractice and open the build folder.

 

Make sure you see modid-1.0.jar.

 

This is our build mod file!

 

Now in the next step we will show you how to load your Mod onto your Minecraft game.

 

Step 8: Test your Mod!

 

Now to test our mod we need to make sure we have regular Minecraft forge downloaded.

 

What we were working in was the developer kit for Forge.

 

Now we need to access the Minecraft Forge client.

 

Return to the same Minecraft Forge download page we were at earlier.

 

Now once at this page click the regular install button shown.

 

 

Once the download finishes, open the executable file in your downloads folder.

 

 

Once this launches, you should see the Forge install window.

 

Make sure you have Install client selected, and keep the default location and then click OK. 

 

Minecraft modding with Forge

 

Make sure the Forge client installs successfully and then press OK when it is done installing.

 

 

Once Forge is done installing, we need to find our build mod file in our Eclipse project folder.

 

Open your ForgePractice folder.

 

Then open the build folder and find the libs folder in here.

 

This is where our Mod will be.

 

Right click and rename the modid-1.0.jar to what you want.

 

 

Once it is renamed, go ahead and right click and copy the new jar file.

 

 

Once the jar file is copied, we need to open the folder that has our mods in it.

 

Go to the search bar and type %appdata% and open the folder that shows up in the search.

 

 

When this folder is open, go to and open the .minecraft folder.

 

 

Inside this .minecraft folder, you should see a mods folder, open up this folder.

 

 

Next, paste in your mod we copied earlier.

 

 

Your mod is all set up to work in Minecraft!

 

Now we need to launch Minecraft and open the Forge version. Search and Open the regular Minecraft version.

 

This has to be the Java version of Minecraft.

 

The Windows 10 or a mobile version of Minecraft will not work.

 

 

Once the Minecraft Launcher is opened, go to the Launch Options tab and click Add new.

 

 

In the Add New window, Change the version to the release 1.12.2-forge version.

 

Name it Forge 1.12 or something descriptively similar.

 

 

Go back to the main Minecraft News tab and click the drop down arrow next to PLAY and select the new Forge 1.12 launch version we made.

 

Once this is selected, click PLAY to launch the Minecraft Forge version.

 

 

Once Minecraft is loaded, we need to make a new level just like what we did when testing our sword.

 

Go to Single Player and then Create New World just like we did earlier.

 

 

In the settings, change it to Creative Mode and change your World Name.

 

Once all of this is done, click the Create button and wait for the new Minecraft game to load.

 

 

Just like earlier, find your sword in the Creative Tab by clicking “e” on your keyboard and then head to the tab you set your Sword to appear in.

 

Mine is the Combat tab and as you can see, the custom sword is at the bottom of the list of items.

 

 

You’ve officially created your own Minecraft Mod from scratch and loaded it into your own Minecraft game!

 

Congratulations!

 

You can make another sword using the same techniques or even challenge yourself to create an Axe or other tool.

 

 

If you enjoy Minecraft Modding and want to take your skills further, CodaKid has a series of courses that can teach you how to make your own custom creature, biome, dimension, insane explosions and special effects, and more!

 

Our courses even include messaging and screenshare support from live engineers if you ever get stuck, and our courses even come with a two week free trial!

 

We hope you enjoyed The Ultimate Guide to Minecraft Modding with Java in 2019. If you enjoyed our Minecraft modding tutorial, we’d love it if you could share it with friends.

 

If you have any questions or comments, please leave them below!

 

Happy Minecraft Modding!

 

Minecraft Modding course

 

Leave a Comment