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