    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 l = par2Random.nextInt(this.radius - 2) + 2;
    031            byte b0 = 2;
    032
    033            for (int i1 = par3 - l; i1 <= par3 + l; ++i1)
    034            {
    035                for (int j1 = par5 - l; j1 <= par5 + l; ++j1)
    036                {
    037                    int k1 = i1 - par3;
    038                    int l1 = j1 - par5;
    039
    040                    if (k1 * k1 + l1 * l1 <= l * l)
    041                    {
    042                        for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2)
    043                        {
    044                            int j2 = par1World.getBlockId(i1, i2, j1);
    045
    046                            if (j2 == Block.dirt.blockID || j2 == Block.grass.blockID)
    047                            {
    048                                par1World.setBlockAndMetadataWithNotify(i1, i2, j1, this.sandID, 0, 2);
    049                            }
    050                        }
    051                    }
    052                }
    053            }
    054
    055            return true;
    056        }
    057    }
    058}