    001    package net.minecraft.world.gen.feature;
    002
    003    import java.util.Random;
    004    import net.minecraft.block.Block;
    005    import net.minecraft.world.World;
    006
    007    public class WorldGenTaiga2 extends WorldGenerator
    008    {
    009        public WorldGenTaiga2(boolean par1)
    010        {
    011            super(par1);
    012        }
    013
    014        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    015        {
    016            int var6 = par2Random.nextInt(4) + 6;
    017            int var7 = 1 + par2Random.nextInt(2);
    018            int var8 = var6 - var7;
    019            int var9 = 2 + par2Random.nextInt(2);
    020            boolean var10 = true;
    021
    022            if (par4 >= 1 && par4 + var6 + 1 <= 256)
    023            {
    024                int var11;
    025                int var13;
    026                int var15;
    027                int var21;
    028
    029                for (var11 = par4; var11 <= par4 + 1 + var6 && var10; ++var11)
    030                {
    031                    boolean var12 = true;
    032
    033                    if (var11 - par4 < var7)
    034                    {
    035                        var21 = 0;
    036                    }
    037                    else
    038                    {
    039                        var21 = var9;
    040                    }
    041
    042                    for (var13 = par3 - var21; var13 <= par3 + var21 && var10; ++var13)
    043                    {
    044                        for (int var14 = par5 - var21; var14 <= par5 + var21 && var10; ++var14)
    045                        {
    046                            if (var11 >= 0 && var11 < 256)
    047                            {
    048                                var15 = par1World.getBlockId(var13, var11, var14);
    049
    050                                Block block = Block.blocksList[var15];
    051
    052                                if (var15 != 0 && block != null && !block.isLeaves(par1World, var13, var11, var14))
    053                                {
    054                                    var10 = false;
    055                                }
    056                            }
    057                            else
    058                            {
    059                                var10 = false;
    060                            }
    061                        }
    062                    }
    063                }
    064
    065                if (!var10)
    066                {
    067                    return false;
    068                }
    069                else
    070                {
    071                    var11 = par1World.getBlockId(par3, par4 - 1, par5);
    072
    073                    if ((var11 == Block.grass.blockID || var11 == Block.dirt.blockID) && par4 < 256 - var6 - 1)
    074                    {
    075                        this.setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
    076                        var21 = par2Random.nextInt(2);
    077                        var13 = 1;
    078                        byte var22 = 0;
    079                        int var17;
    080                        int var16;
    081
    082                        for (var15 = 0; var15 <= var8; ++var15)
    083                        {
    084                            var16 = par4 + var6 - var15;
    085
    086                            for (var17 = par3 - var21; var17 <= par3 + var21; ++var17)
    087                            {
    088                                int var18 = var17 - par3;
    089
    090                                for (int var19 = par5 - var21; var19 <= par5 + var21; ++var19)
    091                                {
    092                                    int var20 = var19 - par5;
    093
    094                                    Block block = Block.blocksList[par1World.getBlockId(var17, var16, var19)];
    095
    096                                    if ((Math.abs(var18) != var21 || Math.abs(var20) != var21 || var21 <= 0) &&
    097                                        (block == null || block.canBeReplacedByLeaves(par1World, var17, var16, var19)))
    098                                    {
    099                                        this.setBlockAndMetadata(par1World, var17, var16, var19, Block.leaves.blockID, 1);
    100                                    }
    101                                }
    102                            }
    103
    104                            if (var21 >= var13)
    105                            {
    106                                var21 = var22;
    107                                var22 = 1;
    108                                ++var13;
    109
    110                                if (var13 > var9)
    111                                {
    112                                    var13 = var9;
    113                                }
    114                            }
    115                            else
    116                            {
    117                                ++var21;
    118                            }
    119                        }
    120
    121                        var15 = par2Random.nextInt(3);
    122
    123                        for (var16 = 0; var16 < var6 - var15; ++var16)
    124                        {
    125                            var17 = par1World.getBlockId(par3, par4 + var16, par5);
    126
    127                            Block block = Block.blocksList[var17];
    128
    129                            if (var17 == 0 || block == null || block.isLeaves(par1World, par3, par4 + var16, par5))
    130                            {
    131                                this.setBlockAndMetadata(par1World, par3, par4 + var16, par5, Block.wood.blockID, 1);
    132                            }
    133                        }
    134
    135                        return true;
    136                    }
    137                    else
    138                    {
    139                        return false;
    140                    }
    141                }
    142            }
    143            else
    144            {
    145                return false;
    146            }
    147        }
    148    }