001    package net.minecraft.src;
002    
003    import java.util.Random;
004    
005    public class BlockFlower extends Block
006    {
007        protected BlockFlower(int par1, int par2, Material par3Material)
008        {
009            super(par1, par3Material);
010            this.blockIndexInTexture = par2;
011            this.setTickRandomly(true);
012            float var4 = 0.2F;
013            this.setBlockBounds(0.5F - var4, 0.0F, 0.5F - var4, 0.5F + var4, var4 * 3.0F, 0.5F + var4);
014            this.setCreativeTab(CreativeTabs.tabDecorations);
015        }
016    
017        protected BlockFlower(int par1, int par2)
018        {
019            this(par1, par2, Material.plants);
020        }
021    
022        /**
023         * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
024         */
025        public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
026        {
027            return super.canPlaceBlockAt(par1World, par2, par3, par4) && this.canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
028        }
029    
030        /**
031         * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
032         * blockID passed in. Args: blockID
033         */
034        protected boolean canThisPlantGrowOnThisBlockID(int par1)
035        {
036            return par1 == Block.grass.blockID || par1 == Block.dirt.blockID || par1 == Block.tilledField.blockID;
037        }
038    
039        /**
040         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
041         * their own) Args: x, y, z, neighbor blockID
042         */
043        public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
044        {
045            super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
046            this.checkFlowerChange(par1World, par2, par3, par4);
047        }
048    
049        /**
050         * Ticks the block if it's been scheduled
051         */
052        public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
053        {
054            this.checkFlowerChange(par1World, par2, par3, par4);
055        }
056    
057        protected final void checkFlowerChange(World par1World, int par2, int par3, int par4)
058        {
059            if (!this.canBlockStay(par1World, par2, par3, par4))
060            {
061                this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
062                par1World.setBlockWithNotify(par2, par3, par4, 0);
063            }
064        }
065    
066        /**
067         * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
068         */
069        public boolean canBlockStay(World par1World, int par2, int par3, int par4)
070        {
071            return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && this.canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
072        }
073    
074        /**
075         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
076         * cleared to be reused)
077         */
078        public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
079        {
080            return null;
081        }
082    
083        /**
084         * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
085         * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
086         */
087        public boolean isOpaqueCube()
088        {
089            return false;
090        }
091    
092        /**
093         * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
094         */
095        public boolean renderAsNormalBlock()
096        {
097            return false;
098        }
099    
100        /**
101         * The type of render function that is called for this block
102         */
103        public int getRenderType()
104        {
105            return 1;
106        }
107    }