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 /**
086 * Get the block's damage value (for use with pick block).
087 */
088 public int getDamageValue(World par1World, int par2, int par3, int par4)
089 {
090 return par1World.getBlockMetadata(par2, par3, par4);
091 }
092
093 @SideOnly(Side.CLIENT)
094
095 /**
096 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
097 */
098 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
099 {
100 for (int var4 = 1; var4 < 3; ++var4)
101 {
102 par3List.add(new ItemStack(par1, 1, var4));
103 }
104 }
105
106 @Override
107 public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int meta, int fortune)
108 {
109 ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
110 if (world.rand.nextInt(8) != 0)
111 {
112 return ret;
113 }
114
115 ItemStack item = ForgeHooks.getGrassSeed(world);
116 if (item != null)
117 {
118 ret.add(item);
119 }
120 return ret;
121 }
122
123 @Override
124 public boolean isShearable(ItemStack item, World world, int x, int y, int z)
125 {
126 return true;
127 }
128
129 @Override
130 public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
131 {
132 ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
133 ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
134 return ret;
135 }
136 }