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