// Date: 25.12.2015 00:46:58
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX

package com.hbm.render.model;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelT45Legs extends ModelBiped {

	ModelRenderer leftleg;
	ModelRenderer rightleg;
	ModelRenderer Shape1;
	ModelRenderer Shape2;
	ModelRenderer Shape3;
	ModelRenderer Shape4;
	ModelRenderer Shape5;
	ModelRenderer Shape6;

	public ModelT45Legs() {
		this.textureWidth = 64;
		this.textureHeight = 32;

		this.leftleg = new ModelRenderer(this, 0, 0);
		this.rightleg = new ModelRenderer(this, 0, 0);
		this.Shape1 = new ModelRenderer(this, 0, 0);
		this.Shape1.addBox(0F, 0F, 0F, 4, 12, 4);
		this.Shape1.setRotationPoint(-4F + 2, 0F - 0.5F, -2F);
		this.Shape1.setTextureSize(64, 32);
		this.Shape1.mirror = true;
		setRotation(this.Shape1, 0F, 0F, 0F);
		convertToChild(this.rightleg, this.Shape1);
		this.Shape2 = new ModelRenderer(this, 16, 0);
		this.Shape2.addBox(0F, 0F, 0F, 4, 12, 4);
		this.Shape2.setRotationPoint(0F - 2, 0F - 0.5F, -2F);
		this.Shape2.setTextureSize(64, 32);
		this.Shape2.mirror = true;
		setRotation(this.Shape2, 0F, 0F, 0F);
		convertToChild(this.leftleg, this.Shape2);
		this.Shape3 = new ModelRenderer(this, 0, 16);
		this.Shape3.addBox(0F, -6F, 0F, 5, 6, 4);
		this.Shape3.setRotationPoint(-5F + 2, 10F - 0.5F, -2F);
		this.Shape3.setTextureSize(64, 32);
		this.Shape3.mirror = true;
		setRotation(this.Shape3, 0.1745329F, 0F, 0F);
		convertToChild(this.rightleg, this.Shape3);
		this.Shape4 = new ModelRenderer(this, 18, 16);
		this.Shape4.addBox(0F, -6F, 0F, 5, 6, 4);
		this.Shape4.setRotationPoint(0F - 2, 10F - 0.5F, -2F);
		this.Shape4.setTextureSize(64, 32);
		this.Shape4.mirror = true;
		setRotation(this.Shape4, 0.1745329F, 0F, 0F);
		convertToChild(this.leftleg, this.Shape4);
		this.Shape5 = new ModelRenderer(this, 34, 0);
		this.Shape5.addBox(0F, 0F, 0F, 5, 2, 4);
		this.Shape5.setRotationPoint(-5F + 2, 1F - 0.5F, -3F);
		this.Shape5.setTextureSize(64, 32);
		this.Shape5.mirror = true;
		setRotation(this.Shape5, 0F, 0F, 0F);
		convertToChild(this.rightleg, this.Shape5);
		this.Shape6 = new ModelRenderer(this, 34, 8);
		this.Shape6.addBox(0F, 0F, 0F, 5, 2, 4);
		this.Shape6.setRotationPoint(0F - 2, 1F - 0.5F, -3F);
		this.Shape6.setTextureSize(64, 32);
		this.Shape6.mirror = true;
		setRotation(this.Shape6, 0F, 0F, 0F);
		convertToChild(this.leftleg, this.Shape6);
	}

	@Override
	public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) {

		this.isSneak = entity.isSneaking();
		this.isRiding = entity.isRiding();

		super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity);

		this.leftleg.rotationPointX = this.bipedLeftLeg.rotationPointX;
		this.leftleg.rotationPointY = this.bipedLeftLeg.rotationPointY - 1.5F;
		this.leftleg.rotationPointZ = this.bipedLeftLeg.rotationPointZ;
		this.leftleg.rotateAngleX = this.bipedLeftLeg.rotateAngleX;
		this.leftleg.rotateAngleY = this.bipedLeftLeg.rotateAngleY;
		this.leftleg.rotateAngleZ = this.bipedLeftLeg.rotateAngleZ;
		this.rightleg.rotationPointX = this.bipedRightLeg.rotationPointX;
		this.rightleg.rotationPointY = this.bipedRightLeg.rotationPointY - 1.5F;
		this.rightleg.rotationPointZ = this.bipedRightLeg.rotationPointZ;
		this.rightleg.rotateAngleX = this.bipedRightLeg.rotateAngleX;
		this.rightleg.rotateAngleY = this.bipedRightLeg.rotateAngleY;
		this.rightleg.rotateAngleZ = this.bipedRightLeg.rotateAngleZ;

		if (this.isSneak) {
			this.leftleg.rotationPointZ -= 0.5F;
			this.rightleg.rotationPointZ -= 0.5F;
			this.leftleg.rotationPointY += 0.5F;
			this.rightleg.rotationPointY += 0.5F;
		}
	}

	@Override
	public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {

		this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity);
		GL11.glPushMatrix();
		GL11.glScalef(1.125F, 1.125F, 1.125F);
		this.leftleg.render(scaleFactor);

		this.rightleg.render(scaleFactor);
		GL11.glPopMatrix();
	}

	protected static void convertToChild(ModelRenderer parent, ModelRenderer child) {

		// move child rotation point to be relative to parent
		child.rotationPointX -= parent.rotationPointX;
		child.rotationPointY -= parent.rotationPointY;
		child.rotationPointZ -= parent.rotationPointZ;
		// make rotations relative to parent
		child.rotateAngleX -= parent.rotateAngleX;
		child.rotateAngleY -= parent.rotateAngleY;
		child.rotateAngleZ -= parent.rotateAngleZ;
		// create relationship
		parent.addChild(child);
	}

	private static void setRotation(ModelRenderer model, float x, float y, float z) {

		model.rotateAngleX = x;
		model.rotateAngleY = y;
		model.rotateAngleZ = z;
	}
}
