package CustomOreGen.Util;

import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;

public class BiomeHeightScale implements HeightScale {

	@Override
	public int getHeight(World world, int x, int z) {
		BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
		if (world.provider.hasNoSky || biome == null) {
			return new WorldHeightScale().getHeight(world, x, z);
		}
		return (int)biome.rootHeight;
	}

	private int biomeToBlockHeight(float biomeHeight, World world) {
		int range;
		int groundHeight = world.provider.getAverageGroundLevel();
		if (biomeHeight > 0) {
			range = world.getHeight() - groundHeight;
		} else {
			range = groundHeight;
		}
		return (int)(groundHeight + biomeHeight / 4 * range);
	}
	
	@Override
	public String getName() {
		return "biome";
	}
}

@@ -398,21 +398,40 @@
 %09return 
-(int)
+this.biomeToBlockHeight(
 biome.ro
@@ -438,16 +438,24 @@
 otHeight
+, world)
 ;%0A%09%7D%0A%0A%09p
@@ -522,21 +522,8 @@
 ) %7B%0A
-%09%09int range;%0A
 %09%09in
@@ -583,118 +583,8 @@
 ();%0A
-%09%09if (biomeHeight %3E 0) %7B%0A%09%09%09range = world.getHeight() - groundHeight;%0A%09%09%7D else %7B%0A%09%09%09range = groundHeight;%0A%09%09%7D%0A
 %09%09re
@@ -609,16 +609,25 @@
 eight + 
+Math.min(
 biomeHei
@@ -633,20 +633,33 @@
 ight
+, 4.0)
  / 
-4 * range
+2 * groundHeight
 );%0A%09

fix biome height scale for 1.7.2 changes; not sure how well this will work with BoP