Jump to content

[1.7.2][Solved] Item Creation


Naah

Recommended Posts

EDIT: The tutorial I linked from the wiki was missing a *very* important bit of code!

GameRegistry.registerItem(genericItem,"Generic Item");

After adding this for each item, they both show up now. Now I just have to figure out why LanguageRegistry.addName isn't setting the in-game item name properly. :P

/EDIT

 

DISCLAIMER - I am new to Minecraft mod creation, please don't hate me for it. I promise I have coded before(although not in Java), and I am very good at taking a little bit of information a long way. :P

 

I'm attempting to go off of the tutorial at http://www.minecraftforge.net/wiki/Basic_Items to create an item that I can select in Creative Mode. No grand schemes at the moment, I just want to put an item into the game. My code will compile and run, but the item doesn't show up.

 

I feel like maybe the reason this isn't working is because item IDs have gone out the window - but I haven't yet figured out how to bridge the gap from the old tutorial code to working 1.7.2 code.

 

Is there anyone who would be so kind as to post the basic 1.7.2 code/information needed to create an item?

 

EDIT: Using Forge 10.12.0.997

 

The tutorial code in the Generic Class (parts relating to items):

public class Generic 
{
    private static Item genericItem;
    private static Item genericIngot;
@EventHandler
        public void preInit(FMLPreInitializationEvent event) {
                genericItem = new GenericItem(5000);
                genericIngot = new GenericItem(5001)
                .setMaxStackSize(16).setUnlocalizedName("genericIngot");
        }
       
        @EventHandler
        public void load(FMLInitializationEvent event) {
                LanguageRegistry.addName(genericItem, "Generic Item");
                LanguageRegistry.addName(genericIngot, "Generic Ingot");
        }

But for 1.7.2 itemId isn't a property of items, so I would think simply changing to THIS would work:

@EventHandler
    public void preInit(FMLPreInitializationEvent event) 
    {
     genericItem = new GenericItem();
     
     genericIngot = new GenericItem().setMaxStackSize(16).setUnlocalizedName("genericIngot");
     
    }

But it doesn't seem to.

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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