package biomesoplenty.worldgen;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;

public class WorldGenNetherBush extends WorldGenerator
{
	@Override
	public boolean generate(World var1, Random var2, int var3, int var4, int var5)
	{
		while (var1.isAirBlock(var3, var4, var5) && var4 > 2)
		{
			--var4;
		}

		int var6 = var1.getBlockId(var3, var4, var5);
		int var99 = var1.getBlockId(var3, var4 + 1, var5);

		if (var6 != Block.netherrack.blockID && var6 != Block.grass.blockID && var99 != 0)
			return false;
		else
		{
			for (int var7 = -2; var7 <= 2; ++var7)
			{
				for (int var8 = -2; var8 <= 2; ++var8)
				{
					if (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8) && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8))
						return false;
				}
			}

			var1.setBlock(var3, var4, var5, Block.netherrack.blockID);
			this.setBlockAndMetadata(var1, var3, var4 + 1, var5, Blocks.logs4.get().blockID, 1);
			this.setBlockAndMetadata(var1, var3, var4 + 2, var5, Blocks.logs4.get().blockID, 1);
			this.setBlockAndMetadata(var1, var3 + 1, var4 + 2, var5, Blocks.leaves2.get().blockID, 4);
			this.setBlockAndMetadata(var1, var3 - 1, var4 + 2, var5, Blocks.leaves2.get().blockID, 4);
			this.setBlockAndMetadata(var1, var3, var4 + 2, var5 + 1, Blocks.leaves2.get().blockID, 4);
			this.setBlockAndMetadata(var1, var3, var4 + 2, var5 - 1, Blocks.leaves2.get().blockID, 4);
			this.setBlockAndMetadata(var1, var3, var4 + 3, var5, Blocks.leaves2.get().blockID, 4);
			return true;
		}
	}
}
