    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.Random;
    006
    007    public class BlockMycelium extends Block
    008    {
    009        protected BlockMycelium(int par1)
    010        {
    011            super(par1, Material.grass);
    012            this.blockIndexInTexture = 77;
    013            this.setTickRandomly(true);
    014            this.setCreativeTab(CreativeTabs.tabBlock);
    015        }
    016
    017        /**
    018         * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
    019         */
    020        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
    021        {
    022            return par1 == 1 ? 78 : (par1 == 0 ? 2 : 77);
    023        }
    024
    025        @SideOnly(Side.CLIENT)
    026
    027        /**
    028         * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
    029         */
    030        public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    031        {
    032            if (par5 == 1)
    033            {
    034                return 78;
    035            }
    036            else if (par5 == 0)
    037            {
    038                return 2;
    039            }
    040            else
    041            {
    042                Material var6 = par1IBlockAccess.getBlockMaterial(par2, par3 + 1, par4);
    043                return var6 != Material.snow && var6 != Material.craftedSnow ? 77 : 68;
    044            }
    045        }
    046
    047        /**
    048         * Ticks the block if it's been scheduled
    049         */
    050        public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    051        {
    052            if (!par1World.isRemote)
    053            {
    054                if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
    055                {
    056                    par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID);
    057                }
    058                else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
    059                {
    060                    for (int var6 = 0; var6 < 4; ++var6)
    061                    {
    062                        int var7 = par2 + par5Random.nextInt(3) - 1;
    063                        int var8 = par3 + par5Random.nextInt(5) - 3;
    064                        int var9 = par4 + par5Random.nextInt(3) - 1;
    065                        int var10 = par1World.getBlockId(var7, var8 + 1, var9);
    066
    067                        if (par1World.getBlockId(var7, var8, var9) == Block.dirt.blockID && par1World.getBlockLightValue(var7, var8 + 1, var9) >= 4 && par1World.getBlockLightOpacity(var7, var8 + 1, var9) <= 2)
    068                        {
    069                            par1World.setBlockWithNotify(var7, var8, var9, this.blockID);
    070                        }
    071                    }
    072                }
    073            }
    074        }
    075
    076        @SideOnly(Side.CLIENT)
    077
    078        /**
    079         * A randomly called display update to be able to add particles or other items for display
    080         */
    081        public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    082        {
    083            super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
    084
    085            if (par5Random.nextInt(10) == 0)
    086            {
    087                par1World.spawnParticle("townaura", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.1F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);
    088            }
    089        }
    090
    091        /**
    092         * Returns the ID of the items to drop on destruction.
    093         */
    094        public int idDropped(int par1, Random par2Random, int par3)
    095        {
    096            return Block.dirt.idDropped(0, par2Random, par3);
    097        }
    098    }