// Date: 10.08.2018 10:17:16
// 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 ModelM65Blaze extends ModelBiped {

	public ModelRenderer mask;
	public ModelRenderer Shape1;
	public ModelRenderer Shape2;
	public ModelRenderer Shape3;
	public ModelRenderer Shape4;
	public ModelRenderer Shape5;
	public ModelRenderer Shape6;
	public ModelRenderer Shape7;
	public ModelRenderer Shape8;
	public ModelRenderer Shape9;
	public ModelRenderer Shape10;

	public ModelM65Blaze() {
		this.textureWidth = 32;
		this.textureHeight = 32;

		float yOffset = 4F;

		this.mask = new ModelRenderer(this, 0, 0);
		this.Shape1 = new ModelRenderer(this, 0, 0);
		this.Shape1.addBox(0F, 0F, 0F, 8, 8, 8);
		this.Shape1.setRotationPoint(-4F, -8F + yOffset, -4F);
		this.Shape1.setTextureSize(32, 32);
		this.Shape1.mirror = true;
		setRotation(this.Shape1, 0F, 0F, 0F);
		convertToChild(this.mask, this.Shape1);
		this.Shape2 = new ModelRenderer(this, 0, 16);
		this.Shape2.addBox(0F, 0F, 0F, 3, 3, 1);
		this.Shape2.setRotationPoint(-1.5F, -3.5F + yOffset, -5F);
		this.Shape2.setTextureSize(32, 32);
		this.Shape2.mirror = true;
		setRotation(this.Shape2, 0F, 0F, 0F);
		convertToChild(this.mask, this.Shape2);
		this.Shape3 = new ModelRenderer(this, 0, 20);
		this.Shape3.addBox(0F, -2F, 0F, 2, 2, 1);
		this.Shape3.setRotationPoint(-1F, -3.5F + yOffset, -5F);
		this.Shape3.setTextureSize(32, 32);
		this.Shape3.mirror = true;
		setRotation(this.Shape3, -0.4799655F, 0F, 0F);
		convertToChild(this.mask, this.Shape3);
		this.Shape4 = new ModelRenderer(this, 8, 16);
		this.Shape4.addBox(0F, 0F, -2F, 3, 2, 2);
		this.Shape4.setRotationPoint(-1.5F, -2F + yOffset, -4F);
		this.Shape4.setTextureSize(32, 32);
		this.Shape4.mirror = true;
		setRotation(this.Shape4, 0.6108652F, 0F, 0F);
		convertToChild(this.mask, this.Shape4);
		this.Shape5 = new ModelRenderer(this, 0, 23);
		this.Shape5.addBox(0F, 0F, 0F, 3, 3, 0);
		this.Shape5.setRotationPoint(-3.5F, -6F + yOffset, -4.2F);
		this.Shape5.setTextureSize(32, 32);
		this.Shape5.mirror = true;
		setRotation(this.Shape5, 0F, 0F, 0F);
		convertToChild(this.mask, this.Shape5);
		this.Shape6 = new ModelRenderer(this, 0, 26);
		this.Shape6.addBox(0F, 0F, 0F, 3, 3, 0);
		this.Shape6.setRotationPoint(0.5F, -6F + yOffset, -4.2F);
		this.Shape6.setTextureSize(32, 32);
		this.Shape6.mirror = true;
		setRotation(this.Shape6, 0F, 0F, 0F);
		convertToChild(this.mask, this.Shape6);
		this.Shape7 = new ModelRenderer(this, 6, 20);
		this.Shape7.addBox(0F, 0F, 0F, 2, 2, 1);
		this.Shape7.setRotationPoint(-1F, -3.2F + yOffset, -6F);
		this.Shape7.setTextureSize(32, 32);
		this.Shape7.mirror = true;
		setRotation(this.Shape7, 0F, 0F, 0F);
		convertToChild(this.mask, this.Shape7);
		this.Shape8 = new ModelRenderer(this, 6, 23);
		this.Shape8.addBox(0F, 0F, -3F, 2, 2, 1);
		this.Shape8.setRotationPoint(-1F, -2F + yOffset, -4F);
		this.Shape8.setTextureSize(32, 32);
		this.Shape8.mirror = true;
		setRotation(this.Shape8, 0.6108652F, 0F, 0F);
		convertToChild(this.mask, this.Shape8);
		this.Shape9 = new ModelRenderer(this, 18, 21);
		this.Shape9.addBox(0F, -1F, -5F, 3, 4, 2);
		this.Shape9.setRotationPoint(-1.5F, -2F + yOffset, -4F);
		this.Shape9.setTextureSize(32, 32);
		this.Shape9.mirror = true;
		setRotation(this.Shape9, 0.6108652F, 0F, 0F);
		convertToChild(this.mask, this.Shape9);
		this.Shape10 = new ModelRenderer(this, 18, 16);
		this.Shape10.addBox(0F, -0.5F, -5F, 4, 3, 2);
		this.Shape10.setRotationPoint(-2F, -2F + yOffset, -4F);
		this.Shape10.setTextureSize(32, 32);
		this.Shape10.mirror = true;
		setRotation(this.Shape10, 0.6108652F, 0F, 0F);
		convertToChild(this.mask, this.Shape10);
	}

	@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.mask.rotationPointX = this.bipedHead.rotationPointX;
		this.mask.rotationPointY = this.bipedHead.rotationPointY;
		this.mask.rotateAngleY = this.bipedHead.rotateAngleY;
		this.mask.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();
		double d = 1D / 16D * 18D;
		//GL11.glTranslated(0, 1/16D, 0);
		GL11.glScaled(d, d, d);
		GL11.glScaled(1.01D, 1.01D, 1.01D);
		this.mask.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;
	}
}
