package net.minecraft.world.biome;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenBlockBlob;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenTaiga1;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTallGrass;
import net.minecraft.world.gen.feature.WorldGenerator;

public class BiomeGenTaiga extends BiomeGenBase
{
	private static final WorldGenTaiga1 field_150639_aC = new WorldGenTaiga1();
	private static final WorldGenTaiga2 field_150640_aD = new WorldGenTaiga2(false);
	private static final WorldGenMegaPineTree field_150641_aE = new WorldGenMegaPineTree(false, false);
	private static final WorldGenMegaPineTree field_150642_aF = new WorldGenMegaPineTree(false, true);
	private static final WorldGenBlockBlob field_150643_aG = new WorldGenBlockBlob(Blocks.mossy_cobblestone, 0);
	private int field_150644_aH;
	private static final String __OBFID = "CL_00000186";

	public BiomeGenTaiga(int p_i45385_1_, int p_i45385_2_)
	{
		super(p_i45385_1_);
		this.field_150644_aH = p_i45385_2_;
		this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 8, 4, 4));
		this.theBiomeDecorator.treesPerChunk = 10;

		if (p_i45385_2_ != 1 && p_i45385_2_ != 2)
		{
			this.theBiomeDecorator.grassPerChunk = 1;
			this.theBiomeDecorator.mushroomsPerChunk = 1;
		}
		else
		{
			this.theBiomeDecorator.grassPerChunk = 7;
			this.theBiomeDecorator.deadBushPerChunk = 1;
			this.theBiomeDecorator.mushroomsPerChunk = 3;
		}
	}

	public WorldGenAbstractTree func_150567_a(Random p_150567_1_)
	{
		return (WorldGenAbstractTree)((this.field_150644_aH == 1 || this.field_150644_aH == 2) && p_150567_1_.nextInt(3) == 0 ? (this.field_150644_aH != 2 && p_150567_1_.nextInt(13) != 0 ? field_150641_aE : field_150642_aF) : (p_150567_1_.nextInt(3) == 0 ? field_150639_aC : field_150640_aD));
	}

	public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
	{
		return par1Random.nextInt(5) > 0 ? new WorldGenTallGrass(Blocks.tallgrass, 2) : new WorldGenTallGrass(Blocks.tallgrass, 1);
	}

	public void decorate(World par1World, Random par2Random, int par3, int par4)
	{
		int k;
		int l;
		int i1;
		int j1;

		if (this.field_150644_aH == 1 || this.field_150644_aH == 2)
		{
			k = par2Random.nextInt(3);

			for (l = 0; l < k; ++l)
			{
				i1 = par3 + par2Random.nextInt(16) + 8;
				j1 = par4 + par2Random.nextInt(16) + 8;
				int k1 = par1World.getHeightValue(i1, j1);
				field_150643_aG.generate(par1World, par2Random, i1, k1, j1);
			}
		}

		genTallFlowers.func_150548_a(3);

		for (k = 0; k < 7; ++k)
		{
			l = par3 + par2Random.nextInt(16) + 8;
			i1 = par4 + par2Random.nextInt(16) + 8;
			j1 = par2Random.nextInt(par1World.getHeightValue(l, i1) + 32);
			genTallFlowers.generate(par1World, par2Random, l, j1, i1);
		}

		super.decorate(par1World, par2Random, par3, par4);
	}

	public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_)
	{
		if (this.field_150644_aH == 1 || this.field_150644_aH == 2)
		{
			this.topBlock = Blocks.grass;
			this.field_150604_aj = 0;
			this.fillerBlock = Blocks.dirt;

			if (p_150573_7_ > 1.75D)
			{
				this.topBlock = Blocks.dirt;
				this.field_150604_aj = 1;
			}
			else if (p_150573_7_ > -0.95D)
			{
				this.topBlock = Blocks.dirt;
				this.field_150604_aj = 2;
			}
		}

		this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_);
	}

	public BiomeGenBase createMutation()
	{
		return this.biomeID == BiomeGenBase.megaTaiga.biomeID ? (new BiomeGenTaiga(this.biomeID + 128, 2)).func_150557_a(5858897, true).setBiomeName("Mega Spruce Taiga").func_76733_a(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(new BiomeGenBase.Height(this.rootHeight, this.heightVariation)) : super.createMutation();
	}
}