package net.minecraft.world.gen.feature;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;

public class WorldGenSand extends WorldGenerator
{
	private Block field_150517_a;
	private int radius;
	private static final String __OBFID = "CL_00000431";

	public WorldGenSand(Block p_i45462_1_, int p_i45462_2_)
	{
		this.field_150517_a = p_i45462_1_;
		this.radius = p_i45462_2_;
	}

	public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
	{
		if (par1World.getBlock(par3, par4, par5).getMaterial() != Material.water)
		{
			return false;
		}
		else
		{
			int l = par2Random.nextInt(this.radius - 2) + 2;
			byte b0 = 2;

			for (int i1 = par3 - l; i1 <= par3 + l; ++i1)
			{
				for (int j1 = par5 - l; j1 <= par5 + l; ++j1)
				{
					int k1 = i1 - par3;
					int l1 = j1 - par5;

					if (k1 * k1 + l1 * l1 <= l * l)
					{
						for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2)
						{
							Block block = par1World.getBlock(i1, i2, j1);

							if (block == Blocks.dirt || block == Blocks.grass)
							{
								par1World.setBlock(i1, i2, j1, this.field_150517_a, 0, 2);
							}
						}
					}
				}
			}

			return true;
		}
	}
}