    001package net.minecraft.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.block.Block;
    006import net.minecraft.block.BlockLeaves;
    007import net.minecraft.util.Icon;
    008import net.minecraft.world.ColorizerFoliage;
    009
    010public class ItemLeaves extends ItemBlock
    011{
    012    public ItemLeaves(int par1)
    013    {
    014        super(par1);
    015        this.setMaxDamage(0);
    016        this.setHasSubtypes(true);
    017    }
    018
    019    /**
    020     * Returns the metadata of the block which this Item (ItemBlock) can place
    021     */
    022    public int getMetadata(int par1)
    023    {
    024        return par1 | 4;
    025    }
    026
    027    @SideOnly(Side.CLIENT)
    028
    029    /**
    030     * Gets an icon index based on an item's damage value
    031     */
    032    public Icon getIconFromDamage(int par1)
    033    {
    034        return Block.leaves.getIcon(0, par1);
    035    }
    036
    037    @SideOnly(Side.CLIENT)
    038    public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
    039    {
    040        int j = par1ItemStack.getItemDamage();
    041        return (j & 1) == 1 ? ColorizerFoliage.getFoliageColorPine() : ((j & 2) == 2 ? ColorizerFoliage.getFoliageColorBirch() : ColorizerFoliage.getFoliageColorBasic());
    042    }
    043
    044    /**
    045     * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
    046     * different names based on their damage or NBT.
    047     */
    048    public String getUnlocalizedName(ItemStack par1ItemStack)
    049    {
    050        int i = par1ItemStack.getItemDamage();
    051
    052        if (i < 0 || i >= BlockLeaves.LEAF_TYPES.length)
    053        {
    054            i = 0;
    055        }
    056
    057        return super.getUnlocalizedName() + "." + BlockLeaves.LEAF_TYPES[i];
    058    }
    059}