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 WorldGenClay extends WorldGenerator
{
	private Block field_150546_a;
	private int numberOfBlocks;
	private static final String __OBFID = "CL_00000405";

	public WorldGenClay(int par1)
	{
		this.field_150546_a = Blocks.clay;
		this.numberOfBlocks = par1;
	}

	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.numberOfBlocks - 2) + 2;
			byte b0 = 1;

			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.clay)
							{
								par1World.setBlock(i1, i2, j1, this.field_150546_a, 0, 2);
							}
						}
					}
				}
			}

			return true;
		}
	}
}