001package net.minecraft.block;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.util.Random;
006import net.minecraft.block.material.Material;
007import net.minecraft.client.renderer.texture.IconRegister;
008import net.minecraft.util.Icon;
009import net.minecraft.world.World;
010
011public class BlockMushroomCap extends Block
012{
013    private static final String[] field_94429_a = new String[] {"mushroom_skin_brown", "mushroom_skin_red"};
014
015    /** The mushroom type. 0 for brown, 1 for red. */
016    private final int mushroomType;
017    @SideOnly(Side.CLIENT)
018    private Icon[] iconArray;
019    @SideOnly(Side.CLIENT)
020    private Icon field_94426_cO;
021    @SideOnly(Side.CLIENT)
022    private Icon field_94427_cP;
023
024    public BlockMushroomCap(int par1, Material par2Material, int par3)
025    {
026        super(par1, par2Material);
027        this.mushroomType = par3;
028    }
029
030    @SideOnly(Side.CLIENT)
031
032    /**
033     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
034     */
035    public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
036    {
037        return par2 == 10 && par1 > 1 ? this.field_94426_cO : (par2 >= 1 && par2 <= 9 && par1 == 1 ? this.iconArray[this.mushroomType] : (par2 >= 1 && par2 <= 3 && par1 == 2 ? this.iconArray[this.mushroomType] : (par2 >= 7 && par2 <= 9 && par1 == 3 ? this.iconArray[this.mushroomType] : ((par2 == 1 || par2 == 4 || par2 == 7) && par1 == 4 ? this.iconArray[this.mushroomType] : ((par2 == 3 || par2 == 6 || par2 == 9) && par1 == 5 ? this.iconArray[this.mushroomType] : (par2 == 14 ? this.iconArray[this.mushroomType] : (par2 == 15 ? this.field_94426_cO : this.field_94427_cP)))))));
038    }
039
040    /**
041     * Returns the quantity of items to drop on block destruction.
042     */
043    public int quantityDropped(Random par1Random)
044    {
045        int i = par1Random.nextInt(10) - 7;
046
047        if (i < 0)
048        {
049            i = 0;
050        }
051
052        return i;
053    }
054
055    /**
056     * Returns the ID of the items to drop on destruction.
057     */
058    public int idDropped(int par1, Random par2Random, int par3)
059    {
060        return Block.mushroomBrown.blockID + this.mushroomType;
061    }
062
063    @SideOnly(Side.CLIENT)
064
065    /**
066     * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
067     */
068    public int idPicked(World par1World, int par2, int par3, int par4)
069    {
070        return Block.mushroomBrown.blockID + this.mushroomType;
071    }
072
073    @SideOnly(Side.CLIENT)
074
075    /**
076     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
077     * is the only chance you get to register icons.
078     */
079    public void registerIcons(IconRegister par1IconRegister)
080    {
081        this.iconArray = new Icon[field_94429_a.length];
082
083        for (int i = 0; i < this.iconArray.length; ++i)
084        {
085            this.iconArray[i] = par1IconRegister.registerIcon(field_94429_a[i]);
086        }
087
088        this.field_94427_cP = par1IconRegister.registerIcon("mushroom_inside");
089        this.field_94426_cO = par1IconRegister.registerIcon("mushroom_skin_stem");
090    }
091}