    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[] field_94428_c;
    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.field_94428_c[this.mushroomType] : (par2 >= 1 && par2 <= 3 && par1 == 2 ? this.field_94428_c[this.mushroomType] : (par2 >= 7 && par2 <= 9 && par1 == 3 ? this.field_94428_c[this.mushroomType] : ((par2 == 1 || par2 == 4 || par2 == 7) && par1 == 4 ? this.field_94428_c[this.mushroomType] : ((par2 == 3 || par2 == 6 || par2 == 9) && par1 == 5 ? this.field_94428_c[this.mushroomType] : (par2 == 14 ? this.field_94428_c[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    public void func_94332_a(IconRegister par1IconRegister)
    075    {
    076        this.field_94428_c = new Icon[field_94429_a.length];
    077
    078        for (int i = 0; i < this.field_94428_c.length; ++i)
    079        {
    080            this.field_94428_c[i] = par1IconRegister.func_94245_a(field_94429_a[i]);
    081        }
    082
    083        this.field_94427_cP = par1IconRegister.func_94245_a("mushroom_inside");
    084        this.field_94426_cO = par1IconRegister.func_94245_a("mushroom_skin_stem");
    085    }
    086}