    001package net.minecraft.world.gen.feature;
    002
    003import java.util.Random;
    004import net.minecraft.block.Block;
    005import net.minecraft.world.World;
    006
    007public class WorldGenTaiga1 extends WorldGenerator
    008{
    009    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    010    {
    011        int l = par2Random.nextInt(5) + 7;
    012        int i1 = l - par2Random.nextInt(2) - 3;
    013        int j1 = l - i1;
    014        int k1 = 1 + par2Random.nextInt(j1 + 1);
    015        boolean flag = true;
    016
    017        if (par4 >= 1 && par4 + l + 1 <= 128)
    018        {
    019            int l1;
    020            int i2;
    021            int j2;
    022            int k2;
    023            int l2;
    024
    025            for (l1 = par4; l1 <= par4 + 1 + l && flag; ++l1)
    026            {
    027                boolean flag1 = true;
    028
    029                if (l1 - par4 < i1)
    030                {
    031                    l2 = 0;
    032                }
    033                else
    034                {
    035                    l2 = k1;
    036                }
    037
    038                for (i2 = par3 - l2; i2 <= par3 + l2 && flag; ++i2)
    039                {
    040                    for (j2 = par5 - l2; j2 <= par5 + l2 && flag; ++j2)
    041                    {
    042                        if (l1 >= 0 && l1 < 128)
    043                        {
    044                            k2 = par1World.getBlockId(i2, l1, j2);
    045
    046                            Block block = Block.blocksList[k2];
    047
    048                            if (k2 != 0 && (block == null || !block.isLeaves(par1World, i2, l1, j2)))
    049                            {
    050                                flag = false;
    051                            }
    052                        }
    053                        else
    054                        {
    055                            flag = false;
    056                        }
    057                    }
    058                }
    059            }
    060
    061            if (!flag)
    062            {
    063                return false;
    064            }
    065            else
    066            {
    067                l1 = par1World.getBlockId(par3, par4 - 1, par5);
    068
    069                if ((l1 == Block.grass.blockID || l1 == Block.dirt.blockID) && par4 < 128 - l - 1)
    070                {
    071                    this.setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
    072                    l2 = 0;
    073
    074                    for (i2 = par4 + l; i2 >= par4 + i1; --i2)
    075                    {
    076                        for (j2 = par3 - l2; j2 <= par3 + l2; ++j2)
    077                        {
    078                            k2 = j2 - par3;
    079
    080                            for (int i3 = par5 - l2; i3 <= par5 + l2; ++i3)
    081                            {
    082                                int j3 = i3 - par5;
    083
    084                                Block block = Block.blocksList[par1World.getBlockId(j2, i2, i3)];
    085
    086                                if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) &&
    087                                    (block == null || block.canBeReplacedByLeaves(par1World, j2, i2, i3)))
    088                                {
    089                                    this.setBlockAndMetadata(par1World, j2, i2, i3, Block.leaves.blockID, 1);
    090                                }
    091                            }
    092                        }
    093
    094                        if (l2 >= 1 && i2 == par4 + i1 + 1)
    095                        {
    096                            --l2;
    097                        }
    098                        else if (l2 < k1)
    099                        {
    100                            ++l2;
    101                        }
    102                    }
    103
    104                    for (i2 = 0; i2 < l - 1; ++i2)
    105                    {
    106                        j2 = par1World.getBlockId(par3, par4 + i2, par5);
    107
    108                        Block block = Block.blocksList[j2];
    109
    110                        if (j2 == 0 || block == null || block.isLeaves(par1World, par3, par4 + i2, par5))
    111                        {
    112                            this.setBlockAndMetadata(par1World, par3, par4 + i2, par5, Block.wood.blockID, 1);
    113                        }
    114                    }
    115
    116                    return true;
    117                }
    118                else
    119                {
    120                    return false;
    121                }
    122            }
    123        }
    124        else
    125        {
    126            return false;
    127        }
    128    }
    129}