// Date: 14.09.2015 19:47:47
// 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;
import net.minecraft.entity.player.EntityPlayer;

public class ModelGoggles extends ModelBiped {

	ModelRenderer Shape1;
	ModelRenderer Shape2;
	ModelRenderer Shape5;
	ModelRenderer Shape6;
	ModelRenderer Shape7;
	ModelRenderer google;

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

		this.google = new ModelRenderer(this, 0, 0);
		this.Shape1 = new ModelRenderer(this, 0, 0);
		this.Shape1.addBox(0F, 0F, 0F, 9, 3, 1);
		this.Shape1.setRotationPoint(-4.5F, -3F - 2, -4.5F);
		this.Shape1.setTextureSize(64, 32);
		this.Shape1.mirror = true;
		setRotation(this.Shape1, 0F, 0F, 0F);
		convertToChild(this.google, this.Shape1);
		this.Shape2 = new ModelRenderer(this, 0, 4);
		this.Shape2.addBox(0F, 0F, 0F, 9, 2, 5);
		this.Shape2.setRotationPoint(-4.5F, -3F - 2, -3.5F);
		this.Shape2.setTextureSize(64, 32);
		this.Shape2.mirror = true;
		setRotation(this.Shape2, 0F, 0F, 0F);
		convertToChild(this.google, this.Shape2);
		this.Shape5 = new ModelRenderer(this, 26, 0);
		this.Shape5.addBox(0F, 0F, 0F, 2, 2, 1);
		this.Shape5.setRotationPoint(1F, -2.5F - 2, -5F);
		this.Shape5.setTextureSize(64, 32);
		this.Shape5.mirror = true;
		setRotation(this.Shape5, 0F, 0F, 0F);
		convertToChild(this.google, this.Shape5);
		this.Shape6 = new ModelRenderer(this, 20, 0);
		this.Shape6.addBox(0F, 0F, 0F, 2, 2, 1);
		this.Shape6.setRotationPoint(-3F, -2.5F - 2, -5F);
		this.Shape6.setTextureSize(64, 32);
		this.Shape6.mirror = true;
		setRotation(this.Shape6, 0F, 0F, 0F);
		convertToChild(this.google, this.Shape6);
		this.Shape7 = new ModelRenderer(this, 0, 11);
		this.Shape7.addBox(0F, 0F, 0F, 9, 1, 4);
		this.Shape7.setRotationPoint(-4.5F, -3F - 2, 0.5F);
		this.Shape7.setTextureSize(64, 32);
		this.Shape7.mirror = true;
		setRotation(this.Shape7, 0F, 0F, 0F);
		convertToChild(this.google, this.Shape7);
	}

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

		if(entity instanceof EntityPlayer) {
			EntityPlayer player = (EntityPlayer) entity;
			this.isSneak = player.isSneaking();
		}

		super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity);
		this.google.rotationPointX = this.bipedHead.rotationPointX;
		this.google.rotationPointY = this.bipedHead.rotationPointY;
		this.google.rotateAngleY = this.bipedHead.rotateAngleY;
		this.google.rotateAngleX = this.bipedHead.rotateAngleX;
	}

	@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();
		this.google.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;
	}
}
