Jump to content

[1.7.10]Making Meta Items and getting Damage Values


BuddingDev

Recommended Posts

Basically, you need this in your item class:

 

Note: this is for my mod and one of the meta's outright doesn't exist and several only exist if IC2 is loaded.  Or would, if IC2 didn't handle them.  I've got them in here as I have several items that all use the same metadata numbers (itemA:3 is the same material as itemB:3 and itemC:3, even if itemB:3 is illogical and not used).

 

    @SideOnly(Side.CLIENT)
    public void getSubItems(Item item, CreativeTabs tab, List list) {
        list.add(new ItemStack(item, 1, 0));
        list.add(new ItemStack(item, 1, 1));
        //list.add(new ItemStack(item, 1, 2));
        list.add(new ItemStack(item, 1, 3));
        list.add(new ItemStack(item, 1, 4));
        /*if(Loader.isModLoaded("IC2")){
            list.add(new ItemStack(item, 1, 6));
            list.add(new ItemStack(item, 1, 7));
            list.add(new ItemStack(item, 1, );
            list.add(new ItemStack(item, 1, 9));
    	}*/
    }

 

Then you need the names, so you can localize them:

 

    public String getUnlocalizedName(ItemStack stack) {
    	switch(stack.getItemDamage()) {
    	case 0:
    		return "item.small_iron_dust";
    	case 1:
    		return "item.small_gold_dust";
    	case 2:
    		return "item.small_diamond_dust";//non-existent.  placeholder to match metadata across several items
    	case 3:
    		return "item.small_flour_dust";
    	case 4:
    		return "item.small_sugar_dust";
    	case 5:
    		return "item.small_limonite_dust";//non-existent.  placeholder to match metadata across several items
    	case 6:
    		return "item.small_tin_dust";//implemented by IC2, placeholder
    	case 7:
    		return "item.small_copper_dust";//implemented by IC2, placeholder
    	case 8:
    		return "item.small_lead_dust";//implemented by IC2, placeholder
    	case 9:
    		return "item.small_uranium_dust";//implemented by IC2, placeholder
    	}
        return "item.small_dust"; //Just in case, return something
    }

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.

Link to comment
Share on other sites

You can get it from the ItemStack, yes.

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.

Link to comment
Share on other sites

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.