I'm trying to modularize the way I add recipes to my mod, in order to cut down on all the duplicate code I've been writing. I've seen examples around the internet of people using an Object array to pass crafting pattern and ingredients, but for some reason I can't get it to work, as it keeps crashing on startup.
Here's the code where it crashes:
package ch.ax1m.aximtech.init;
// SNIP - imports
public class Recipes {
// SNIP - init method and other stuff
private static void addToolRecipe(ItemToolAT tool) {
String mat = tool.getOreMaterial();
Object[] pattern = null;
switch(Reference.ToolData.toolTypes.indexOf(tool.getToolType())) {
case 0:
pattern = new Object[] { "hXf", " X ", " I ", 'h', "hammer", 'f', "file" };
break;
// SNIP - other tool types
}
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(tool), pattern,
'X', "ingot" + mat, 'P', "plate" + mat, 'R', "rod" + mat, 'I', "stickWood"));
}
}
And this is the top of the stacktrace:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Character
at net.minecraftforge.oredict.ShapedOreRecipe.<init>(ShapedOreRecipe.java:89)
at ch.ax1m.aximtech.init.Recipes.addToolRecipe(Recipes.java:110)
at ch.ax1m.aximtech.init.Recipes.init(Recipes.java:42)
at ch.ax1m.aximtech.AximTech.init(AximTech.java:46)
I also tried wrapping the chars in my pattern Object in Character.valueOf(), as I've seen in a couple examples, but that didn't change anything, still gives me the same error.