Mod: Moustache Helmet and Superspeed Boots

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

The class suggested these two mods on the second-last day of class :) I figured it was simple enough to combine them into one activity as it builds on what we did with the chainsaw.

Add a new class, MoustacheHelmet with a superclass of net.minecraft.item.ItemArmor.

Add the following code to MoustacheHelmet.java

public MoustacheHelmet() {
    super(5001, EnumArmorMaterial.DIAMOND, 3, 0);
    setUnlocalizedName("moustache");
    setCreativeTab(CreativeTabs.tabCombat);
    func_111206_d("generic:moustachehelmet");
}

@Override
public String getArmorTexture(ItemStack stack,
                                  Entity entity,
                                  int slot,
                                  String type)
{
    return "generic:textures/models/armor/prestone_1.png";
}

Add a new class SuperSpeedBoots with a superclass of net.minecraft.item.ItemArmor.

public SuperSpeedBoots() {
    super(5002, EnumArmorMaterial.DIAMOND, 3, 3);
    setUnlocalizedName("superspeed");
    setCreativeTab(CreativeTabs.tabCombat);
    func_111206_d("generic:superspeedboots");
}

@Override
public String getArmorTexture(ItemStack stack,
                                  Entity entity,
                                  int slot,
                                  String type)
{
    return "generic:textures/models/armor/prestone_1.png";
}

@Override
public void onArmorTickUpdate(World world, 
                              EntityPlayer player,
                              ItemStack itemStack)
{
player.addPotionEffect(
           new PotionEffect(
             Potion.moveSpeed.getId(),100,2));
}

In our main mod file, create variables for our two new parts of the armor

public static final Item moustacheHelmet = 
              new MoustacheHelmet();
public static final Item superSpeedBoots = 
              new SuperspeedBoots();

and register them with the game in the load method

GameRegistry.registerItem(
      moustacheHelmet, "moustacheHelmet");
LanguageRegistry.addName(
      moustacheHelmet, "Moustache Helmet");

GameRegistry.registerItem(
      superSpeedBoots, "superspeedBoots");
LanguageRegistry.addName(
      superSpeedBoots, "Super Speed Boots");

We'll also make recipes this time (using diamonds, since we already have a mod to create diamonds from dirt)

GameRegistry.addRecipe(
    new ItemStack(moustacheHelmet),
    "XXX",
    "X X",
    'X', Item.diamond);

GameRegistry.addRecipe(
    new ItemStack(superSpeedBoots),
    "X X",
    "X X",
    'X', Item.diamond);

Now we have to copy our files (prestone_1.png and prestone2_.png) to

 forge
 \mcp
 \src
 \minecraft
 \assets
 \generic
 \textures
 \models
 \armor

And copy the inventory item images (moustachehelmet.png and superspeedboots.png) into

forge
\mcp
\src
\minecraft
\assets
\generic
\textures
\items

Make sure you have a folder link to:

forge
\mcp
\src
\minecraft
\assets

That's about it! Your player can now have a moustache for a helmet, and a constant Speed III potion once the boots are equipped.