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