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