    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class WorldGenLakes extends WorldGenerator
    006    {
    007        private int blockIndex;
    008
    009        public WorldGenLakes(int par1)
    010        {
    011            this.blockIndex = par1;
    012        }
    013
    014        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    015        {
    016            par3 -= 8;
    017
    018            for (par5 -= 8; par4 > 5 && par1World.isAirBlock(par3, par4, par5); --par4)
    019            {
    020                ;
    021            }
    022
    023            if (par4 <= 4)
    024            {
    025                return false;
    026            }
    027            else
    028            {
    029                par4 -= 4;
    030                boolean[] var6 = new boolean[2048];
    031                int var7 = par2Random.nextInt(4) + 4;
    032                int var8;
    033
    034                for (var8 = 0; var8 < var7; ++var8)
    035                {
    036                    double var9 = par2Random.nextDouble() * 6.0D + 3.0D;
    037                    double var11 = par2Random.nextDouble() * 4.0D + 2.0D;
    038                    double var13 = par2Random.nextDouble() * 6.0D + 3.0D;
    039                    double var15 = par2Random.nextDouble() * (16.0D - var9 - 2.0D) + 1.0D + var9 / 2.0D;
    040                    double var17 = par2Random.nextDouble() * (8.0D - var11 - 4.0D) + 2.0D + var11 / 2.0D;
    041                    double var19 = par2Random.nextDouble() * (16.0D - var13 - 2.0D) + 1.0D + var13 / 2.0D;
    042
    043                    for (int var21 = 1; var21 < 15; ++var21)
    044                    {
    045                        for (int var22 = 1; var22 < 15; ++var22)
    046                        {
    047                            for (int var23 = 1; var23 < 7; ++var23)
    048                            {
    049                                double var24 = ((double)var21 - var15) / (var9 / 2.0D);
    050                                double var26 = ((double)var23 - var17) / (var11 / 2.0D);
    051                                double var28 = ((double)var22 - var19) / (var13 / 2.0D);
    052                                double var30 = var24 * var24 + var26 * var26 + var28 * var28;
    053
    054                                if (var30 < 1.0D)
    055                                {
    056                                    var6[(var21 * 16 + var22) * 8 + var23] = true;
    057                                }
    058                            }
    059                        }
    060                    }
    061                }
    062
    063                int var10;
    064                int var32;
    065                boolean var33;
    066
    067                for (var8 = 0; var8 < 16; ++var8)
    068                {
    069                    for (var32 = 0; var32 < 16; ++var32)
    070                    {
    071                        for (var10 = 0; var10 < 8; ++var10)
    072                        {
    073                            var33 = !var6[(var8 * 16 + var32) * 8 + var10] && (var8 < 15 && var6[((var8 + 1) * 16 + var32) * 8 + var10] || var8 > 0 && var6[((var8 - 1) * 16 + var32) * 8 + var10] || var32 < 15 && var6[(var8 * 16 + var32 + 1) * 8 + var10] || var32 > 0 && var6[(var8 * 16 + (var32 - 1)) * 8 + var10] || var10 < 7 && var6[(var8 * 16 + var32) * 8 + var10 + 1] || var10 > 0 && var6[(var8 * 16 + var32) * 8 + (var10 - 1)]);
    074
    075                            if (var33)
    076                            {
    077                                Material var12 = par1World.getBlockMaterial(par3 + var8, par4 + var10, par5 + var32);
    078
    079                                if (var10 >= 4 && var12.isLiquid())
    080                                {
    081                                    return false;
    082                                }
    083
    084                                if (var10 < 4 && !var12.isSolid() && par1World.getBlockId(par3 + var8, par4 + var10, par5 + var32) != this.blockIndex)
    085                                {
    086                                    return false;
    087                                }
    088                            }
    089                        }
    090                    }
    091                }
    092
    093                for (var8 = 0; var8 < 16; ++var8)
    094                {
    095                    for (var32 = 0; var32 < 16; ++var32)
    096                    {
    097                        for (var10 = 0; var10 < 8; ++var10)
    098                        {
    099                            if (var6[(var8 * 16 + var32) * 8 + var10])
    100                            {
    101                                par1World.setBlock(par3 + var8, par4 + var10, par5 + var32, var10 >= 4 ? 0 : this.blockIndex);
    102                            }
    103                        }
    104                    }
    105                }
    106
    107                for (var8 = 0; var8 < 16; ++var8)
    108                {
    109                    for (var32 = 0; var32 < 16; ++var32)
    110                    {
    111                        for (var10 = 4; var10 < 8; ++var10)
    112                        {
    113                            if (var6[(var8 * 16 + var32) * 8 + var10] && par1World.getBlockId(par3 + var8, par4 + var10 - 1, par5 + var32) == Block.dirt.blockID && par1World.getSavedLightValue(EnumSkyBlock.Sky, par3 + var8, par4 + var10, par5 + var32) > 0)
    114                            {
    115                                BiomeGenBase var35 = par1World.getBiomeGenForCoords(par3 + var8, par5 + var32);
    116
    117                                if (var35.topBlock == Block.mycelium.blockID)
    118                                {
    119                                    par1World.setBlock(par3 + var8, par4 + var10 - 1, par5 + var32, Block.mycelium.blockID);
    120                                }
    121                                else
    122                                {
    123                                    par1World.setBlock(par3 + var8, par4 + var10 - 1, par5 + var32, Block.grass.blockID);
    124                                }
    125                            }
    126                        }
    127                    }
    128                }
    129
    130                if (Block.blocksList[this.blockIndex].blockMaterial == Material.lava)
    131                {
    132                    for (var8 = 0; var8 < 16; ++var8)
    133                    {
    134                        for (var32 = 0; var32 < 16; ++var32)
    135                        {
    136                            for (var10 = 0; var10 < 8; ++var10)
    137                            {
    138                                var33 = !var6[(var8 * 16 + var32) * 8 + var10] && (var8 < 15 && var6[((var8 + 1) * 16 + var32) * 8 + var10] || var8 > 0 && var6[((var8 - 1) * 16 + var32) * 8 + var10] || var32 < 15 && var6[(var8 * 16 + var32 + 1) * 8 + var10] || var32 > 0 && var6[(var8 * 16 + (var32 - 1)) * 8 + var10] || var10 < 7 && var6[(var8 * 16 + var32) * 8 + var10 + 1] || var10 > 0 && var6[(var8 * 16 + var32) * 8 + (var10 - 1)]);
    139
    140                                if (var33 && (var10 < 4 || par2Random.nextInt(2) != 0) && par1World.getBlockMaterial(par3 + var8, par4 + var10, par5 + var32).isSolid())
    141                                {
    142                                    par1World.setBlock(par3 + var8, par4 + var10, par5 + var32, Block.stone.blockID);
    143                                }
    144                            }
    145                        }
    146                    }
    147                }
    148
    149                if (Block.blocksList[this.blockIndex].blockMaterial == Material.water)
    150                {
    151                    for (var8 = 0; var8 < 16; ++var8)
    152                    {
    153                        for (var32 = 0; var32 < 16; ++var32)
    154                        {
    155                            byte var34 = 4;
    156
    157                            if (par1World.isBlockFreezable(par3 + var8, par4 + var34, par5 + var32))
    158                            {
    159                                par1World.setBlock(par3 + var8, par4 + var34, par5 + var32, Block.ice.blockID);
    160                            }
    161                        }
    162                    }
    163                }
    164
    165                return true;
    166            }
    167        }
    168    }