    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class WorldGenShrub extends WorldGenerator
    006    {
    007        private int field_76527_a;
    008        private int field_76526_b;
    009
    010        public WorldGenShrub(int par1, int par2)
    011        {
    012            this.field_76526_b = par1;
    013            this.field_76527_a = par2;
    014        }
    015
    016        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    017        {
    018            int var15;
    019
    020            Block block = null;
    021            do
    022            {
    023                block = Block.blocksList[par1World.getBlockId(par3,  par4, par5)];
    024                if (block != null && !block.isLeaves(par1World, par3, par4, par5))
    025                {
    026                    break;
    027                }
    028                par4--;
    029            } while (par4 > 0);
    030
    031            int var7 = par1World.getBlockId(par3, par4, par5);
    032
    033            if (var7 == Block.dirt.blockID || var7 == Block.grass.blockID)
    034            {
    035                ++par4;
    036                this.setBlockAndMetadata(par1World, par3, par4, par5, Block.wood.blockID, this.field_76526_b);
    037
    038                for (int var8 = par4; var8 <= par4 + 2; ++var8)
    039                {
    040                    int var9 = var8 - par4;
    041                    int var10 = 2 - var9;
    042
    043                    for (int var11 = par3 - var10; var11 <= par3 + var10; ++var11)
    044                    {
    045                        int var12 = var11 - par3;
    046
    047                        for (int var13 = par5 - var10; var13 <= par5 + var10; ++var13)
    048                        {
    049                            int var14 = var13 - par5;
    050
    051                            block = Block.blocksList[par1World.getBlockId(var11, var8, var13)];
    052
    053                            if ((Math.abs(var12) != var10 || Math.abs(var14) != var10 || par2Random.nextInt(2) != 0) &&
    054                                (block == null || block.canBeReplacedByLeaves(par1World, var11, var8, var13)))
    055                            {
    056                                this.setBlockAndMetadata(par1World, var11, var8, var13, Block.leaves.blockID, this.field_76527_a);
    057                            }
    058                        }
    059                    }
    060                }
    061            }
    062
    063            return true;
    064        }
    065    }