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