001package net.minecraft.block;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005
006import java.util.ArrayList;
007import java.util.List;
008import java.util.Random;
009import net.minecraft.block.material.Material;
010import net.minecraft.client.renderer.texture.IconRegister;
011import net.minecraft.creativetab.CreativeTabs;
012import net.minecraft.entity.player.EntityPlayer;
013import net.minecraft.item.Item;
014import net.minecraft.item.ItemStack;
015import net.minecraft.stats.StatList;
016import net.minecraft.util.Icon;
017import net.minecraft.world.ColorizerFoliage;
018import net.minecraft.world.ColorizerGrass;
019import net.minecraft.world.IBlockAccess;
020import net.minecraft.world.World;
021
022import net.minecraftforge.common.ForgeHooks;
023import net.minecraftforge.common.IShearable;
024
025public class BlockTallGrass extends BlockFlower implements IShearable
026{
027    private static final String[] field_94367_a = new String[] {"deadbush", "tallgrass", "fern"};
028    @SideOnly(Side.CLIENT)
029    private Icon[] field_94366_b;
030
031    protected BlockTallGrass(int par1)
032    {
033        super(par1, Material.vine);
034        float f = 0.4F;
035        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
036    }
037
038    @SideOnly(Side.CLIENT)
039
040    /**
041     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
042     */
043    public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
044    {
045        if (par2 >= this.field_94366_b.length)
046        {
047            par2 = 0;
048        }
049
050        return this.field_94366_b[par2];
051    }
052
053    /**
054     * Returns the ID of the items to drop on destruction.
055     */
056    public int idDropped(int par1, Random par2Random, int par3)
057    {
058        return -1;
059    }
060
061    /**
062     * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
063     */
064    public int quantityDroppedWithBonus(int par1, Random par2Random)
065    {
066        return 1 + par2Random.nextInt(par1 * 2 + 1);
067    }
068
069    /**
070     * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
071     * block and l is the block's subtype/damage.
072     */
073    public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
074    {
075        super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
076    }
077
078    @SideOnly(Side.CLIENT)
079    public int getBlockColor()
080    {
081        double d0 = 0.5D;
082        double d1 = 1.0D;
083        return ColorizerGrass.getGrassColor(d0, d1);
084    }
085
086    @SideOnly(Side.CLIENT)
087
088    /**
089     * Returns the color this block should be rendered. Used by leaves.
090     */
091    public int getRenderColor(int par1)
092    {
093        return par1 == 0 ? 16777215 : ColorizerFoliage.getFoliageColorBasic();
094    }
095
096    @SideOnly(Side.CLIENT)
097
098    /**
099     * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
100     * when first determining what to render.
101     */
102    public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
103    {
104        int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
105        return l == 0 ? 16777215 : par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor();
106    }
107
108    /**
109     * Get the block's damage value (for use with pick block).
110     */
111    public int getDamageValue(World par1World, int par2, int par3, int par4)
112    {
113        return par1World.getBlockMetadata(par2, par3, par4);
114    }
115
116    @SideOnly(Side.CLIENT)
117
118    /**
119     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
120     */
121    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
122    {
123        for (int j = 1; j < 3; ++j)
124        {
125            par3List.add(new ItemStack(par1, 1, j));
126        }
127    }
128
129    @SideOnly(Side.CLIENT)
130    public void func_94332_a(IconRegister par1IconRegister)
131    {
132        this.field_94366_b = new Icon[field_94367_a.length];
133
134        for (int i = 0; i < this.field_94366_b.length; ++i)
135        {
136            this.field_94366_b[i] = par1IconRegister.func_94245_a(field_94367_a[i]);
137        }
138    }
139
140    @Override
141    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int meta, int fortune)
142    {
143        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
144        if (world.rand.nextInt(8) != 0)
145        {
146            return ret;
147        }
148
149        ItemStack item = ForgeHooks.getGrassSeed(world);
150        if (item != null)
151        {
152            ret.add(item);
153        }
154        return ret;
155    }
156
157    @Override
158    public boolean isShearable(ItemStack item, World world, int x, int y, int z)
159    {
160        return true;
161    }
162
163    @Override
164    public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
165    {
166        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
167        ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
168        return ret;
169    }
170}