// Date: 3/3/2012 11:56:45 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX

package twilightforest.client.model.entity;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;

public class ModelTFPenguin extends ModelBase {
	//fields
	ModelRenderer body;
	ModelRenderer rightarm;
	ModelRenderer leftarm;
	ModelRenderer rightleg;
	ModelRenderer leftleg;
	ModelRenderer head;
	ModelRenderer beak;

	public ModelTFPenguin() {
		textureWidth = 64;
		textureHeight = 32;

		body = new ModelRenderer(this, 32, 0);
		body.addBox(-4F, 0F, -4F, 8, 9, 8);
		body.setRotationPoint(0F, 14F, 0F);

		rightarm = new ModelRenderer(this, 34, 18);
		rightarm.addBox(-1F, -1F, -2F, 1, 8, 4);
		rightarm.setRotationPoint(-4F, 15F, 0F);

		leftarm = new ModelRenderer(this, 24, 18);
		leftarm.addBox(0F, -1F, -2F, 1, 8, 4);
		leftarm.setRotationPoint(4F, 15F, 0F);

		leftarm.mirror = true;


		rightleg = new ModelRenderer(this, 0, 16);
		rightleg.addBox(-2F, 0F, -5F, 4, 1, 8);
		rightleg.setRotationPoint(-2F, 23F, 0F);
		rightleg.setTextureSize(64, 32);

		leftleg = new ModelRenderer(this, 0, 16);
		leftleg.addBox(-2F, 0F, -5F, 4, 1, 8);
		leftleg.setRotationPoint(2F, 23F, 0F);


		head = new ModelRenderer(this, 0, 0);
		head.addBox(-3.5F, -4F, -3.5F, 7, 5, 7);
		head.setRotationPoint(0F, 13F, 0F);

		beak = new ModelRenderer(this, 0, 13);
		beak.addBox(-1F, 0F, -1F, 2, 1, 2);
		beak.setRotationPoint(0F, -1F, -4F);

		head.addChild(beak);

	}

	/**
	 * Sets the models various rotation angles then renders the model.
	 */
	@Override
	public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);

		if (isChild) {
			float f = 2.0F;
			GlStateManager.pushMatrix();
			GlStateManager.translate(0.0F, 5F * scale, 0.75F * scale);
			head.render(scale);
			GlStateManager.popMatrix();
			GlStateManager.pushMatrix();
			GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);
			GlStateManager.translate(0.0F, 24F * scale, 0.0F);
			body.render(scale);
			rightleg.render(scale);
			leftleg.render(scale);
			rightarm.render(scale);
			leftarm.render(scale);
			GlStateManager.popMatrix();
		} else {
			head.render(scale);
			body.render(scale);
			rightleg.render(scale);
			leftleg.render(scale);
			rightarm.render(scale);
			leftarm.render(scale);
		}
	}

	/**
	 * Sets the models various rotation angles.
	 */
	@Override
	public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) {
		head.rotateAngleX = headPitch / (180F / (float) Math.PI);
		head.rotateAngleY = netHeadYaw / (180F / (float) Math.PI);

		rightleg.rotateAngleX = MathHelper.cos(limbSwing) * 0.7F * limbSwingAmount;
		leftleg.rotateAngleX = MathHelper.cos(limbSwing + (float) Math.PI) * 0.7F * limbSwingAmount;

		rightarm.rotateAngleZ = ageInTicks;
		leftarm.rotateAngleZ = -ageInTicks;
	}


}
