Reputation: 11
I'm currently having some issues developing my first hand-written mod. I am currently using Eclipse Photon as my IDE, am running Windows 10 Home on a 64 bit machine, and have 4 GB of ram.
Here is my code:
package com.haxium.basicmod.obsidian.armor;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import com.haxium.basicmod.obsidian.armor.ItemObsidianGeneric;
import com.haxium.basicmod.obsidian.armor.ItemObsidianArmor;
@Mod(modid = ObsidianArmor.MODID, version = ObsidianArmor.VERSION, name = ObsidianArmor.NAME)
public class ObsidianArmor {
public static final String MODID = "obsidian_armor";
public static final String VERSION = "1.7.10-Stable-1.1.0.1";
public static final String NAME = "HaxCraft Obsidian Edition";
//tools
public static Item obsidian_pickaxe;
public static Item obsidian_sword;
public static Item obsidian_ingot;
ToolMaterial obsidian = EnumHelper.addToolMaterial("obsidian", 3, 4500, 10.1F, 4.5F, 10);
//armor
public static Item obsidian_helmet;
public static Item obsidian_chest;
public static Item obsidian_leggings;
public static Item obsidian_boots;
ArmorMaterial hardened_obsidian = EnumHelper.addArmorMaterial("hardened_obsidian", 20, new int[] {3, 7, 6, 3}, 25);
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//tools
obsidian_pickaxe = new ItemObsidianPickaxe(obsidian, "obsidian_pickaxe");
obsidian_sword = new ItemObsidianSword(obsidian, "obsidian_sword");
obsidian_ingot = new ItemObsidianGeneric("obsidian_ingot");
GameRegistry.registerItem(obsidian_ingot, "Obsidian Ingot");
GameRegistry.registerItem(obsidian_sword, "Obsidian Sword");
GameRegistry.registerItem(obsidian_pickaxe, "Obsidian Pickaxe");
//Armor
obsidian_boots = new ItemObsidianArmor(hardened_obsidian, 3, "obsidian_boots");
obsidian_helmet = new ItemObsidianArmor(hardened_obsidian, 0, "obsidian_helmet");
obsidian_chest = new ItemObsidianArmor(hardened_obsidian, 1, "obsidian_chest");
obsidian_leggings = new ItemObsidianArmor(hardened_obsidian, 2, "obsidian_leggings");
GameRegistry.registerItem(obsidian_helmet, "Obsidian Helmet");
GameRegistry.registerItem(obsidian_chest, "Obsidian Chestplate");
GameRegistry.registerItem(obsidian_leggings, "Obsidian Leggings");
GameRegistry.registerItem(obsidian_boots, "Obsidian Boots");
}
@EventHandler
public void init(FMLInitializationEvent event) {
GameRegistry.addRecipe(new ItemStack(Items.apple, 9),
"XXX",
"XXX",
"XXX",
'X', Blocks.leaves
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_ingot, 9),
"X",
'X', Blocks.obsidian
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_pickaxe),
"ABC",
"E",
"H",
'A', ObsidianArmor.obsidian_ingot, 'B', ObsidianArmor.obsidian_ingot, 'C', ObsidianArmor.obsidian_ingot, 'E', Items.stick, 'H', Items.stick
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_sword),
"B",
"E",
"HI",
'B', ObsidianArmor.obsidian_ingot, 'E', ObsidianArmor.obsidian_ingot, 'H', Items.stick
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_helmet),
"ABC",
"DF",
'A', ObsidianArmor.obsidian_ingot, 'B', ObsidianArmor.obsidian_ingot, 'C', ObsidianArmor.obsidian_ingot, 'D', ObsidianArmor.obsidian_ingot, 'F', ObsidianArmor.obsidian_ingot
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_chest),
"AC",
"DEF",
"GHI",
'A', ObsidianArmor.obsidian_ingot, 'C', ObsidianArmor.obsidian_ingot, 'D', ObsidianArmor.obsidian_ingot, 'E', ObsidianArmor.obsidian_ingot, 'F', ObsidianArmor.obsidian_ingot, 'G', ObsidianArmor.obsidian_ingot, 'H', ObsidianArmor.obsidian_ingot, 'I', ObsidianArmor.obsidian_ingot
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_leggings),
"ABC",
"DF",
"GI",
'A', ObsidianArmor.obsidian_ingot, 'B', ObsidianArmor.obsidian_ingot, 'C', ObsidianArmor.obsidian_ingot, 'D', ObsidianArmor.obsidian_ingot, 'F', ObsidianArmor.obsidian_ingot, 'G', ObsidianArmor.obsidian_ingot, 'I', ObsidianArmor.obsidian_ingot
);
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_boots),
"AC",
"DF",
'A', ObsidianArmor.obsidian_ingot, "C", ObsidianArmor.obsidian_ingot, 'D', ObsidianArmor.obsidian_ingot, 'F', ObsidianArmor.obsidian_ingot
);
}
}
Any suggestions as to why this keeps failing? If needed, I do have a local copy of the crash log.
Upvotes: 1
Views: 441
Reputation: 28722
At
GameRegistry.addRecipe(new ItemStack(ObsidianArmor.obsidian_sword),
"B",
"E",
"HI",
'B', ObsidianArmor.obsidian_ingot, 'E', ObsidianArmor.obsidian_ingot, 'H', Items.stick
);
You're lacking what I
should be.
At the new code at line 69 you are missing a few spaces to make the re ipe square. You should always fill in a 3x3 grid. Or make sure each item in the array that defines the recipe contains an equal number of items.
"B " // lacks a space
"E ", // lacks a space
"H ", // proper amount of spaces
In those crash logs, always find the class that is your class that will give you the line number in your class that caused it
com.haxium.basicmod.obsidian.armor.ObsidianArmor.init(ObsidianArmor.java:69)
This gives us line 69 in file ObsidianArmour.java
and the error at the top
java.lang.StringIndexOutOfBoundsException: String index out of range: 7
Tells us that the problem lies in strings. There were too few characters instead of the expected 9.
Upvotes: 0
Reputation: 48592
The shape of characters in your recipes need to be rectangles. If the recipes themselves aren't rectangles, add spaces where you don't need items. For example, this:
"ABC",
"E",
"H",
should be this:
"ABC",
" E ",
" H ",
Make that change in all of your recipes and the error will go away.
Upvotes: 2