Мод mob battles на майнкрафт

Monthly Archives: June 2013

icons [i] = par1IconRegister.registerIcon(Tutorial. modid + “:” + ( this .getUnlocalizedName().substring(5)) + i);

If you don’t know what this code means you should read the Block Metadata tutorial. The code is explained in there.
Again like the Block file you need to make sure that the Items get different textures depending on the metadata. Since Items don’t have sides the code for this is quite a bit easier. It should look like this for every Item if you follow the tutorial exactly.

public Icon getIconFromDamage( int par1)

return icons [par1];

This method has one parameter which is the damage of the item. The thing it wants returned is the Icon. Because we have an Icon array that has the same numbers for metadata as for the Icon we can simply return icons[par1] for every single metadata and that is the same in every metadata Item that is made like this.
There is one more thing that can be copied from the Block file. That is the getSubBlocks method. The only difference is, of course, that you have to change the name into getSubItems. The method should look like this.

@SideOnly (Side. CLIENT )

publicvoid getSubItems( int par1, CreativeTabs par2CreativeTabs, List par3List)

par3List.add( new ItemStack( this. 1, x));

This code is exactly the same as in the Block tutorial, if you don’t understand it, read that tutorial.
Now there are just 2 things left to do. The first is to make sure that the Item names are different for each metadata and then to make sure that the names in game are also different. The first thing is done by creating a String array that contains a special name for every metadata.
When you have made that array you will have to add the getUnlocalizedName method to the ItemTutorial file and add this code in there.

public String getUnlocalizedName(ItemStack par1ItemStack)

int i = MathHelper.clamp_int (par1ItemStack.getItemDamage(), 0, 15);

returnsuper .getUnlocalizedName() + “.” + names [i];

The code in this method is also the same for every single metadata Item.

The Item file should now look like this.

Добавить комментарий