2
\$\begingroup\$

I am making my first mod and cannot see what is wrong with it. I am using MCP and Modloader. For my first mod I was going to make swords.

I started with making a new EnumToolMaterials

WOOD(0, 59, 2.0F, 0, 15),
STONE(1, 131, 4.0F, 1, 5),
IRON(2, 250, 6.0F, 2, 14),
LAPIS(3, 750, 7.0F, 2, 14),
OBSIDIAN(3, 1000, 7.5F, 3, 12),
EMERALD(3, 1561, 8.0F, 3, 10),//diamond
GREEN(3, 2000, 9.0F, 4, 10),//emerald
GOLD(0, 200, 12.0F, 0, 22);

then here is the mod class

public class _Mod_Yamiko extends BaseMod{

    /* mod itemts */
    public static final Item swordLapis = (new ItemSword(600, EnumToolMaterial.LAPIS)).setItemName("swordLapis");
    public static final Item swordObsidian = (new ItemSword(601, EnumToolMaterial.OBSIDIAN)).setItemName("swordObsidian");
    public static final Item swordGreen = (new ItemSword(602, EnumToolMaterial.GREEN)).setItemName("swordGreen");

    public void load(){
        //set images
        swordLapis.iconIndex = ModLoader.addOverride("/gui/items.png","/gui/swordLapis.png");

        ModLoader.addName(swordLapis, "Lapis Sword");
        //craft
        ModLoader.addRecipe(new ItemStack(_Mod_Yamiko.swordLapis, 1), new Object[]{
            " X ", " X ", " Y ",
            'X', Block.dirt, 
            'Y', Item.stick 
        });
    }

    public String getVersion(){
        return "0.1";
    }
}

Then I made a 16×16 .png image. I am not sure where to save it so I recompiled and reobfuscated, took the mod files and put it in my local Minecraft install, added the image where it be should be. No problems when playing but I cannot make the new sword.

\$\endgroup\$
3
\$\begingroup\$

It should be

ModLoader.addRecipe(new ItemStack(_Mod_Yamiko.swordLapis, 1), new Object[]{
            " X ", " X ", " Y ",
            Character.valueOf("X"), Block.dirt, 
            Character.valueOf("Y"), Item.stick 
        });

when referencing the characters

\$\endgroup\$
  • \$\begingroup\$ You mean Character.valueOf('X') with single quotes, right? Although I'm a bit surprised (having not worked with Java much lately) that just using a primitive char literal in an Object array doesn't simply autobox it. \$\endgroup\$ – Ilmari Karonen Nov 3 '12 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.