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