package net.minecraft.world.gen.feature;

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

public class WorldGenIcePath extends WorldGenerator
{
	private Block field_150555_a;
	private int field_150554_b;
	private static final String __OBFID = "CL_00000416";

	public WorldGenIcePath(int p_i45454_1_)
	{
		this.field_150555_a = Blocks.packed_ice;
		this.field_150554_b = p_i45454_1_;
	}

	public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
	{
		while (par1World.isAirBlock(par3, par4, par5) && par4 > 2)
		{
			--par4;
		}

		if (par1World.getBlock(par3, par4, par5) != Blocks.snow)
		{
			return false;
		}
		else
		{
			int l = par2Random.nextInt(this.field_150554_b - 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.snow || block == Blocks.ice)
							{
								par1World.setBlock(i1, i2, j1, this.field_150555_a, 0, 2);
							}
						}
					}
				}
			}

			return true;
		}
	}
}