It's been such a long time since I've last modded. There are only a couple 1.7.2 tutorials I could find, but I just can't seem to find out how to use assets correctly.
Here's my code:
Test.java
package com.travoos.test;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import cpw.mods.fml.common.registry.GameRegistry;
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;
@Mod(modid = Test.MODID, version = Test.VERSION, name = Test.NAME)
public class Test
{
public static final String NAME = "Test Mod";
public static final String MODID = "test";
public static final String VERSION = "1.0";
public static Item testItem;
@EventHandler
public void preinit(FMLPreInitializationEvent event)
{
Test.testItem = new TestItem().setUnlocalizedName("testItem");
}
@EventHandler
public void init(FMLInitializationEvent event)
{
ItemStack gravelStack = new ItemStack(Blocks.gravel);
ItemStack dirtStack = new ItemStack(Blocks.dirt);
GameRegistry.registerItem(testItem, "testItem");
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.dirt, 23), gravelStack, dirtStack);
GameRegistry.addSmelting(Items.diamond, new ItemStack(Test.testItem, 2), 5f);
}
}
TestItem.java
package com.travoos.test;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class TestItem extends Item {
public TestItem() {
super();
this.setMaxStackSize(14);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setTextureName("test:testItem");
}
@Override
public void registerIcons(IIconRegister register)
{
this.itemIcon = register.registerIcon("test:testItem");
}
}
And here's my project layout for the mod project (Probably incorrect):
testItem.png is a 16x16 sprite.
en_US.txt is just "item.testItem.name=Test"
When I smelt the diamond, the 2 stack of the item comes out, but it crashes when I try to take that item out.
I'd also like to point out that the item doesn't even appear in the creative menu.
So basically all I'm asking is, how would I do this correctly? What am I doing wrong?