package de.outinetworks.InfoMod.mods;

import java.math.BigDecimal;
import java.math.RoundingMode;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityHorse;

public class AnimalInfo {

	static int width;
	static int height;
	static Minecraft MC;
	
	public static void renderInfoBox(Entity entity)
	{
		MC = Minecraft.getMinecraft();
		ScaledResolution scaled = new ScaledResolution(MC);
		width = scaled.getScaledWidth();
		height = scaled.getScaledHeight();
		Entity target = null;
		try {
			target = Minecraft.getMinecraft().objectMouseOver.entityHit;
		}
		catch(Exception e) {
			
		}
		if (target == null) return;
		if (!(target instanceof EntityLiving)) return ;
		if (target instanceof EntityHorse)
		{
			EntityHorse Horse = (EntityHorse) target;
			
			GL11.glPushMatrix();
	        GlStateManager.disableDepth();
	        GL11.glScalef(1F, 1F, 1F);
	       
	        double yVelocity = Horse.getHorseJumpStrength(); //horses's jump strength attribute
	        double jumpHeight = 0;
	        while (yVelocity > 0)
	        {
		        jumpHeight += yVelocity;
		        yVelocity -= 0.08;
		        yVelocity *= 0.98;
	        }
	        
	        MC.fontRendererObj.drawString("Jump: " + String.format("%.1f", round(jumpHeight,1)) + " blocks", (width / 2) + 5, (height/2) + 5, 0xffffff);
	        MC.fontRendererObj.drawString("Health: " + String.format("%.0f", round(Horse.getMaxHealth(),0)), (width / 2) + 5, (height/2) + 15, 0xffffff);
	        MC.fontRendererObj.drawString("Speed: " + String.format("%.1f", round((float)Horse.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue() * 43 ,1)) + " blocks/sec", (width / 2) + 5, (height/2) + 25, 0xffffff);
	        
	        GlStateManager.enableDepth();
	        GL11.glPopMatrix();
		}
		
	}
	
	public static double round(double value, int places) {
	    if (places < 0) throw new IllegalArgumentException();

	    BigDecimal bd = new BigDecimal(value);
	    bd = bd.setScale(places, RoundingMode.DOWN);
	    return bd.doubleValue();
	}
}
@@ -1152,25 +1152,24 @@
 1F);%0A%09      
- 
 %0A%09        do
@@ -1177,262 +1177,66 @@
 ble 
-yVelocity = Horse.getHorseJumpStrength(); //horses's jump strength attribute%0A%09        double jumpHeight = 0;%0A%09        while (yVelocity %3E 0)%0A%09        %7B%0A%09%09        jumpHeight += yVelocity;%0A%09%09        yVelocity -= 0.08;%0A%09%09        yVelocity *= 0.98;%0A%09        %7D
+jumpHeight = calcJumpHeight(Horse.getHorseJumpStrength());
 %0A%09  
@@ -1871,16 +1871,316 @@
 %09%09%0A%09%7D%0A%09%0A
+%09private static double calcJumpHeight(double jumpStrength)%0A%09%7B%0A%09%09// JumpHeight = -0.1817584952 * x%5E3 + 3.689713992 * x%5E2 + 2.128599134 * x - 0.343930367%0A%09%09return (-0.1817584952 * Math.pow(jumpStrength, 3)) + (3.689713992 * Math.pow(jumpStrength, 2)) + (2.128599134 * jumpStrength) - 0.343930367;%0A%09%7D%0A%09%0A
 %09public 

fix jump height calculation (changed in 1.9)