Minecraft Modding – Setting Up Your Environment Windows 8.1, Minecraft 1.8.8
An update to this article for Windows 10 and Minecraft 1.16.4 is here.
We’re excited to offer a course teaching young people how to create Minecraft mods in November. This class introduces high schoolers to Java and how to use it to modify the popular game.
This post serves as a guide to help get started and is a little longer than our normal posts. I couldn’t find a single source of content so this is also a compilation of several sites that I used for research.
What is a “mod”?
Simply put, it’s a modification of the underlying code that runs the Minecraft game on your PC. It allows developers to create new items, blocks, characters, etc. inside the Minecraft environment. It is also perfectly legal and encouraged by Mojang (the game developers) in their licensing agreement: “If you’ve bought the Game, you may play around with it and modify it.”
My Environment
Windows 8.1 64 bit; Minecraft 1.8.8
There are four steps which I’ll describe in sections below:
- Install and set up Java
- Install Eclipse
- Install and configure Minecraft Forge
- Configure Eclipse environment
Install and set up Java
Java is the programming language that we’ll use to make modifications to Minecraft. This section is probably the trickiest if you’ve not used Java before.
Download the Java Development Kit (JDK). Note that you need the development kit and not the Runtime Environment (JRE). This will give you what you need to not only run Java programs but to also be able to compile Java code on your machine. You also need to make sure you select the correct version for your computer.
Click on the downloaded .exe file and your new code should be installed somewhere similar to: C:\Program Files\Java\jdk1.7.0_79
You’ll now need to setup your system’s environment variables. On Windows (in your Metro interface, not desktop mode), click on the Search bar and type ‘Edit the System’ and the following will appear:
Click on the ‘Edit the system environment variables’ link. This window will pop up and you should click the ‘Environment Variables…’ button at the bottom.
There are two settings that you need to update/edit.
First, JAVA_HOME. It’s Value should match the install folder that was created above when you clicked the java .exe.
Second, Path. It’s Value should have a lot of values already setup. At the very end (after the semicolon) enter the above path followed by \bin;
Now your machine is setup to compile Java code. (Fun, right?)
Install Eclipse
Eclipse serves as the Development Environment for your Java code. It provides built-in features that make programming much easier. Download Eclipse (select your appropriate environment on the upper right-hand area of the screen).
The downloaded file will be a .zip file. Once downloaded, you should right-click on that file and select ‘Extract All…’. This will open the .zip file and dump its contents into the folder that you choose. Mine looks like this:
Eclipse is now installed on your machine.
Install and configure Minecraft Forge
“Minecraft Forge is a modding API (Application Programming Interface), which makes it easier to create mods, and also make sure mods are compatible with each other.” It helps us create mods better and faster. I spent a lot of time finding the correct files to download so my time spent is time saved for you. There are two methods for setting up Forge: 1) For running mods that other people have created; and 2) being able to create and compile your own mods. Here’s the download link. Find the ‘Download Recommended’ area on the right and click on the ‘Src’ button.
Be careful, the next screen will display a “Download” button in the middle of the screen. It’s actually an ad and will download adware to your computer. Wait 5 seconds and a ‘Skip’ button will be displayed at the top right. Again, this will be downloaded as a .zip file.
Right-click on the .zip file and ‘Extract All…’ again. My folder is C:\MinecraftModding\Forge. Once this is finished extracting, right-click in the MinecraftModding folder and click New->Folder and call it ‘workspace’ (this is for our Eclipse setup later).
Click on the “Forge” folder and you should see the following:
Hold down shift, and right click, then select “Open command window here”.
Once the command window opens, type the following command exactly:
gradlew setupDecompWorkspace --refresh-dependencies
This will run through several commands and will take several minutes. I found that if I was on an unstable internet connection the process would fail (and the error wasn’t much help). Once I got to a stable connection it ran fine.
Next, run the following command to associate Forge with Eclipse:
gradlew eclipse
Configure Eclipse Environment
Last step and you should be ready to go. Click on the eclipse.exe file in the folder that you extracted to earlier (mine was C:\eclipse-java-mars-R-win32-x86_64\eclipse).
Eclipse will ask you to select a workspace. I chose the folder that we created earlier in the MinecraftModding folder entitled ‘workspace’. You can select to make this Default so that you’re not asked again but I work on other Java projects so I didn’t want to always open to Minecraft mods 🙂
In Eclipse we first have to create your mod project. To do so, we click on File > New > Project and select “Java Project” in the pop-up window which will appear. Give your project a name and click Finish. Now you have a blank Java project.
At this point we have a blank Java project for our code but our project has no awareness of the Minecraft Forge code. Click File > Import and choose “Existing Projects into workspace”. In the dialog for the import click the “Browse” button and select your C:\MinecraftModding\Forge directory as the source to import from. Then click finish. Ensure that a project named “Forge” is in the list of projects and is checked. Press ‘Finish’. The import linked the Forge workspace to your project’s workspace so you now have access to the Forge code.
Although Forge has been linked to the workspace it can’t be used yet. Forge must be added to your project’s buildpath so that the Java compiler compiles your mod and Forge together. Right-click on your Project in the Package Explorer on the left. Then click on Build Path > Configure. Go to the tab “Projects” and click “Add”. Select Forge as the project and click OK.
Finally you have to create Run Configurations. Select your project in the Package Explorer and click on the drop-down arrow next to the green “Run” button in the top tool bar. In the drop-down menu click on “Run Configurations”. Right-click on “Java Application” and click “New”. This creates a new Run Configuration of the type “Java Application”, so it will be a program that runs on your PC.
Name the Configuration ‘Launch Client’ with the following settings:
GradleStart
–username=<Username> –password=<Password>
The <Username> and <Password> are for your regular Minecraft game. Click Apply.
Now you can click on the green run button in the top of Eclipse and Minecraft should eventually start. Now Minecraft is running as a modified version and will load any code that we create.
References
http://jabelarminecraft.blogspot.com/
https://minecraft.net/
http://www.wuppy29.com/minecraft/modding-tutorials/forge-modding-1-8/
http://bedrockminer.jimdo.com/modding-tutorials/set-up-minecraft-forge/set-up-advanced-setup/
http://www.minecraftforge.net/wiki/Installation/Source