Tutorial 6. Items

Before you read, make sure you have seen the previous tutorial

Code is on github

Lets go.

As adding items is nearly the same as adding blocks, i wont tell too much about what has already been handled in blocks. I will Only comment on NEW stuff.

So, we add a new Class ModItems, and call the method init();

We also add an item Object.
Before we continue, we have to create the Backbone again:

Few things to notice here:
1) getUnlocalizedName now returns item. + a string, instead of tile.
2) getUnlocalizedName is added 2 times, one for an itemstack as param, and one with no params. This is, becuase items can have damage. Damaged items dont get passed as item, but as an ItemStack. Therefor, MC needs a method to get an itemstack’s name
3) registerBlockIcons is now registerIcons, and doesnt change blockIcon, but itemIcon

A lot of properties for items dont excist. Hardness, resistance etc dont work.
These do.

One last thing, that we need to add in ModItems,

And once again, same as block, but changed the block to item.


For textures, add a new folder inside /assets/[modid]/textures called items, and place your texture in. Names can still go in en_US.lang.


Voila

Back to List
Next tutorial


2 Responses to Tutorial 6. Items

  1. Maarten says:

    Hey man,
    Your tutorials are awesome and its great that you get them out so fast. The link on your previous page to this tutorial at the bottom doesn’t exists though. Just so you know :). Anyway you are a great teacher!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">