Tags

, , , , , , , , , , , ,

Arkwood had a friend visit from Belgium, a mild and pleasant chap called Peters. Or so I thought. ‘Arkwood tells me you are a programmer,’ he said, ‘Do you like Minecraft?’ I replied, whilst cutting him a sandwich, ‘Oh, I’ve heard of it, but I have no cause for it.’ Suddenly he grabbed the knife and held it to my throat. ‘Make me a Minecraft Mod, or I’ll slice you open!’

With the blade of the knife grazing my Adam’s apple, I began to code. First I made use of the top video by Wuppy, to get my PC set up with the necessary software:

Java Platform (JDK) 8
Eclipse IDE for Java EE Developers
Forge 1.7.2 (Src)

My initial install of Forge was a bit messy, by which I mean I had to rerun the commands after a failed download, and Eclipse threw Java errors – but after a reinstall into a clean Forge folder everything was just grand. Asides from having a blade pressed into my neck, that is.

Okay, so the only piece of software left to get was Minecraft itself. (Un)fortunately, Peters already had a Minecraft account, so was able to download a copy onto Arkwood’s PC for no extra cost, the software installing into the current user profile: C:\Users\Arkwood\AppData\Roaming\.minecraft

With my finger trembling, I pressed the green Run button in the memory-sapping Eclipse, and Minecraft launched. Peters smiled. Phew.

Next up, I found some excellent tutorials from Havvy to help create a Minecraft Mod for my psychotic captor, implementing the code samples from the following:

Basic Modding
Basic Blocks
Icons and Textures

Now, it should be noted that Minecraft Modding is an ever-shifting sand, and some of the code samples in the tutorials may not work with the software versions you are on. Here’s the code that worked for the installations I grabbed above:

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
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.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid="peters", name="Peters", version="1.0.0")
public class Peters 
{
    public static Block petersBlock;
    
    @Instance(value="peters")
    public static Peters instance;
    
    @SidedProxy(clientSide="tutorial.generic.client.ClientProxy",
                    serverSide="tutorial.generic.CommonProxy")
    public static CommonProxy proxy;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) 
    {
    	petersBlock = new PetersBlock(Material.rock)
        .setHardness(50F)
        .setStepSound(Block.soundTypeStone)
        .setBlockName("Peters Block")
        .setCreativeTab(CreativeTabs.tabBlock)
        .setBlockTextureName("peters:petersBlock");

        GameRegistry.registerBlock(petersBlock, "petersBlock");
        
        proxy.registerRenderers();
    }
}
package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class PetersBlock extends Block 
{
    public PetersBlock (Material material) 
    {
        super(material);
    }
}
package tutorial.generic.client;

import tutorial.generic.CommonProxy;

public class ClientProxy extends CommonProxy 
{
    public void registerRenderers() 
    {

    }
}
package tutorial.generic;

public class CommonProxy 
{
    public void registerRenderers() 
    {

    }
}

We have everything we need for our custom block. That is, Peters custom block. In order to complete the job, and bring to an end my horrific ordeal, I need to design a nice texture with the egomaniac’s initials on it. Thank God the wonderful Nova Skin website makes this pig easy. I just painted and downloaded a Stone object, adding the .png file to the assets folder just as the tutorial suggests.

Launching Minecraft from within Eclipse, I was able to create a new world (Game Mode Creative) and see my custom block sitting in the Inventory. Nothing left to do but start using it.

minecraft_inventory_petersblock
minecraft_petersblock

Peters was delighted. He put the knife down and began to play Minecraft. I slid away whilst he was transfixed, mopped my sweaty brow down with some kitchen roll and then laced up my Doc Martens boots. Thankfully Peters was already sitting with his legs spread apart, so it took no extra coaxing from me to put the full force of a metal toe cap boot smack against his gonads. The true Minecraft fanatic that he is, he played on despite ferocious bleeding from his underpants.

Ciao!

Advertisements