Minecraft Forge Setup

This is the tenth lesson in a series introducing 10-year-olds to programming through Minecraft. Learn more here.

Note: These instructions are only guaranteed valid for Minecraft 1.6.2 (with no mods installed) and Forge 9.10.0.804. They also assume you already have the most recent JDK installed. Fingers crossed the real API is released soon and the state of modding Minecraft will be less in flux.

Installing Forge

Instructions for installing Forge are also available at at http://www.minecraftforge.net/wiki/Installation/Source

Determine JDK version

Open a new Windows Explorer window and navigate to C:\Program Files\Java\

You will have a directory in there called jdk1.7.0_xx (depending on when exactly you installed the JDK). Double-click on it and then double-click on bin. We are going to add the full path from the explorer address bar (e.g. C:\Program Files\Java\jdk1.7.0_xx\bin) to our PATH environment variable. Leave this window open so we can copy the path later.

Add the JDK path to our PATH environment variable

  • Right-click on "Computer" and choose Properties or Windows + X and choose 'System' or open Control Panel > System and Security > System
  • Choose 'Advanced System Settings' (Windows 7: click on the 'Advanced' tab)
  • Click the 'Environment variables' button at the bottom of the tab.
  • In the "User variables for xxx" section at the top, you will see a variable called PATH.
  • Click on it and then click the Edit button.
  • Click in the "variable value" text box and then press End. The cursor should now be sitting at the end of the line, most likely after a semicolon. If there is not a semicolon at the end of the line, type one in.
  • Copy (or type in) the full path from the Explorer window we used in the first step (e.g. C:\Program Files\Java\jdk1.7.0_21\bin)
  • Press OK (and close whatever other windows we opened for this step)

Installing Minecraft Forge

  • Download the most recommended 'src' build from http://files.minecraftforge.net/
  • Extract the zip to a new directory (e.g. C:\eclipse-workspace\)
  • Open an explorer window to wherever you extracted it, double-click on forge, and then double-click on install.cmd.

Base Mod and Eclipse setup

These are a simplified version of the instructions found at at http://www.minecraftforge.net/wiki/Basic_Modding. I would suggest making a copy of the entire forge directory just in case things get messy later...

  • Make sure your workspace points to /forge/mcp/eclipse (e.g. c:\eclipse-workspace\forge\mcp\eclipse)
  • Close Task list and Outline
  • Note that you've already got 7 warnings (we just ignore them)

  • Right-click on "src", New > Package. Name = mc.{initials}.first

  • Right-click on the new package, New > Class. Name = CommonProxy. Superclass = blank. Add an empty void method to it named registerRenderers.

  • Right-click on "src", New > Package. Name = mc.{initials}.first.client

  • Right-click on the new package, New > Class. Name = ClientProxy. Superclass = CommonProxy. Change the import statement to mc.{initials}.first.CommonProxy. Add an override for registerRenderers.

  • Right-click on the original package again, New > Class. Name = Generic. Superclass = blank. Replace with the code below:

(Note - update SidedProxy with the appropriate package names)

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import 
     cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid="Generic", name="Generic", version="0.0.0")
@NetworkMod(clientSideRequired=true, 
            serverSideRequired=false)
public class Generic {

    // The instance of your mod that Forge uses.
    @Instance("Generic")
    public static Generic instance;

    // Says where client and server 'proxy' code is loaded.
    @SidedProxy(clientSide=
                 "mc.jb.first.client.ClientProxy",
                serverSide="mc.jb.first.CommonProxy")
    public static CommonProxy proxy;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    }

    @EventHandler
    public void load(FMLInitializationEvent event) {
            proxy.registerRenderers();
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    }
}
  • You should be able to press the green play button (or Ctrl+F11) and have Minecraft launch with your new mod available.
comments powered by Disqus