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.Random;
008
009 public class BlockNetherStalk extends BlockFlower
010 {
011 protected BlockNetherStalk(int par1)
012 {
013 super(par1, 226);
014 this.setTickRandomly(true);
015 float var2 = 0.5F;
016 this.setBlockBounds(0.5F - var2, 0.0F, 0.5F - var2, 0.5F + var2, 0.25F, 0.5F + var2);
017 this.setCreativeTab((CreativeTabs)null);
018 }
019
020 /**
021 * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
022 * blockID passed in. Args: blockID
023 */
024 protected boolean canThisPlantGrowOnThisBlockID(int par1)
025 {
026 return par1 == Block.slowSand.blockID;
027 }
028
029 /**
030 * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
031 */
032 public boolean canBlockStay(World par1World, int par2, int par3, int par4)
033 {
034 return this.canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
035 }
036
037 /**
038 * Ticks the block if it's been scheduled
039 */
040 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
041 {
042 int var6 = par1World.getBlockMetadata(par2, par3, par4);
043
044 if (var6 < 3 && par5Random.nextInt(10) == 0)
045 {
046 ++var6;
047 par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
048 }
049
050 super.updateTick(par1World, par2, par3, par4, par5Random);
051 }
052
053 /**
054 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
055 */
056 public int getBlockTextureFromSideAndMetadata(int par1, int par2)
057 {
058 return par2 >= 3 ? this.blockIndexInTexture + 2 : (par2 > 0 ? this.blockIndexInTexture + 1 : this.blockIndexInTexture);
059 }
060
061 /**
062 * The type of render function that is called for this block
063 */
064 public int getRenderType()
065 {
066 return 6;
067 }
068
069 /**
070 * Drops the block items with a specified chance of dropping the specified items
071 */
072 public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
073 {
074 super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
075 }
076
077 /**
078 * Returns the ID of the items to drop on destruction.
079 */
080 public int idDropped(int par1, Random par2Random, int par3)
081 {
082 return 0;
083 }
084
085 /**
086 * Returns the quantity of items to drop on block destruction.
087 */
088 public int quantityDropped(Random par1Random)
089 {
090 return 0;
091 }
092
093 @SideOnly(Side.CLIENT)
094
095 /**
096 * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
097 */
098 public int idPicked(World par1World, int par2, int par3, int par4)
099 {
100 return Item.netherStalkSeeds.shiftedIndex;
101 }
102
103 @Override
104 public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
105 {
106 ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
107 int count = 1;
108
109 if (metadata >= 3)
110 {
111 count = 2 + world.rand.nextInt(3) + (fortune > 0 ? world.rand.nextInt(fortune + 1) : 0);
112 }
113
114 for (int i = 0; i < count; i++)
115 {
116 ret.add(new ItemStack(Item.netherStalkSeeds));
117 }
118
119 return ret;
120 }
121 }