Reputation: 44
Hello fellow programmers, today, I've been watching & reading Minecraft modding tutorials. It's going pretty good, except a weird bug in my code.
I'm creating "Emerald tools" which is basically a re-textured and OP:ed version of a regular tool.
So far, I've learned how to make the different tool sets (Sword, Pickaxe, Axe, Shovel, and Hoe), but whenever I want to craft the tools in-game, I get unexpected results. For an example, when I craft an axe, it becomes a pickaxe instead, to see what the hedge I'm talking about, please review my source-code and possibly, compile if you have the ModLoader & MCP available.
package net.minecraft.src;
import java.util.Random;
public class mod_minecraft extends BaseMod //Main modding file, extends BaseMod
{
public static final Item mew = new ItemMew(2085).setItemName("Mew"); //Mew, Item tutorial.
public static final Item EmeraldSword = new ItemSword(3077, EnumToolMaterial.MCM).setItemName("EmeraldSword"); //Emerald Sword, sword tutorial
public static final Item EmeraldPickaxe = new ItemPickaxe(2102, EnumToolMaterial.MCM).setItemName("EmeraldPickaxe"); //Emerald Pick
public static final Item EmeraldAxe = new ItemAxe(2096, EnumToolMaterial.MCM).setItemName("Emerald Axe");
public static final Item EmeraldShovel = new ItemSpade(2107, EnumToolMaterial.MCM).setItemName("Emerald Shovel");
public static final Item EmeraldHoe = new ItemHoe(2099, EnumToolMaterial.MCM).setItemName("Emerald Shovel");
public void load()
{
//Mew
mew.iconIndex = ModLoader.addOverride("/gui/items.png", "/items/151Mew.png");
ModLoader.addName(mew, "Mew");
//
//Emerald Sword
EmeraldSword.iconIndex = ModLoader.addOverride("/gui/items.png" , "/items/greensword.png");
ModLoader.addName(EmeraldSword, "Emerald Sword");
ModLoader.addRecipe(new ItemStack(EmeraldSword, 1), new Object[]
{
" * ", " * ", " X ",
'X', Item.stick, '*', Item.emerald
});
//
///Emerald pickaxe
EmeraldPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/items/greenpick.png");
ModLoader.addName(EmeraldPickaxe, "Emerald Pickaxe");
ModLoader.addRecipe(new ItemStack(EmeraldPickaxe, 1), new Object[]
{
"***", " X ", " X ",
'X', Item.stick, '*', Item.emerald
});
//
//Emerald Axe
EmeraldAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/items/greenaxe.png");
ModLoader.addName(EmeraldAxe, "Emerald Axe");
ModLoader.addRecipe(new ItemStack(EmeraldPickaxe, 1), new Object[]
{
"** ", "*X ", " X ",
'X', Item.stick, '*', Item.emerald
});
//
//Emerald Shovel
EmeraldShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/items/greenshovel.png");
ModLoader.addName(EmeraldShovel, "Emerald Shovel");
ModLoader.addRecipe(new ItemStack(EmeraldShovel, 1), new Object []
{
" * ", " X ", " X ",
'*', Item.emerald, 'X', Item.stick
});
//
//Emerald Hoe
EmeraldHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/items/greenhoe.png");
ModLoader.addName(EmeraldHoe, "Emerald Hoe");
ModLoader.addRecipe(new ItemStack(EmeraldHoe, 1), new Object []
{
"** ", " X ", " X ",
'X', Item.stick, '*', Item.emerald
});
//
}
public String getVersion()
{
return "3.14159265";
}
In case you're wondering, my first "test" item was a pixelated version of Mew (the legendary pokemon :D), for some reason, I still have it implemented in the code.
What is wrong? The only tool I can build properly is the sword, all other tools have different ways to be crafted/no ways.
If you don't understand the source code below and you're a decent programmer, don't worry, this is Minecraft suff, which you obviously haven't tried.
I'm using ModLoader and MCP (Minecraft Coder Pack.
In case you're wondering, I'm able to compile the code, it's just that the crafting table gives unexpected results.
All answers are appreciated.
Upvotes: 1
Views: 699
Reputation: 86
Right off of the bat, your axe crafting recipe is:
ModLoader.addRecipe(new ItemStack(EmeraldPickaxe, 1), new Object[]
{
"** ", "X ", " X ",
'X', Item.stick, '', Item.emerald
});
Since you said Pickaxe, you are gonna have problems. My guess is that the Pickaxe and everything after it will be affected by that typo.
Upvotes: 4