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