    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class WorldGenSand extends WorldGenerator
    006    {
    007        /** Stores ID for WorldGenSand */
    008        private int sandID;
    009
    010        /** The maximum radius used when generating a patch of blocks. */
    011        private int radius;
    012
    013        public WorldGenSand(int par1, int par2)
    014        {
    015            this.sandID = par2;
    016            this.radius = par1;
    017        }
    018
    019        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    020        {
    021            if (par1World.getBlockMaterial(par3, par4, par5) != Material.water)
    022            {
    023                return false;
    024            }
    025            else
    026            {
    027                int var6 = par2Random.nextInt(this.radius - 2) + 2;
    028                byte var7 = 2;
    029
    030                for (int var8 = par3 - var6; var8 <= par3 + var6; ++var8)
    031                {
    032                    for (int var9 = par5 - var6; var9 <= par5 + var6; ++var9)
    033                    {
    034                        int var10 = var8 - par3;
    035                        int var11 = var9 - par5;
    036
    037                        if (var10 * var10 + var11 * var11 <= var6 * var6)
    038                        {
    039                            for (int var12 = par4 - var7; var12 <= par4 + var7; ++var12)
    040                            {
    041                                int var13 = par1World.getBlockId(var8, var12, var9);
    042
    043                                if (var13 == Block.dirt.blockID || var13 == Block.grass.blockID)
    044                                {
    045                                    par1World.setBlock(var8, var12, var9, this.sandID);
    046                                }
    047                            }
    048                        }
    049                    }
    050                }
    051
    052                return true;
    053            }
    054        }
    055    }