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