Jump to content

Recommended Posts

Posted

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):

8npa.png

 

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.

 

CrxyC49.png

 

So basically all I'm asking is, how would I do this correctly? What am I doing wrong?

Posted

Change en_US.txt to en_US.lang.

 

The name is working now. Thanks. :D

 

However, the texture is still broken. Still not sure how to fix that.

 

Also, you need to set the item's unlocalized name.

 

The code is a little bit sloppy but I did. I just set it in the variable in Test.java instead of the declaration in TestItem.java.

Posted

You don't need this:

	@Override
public void registerIcons(IIconRegister register)
{
    this.itemIcon = register.registerIcon("test:testItem");
}

 

If you're using a single texture.

 

Also, use all lower case for your texture file name and your setTextureName string.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.