package com.zivilon.cinder_loe.client.model;

import lotr.common.LOTRConfig;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;

public class ModelNex extends ModelBase {
  public ModelRenderer body;

  public ModelRenderer neck;

  public ModelRenderer head;

  public ModelRenderer rightArm;

  public ModelRenderer leftArm;

  public ModelRenderer rightLeg;

  public ModelRenderer leftLeg;

  public ModelRenderer tail;

  public ModelRenderer rightWing;

  public ModelRenderer leftWing;

  private boolean isFireModel;

  public int heldItemRight;

  public ModelNex() {
    this(0.0F);
  }

  public ModelNex(float f) {
    this.textureWidth = 128;
    this.textureHeight = 256;
    this.body = new ModelRenderer(this, 0, 38);
    this.body.setRotationPoint(0.0F, 7.0F, 3.0F);
    this.body.addBox(-8.0F, -15.0F, -6.0F, 16, 18, 12, f);
    this.body.setTextureOffset(0, 207);
    this.body.addBox(-9.0F, -6.5F, -7.0F, 7, 1, 14, f);
    this.body.addBox(-9.0F, -9.5F, -7.0F, 7, 1, 14, f);
    this.body.addBox(-9.0F, -12.5F, -7.0F, 7, 1, 14, f);
    this.body.mirror = true;
    this.body.addBox(2.0F, -6.5F, -7.0F, 7, 1, 14, f);
    this.body.addBox(2.0F, -9.5F, -7.0F, 7, 1, 14, f);
    this.body.addBox(2.0F, -12.5F, -7.0F, 7, 1, 14, f);
    this.body.mirror = false;
    this.body.setTextureOffset(0, 0).addBox(-9.0F, -29.0F, -7.0F, 18, 14, 15, f);
    this.body.setTextureOffset(81, 163).addBox(-2.0F, -21.0F, 5.5F, 4, 25, 2, f);
    this.neck = new ModelRenderer(this, 76, 0);
    this.neck.setRotationPoint(0.0F, -25.0F, -3.0F);
    this.neck.addBox(-6.0F, -5.0F, -10.0F, 12, 12, 14, f);
    this.body.addChild(this.neck);
    this.head = new ModelRenderer(this, 92, 48);
    this.head.setRotationPoint(0.0F, 0.0F, -10.0F);
    this.head.addBox(-4.0F, -6.0F, -6.0F, 8, 10, 7, f);
    this.head.setTextureOffset(57, 58).addBox(-6.0F, -7.0F, -4.0F, 12, 4, 4, f);
    this.head.rotateAngleX = (float)Math.toRadians(10.0D);
    this.neck.addChild(this.head);
    ModelRenderer rightHorn1 = new ModelRenderer(this, 57, 47);
    rightHorn1.setRotationPoint(-6.0F, -5.0F, -2.0F);
    rightHorn1.addBox(-7.0F, -1.5F, -1.5F, 8, 3, 3, f);
    rightHorn1.rotateAngleY = (float)Math.toRadians(-35.0D);
    this.head.addChild(rightHorn1);
    ModelRenderer rightHorn2 = new ModelRenderer(this, 57, 35);
    rightHorn2.setRotationPoint(-7.0F, 0.0F, 0.0F);
    rightHorn2.addBox(-1.0F, -1.0F, -6.0F, 2, 2, 6, f);
    rightHorn2.rotateAngleY = (float)Math.toRadians(45.0D);
    rightHorn1.addChild(rightHorn2);
    ModelRenderer leftHorn1 = new ModelRenderer(this, 57, 47);
    leftHorn1.setRotationPoint(6.0F, -5.0F, -2.0F);
    leftHorn1.mirror = true;
    leftHorn1.addBox(-1.0F, -1.5F, -1.5F, 8, 3, 3, f);
    leftHorn1.rotateAngleY = (float)Math.toRadians(35.0D);
    this.head.addChild(leftHorn1);
    ModelRenderer leftHorn2 = new ModelRenderer(this, 57, 35);
    leftHorn2.setRotationPoint(7.0F, 0.0F, 0.0F);
    leftHorn2.mirror = true;
    leftHorn2.addBox(-1.0F, -1.0F, -6.0F, 2, 2, 6, f);
    leftHorn2.rotateAngleY = (float)Math.toRadians(-45.0D);
    leftHorn1.addChild(leftHorn2);
    this.rightArm = new ModelRenderer(this, 59, 136);
    this.rightArm.setRotationPoint(-9.0F, -25.0F, 0.0F);
    this.rightArm.addBox(-7.0F, -2.0F, -4.0F, 7, 10, 8, f);
    this.rightArm.setTextureOffset(93, 136).addBox(-6.5F, 8.0F, -3.0F, 6, 16, 6, f);
    this.body.addChild(this.rightArm);
    this.leftArm = new ModelRenderer(this, 59, 136);
    this.leftArm.setRotationPoint(9.0F, -25.0F, 0.0F);
    this.leftArm.mirror = true;
    this.leftArm.addBox(0.0F, -2.0F, -4.0F, 7, 10, 8, f);
    this.leftArm.setTextureOffset(93, 136).addBox(0.5F, 8.0F, -3.0F, 6, 16, 6, f);
    this.body.addChild(this.leftArm);
    this.rightLeg = new ModelRenderer(this, 46, 230);
    this.rightLeg.setRotationPoint(-6.0F, 6.0F, 3.0F);
    this.rightLeg.addBox(-7.0F, -2.0F, -4.0F, 7, 9, 8, f);
    this.rightLeg.setTextureOffset(46, 208).addBox(-6.5F, 2.0F, 4.0F, 6, 13, 5, f);
    ModelRenderer rightFoot = new ModelRenderer(this, 0, 243);
    rightFoot.setRotationPoint(0.0F, 0.0F, 0.0F);
    rightFoot.addBox(-7.0F, 15.0F, -6.0F, 7, 3, 9, f);
    rightFoot.rotateAngleX = (float)Math.toRadians(25.0D);
    this.rightLeg.addChild(rightFoot);
    this.leftLeg = new ModelRenderer(this, 46, 230);
    this.leftLeg.setRotationPoint(6.0F, 6.0F, 3.0F);
    this.leftLeg.mirror = true;
    this.leftLeg.addBox(0.0F, -2.0F, -4.0F, 7, 9, 8, f);
    this.leftLeg.setTextureOffset(46, 208).addBox(0.5F, 2.0F, 4.0F, 6, 13, 5, f);
    ModelRenderer leftFoot = new ModelRenderer(this, 0, 243);
    leftFoot.setRotationPoint(0.0F, 0.0F, 0.0F);
    leftFoot.mirror = true;
    leftFoot.addBox(0.0F, 15.0F, -6.0F, 7, 3, 9, f);
    leftFoot.rotateAngleX = (float)Math.toRadians(25.0D);
    this.leftLeg.addChild(leftFoot);
    this.tail = new ModelRenderer(this, 79, 200);
    this.tail.setRotationPoint(0.0F, -3.0F, 3.0F);
    this.tail.addBox(-3.5F, -3.0F, 2.0F, 7, 7, 10, f);
    this.tail.setTextureOffset(80, 225).addBox(-2.5F, -2.5F, 11.0F, 5, 5, 14, f);
    this.tail.setTextureOffset(96, 175).addBox(-1.5F, -2.0F, 24.0F, 3, 3, 12, f);
    this.body.addChild(this.tail);
    this.rightWing = new ModelRenderer(this, 0, 137);
    this.rightWing.setRotationPoint(-6.0F, -27.0F, 4.0F);
    this.rightWing.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 25, f);
    this.rightWing.setTextureOffset(0, 167).addBox(-1.0F, -2.0F, 25.0F, 2, 24, 2, f);
    this.rightWing.setTextureOffset(0, 30).addBox(-0.5F, -7.0F, 25.5F, 1, 5, 1, f);
    this.rightWing.setTextureOffset(0, 69).addBox(0.0F, 0.0F, 0.0F, 0, 35, 25, f);
    this.body.addChild(this.rightWing);
    this.leftWing = new ModelRenderer(this, 0, 137);
    this.leftWing.setRotationPoint(6.0F, -27.0F, 4.0F);
    this.leftWing.mirror = true;
    this.leftWing.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 25, f);
    this.leftWing.setTextureOffset(0, 167).addBox(-1.0F, -2.0F, 25.0F, 2, 24, 2, f);
    this.leftWing.setTextureOffset(0, 30).addBox(-0.5F, -7.0F, 25.5F, 1, 5, 1, f);
    this.leftWing.setTextureOffset(0, 69).addBox(0.0F, 0.0F, 0.0F, 0, 35, 25, f);
    this.body.addChild(this.leftWing);
  }

  public void setFireModel() {
    this.isFireModel = true;
  }

  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    this.rightWing.showModel = true;
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    this.body.render(f5);
    this.rightLeg.render(f5);
    this.leftLeg.render(f5);
  }

  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
    this.neck.rotateAngleX = (float)Math.toRadians(-10.0D);
    this.neck.rotateAngleY = 0.0F;
    this.neck.rotateAngleX += f4 / (float)Math.toDegrees(1.0D);
    this.neck.rotateAngleY += f3 / (float)Math.toDegrees(1.0D);
    this.body.rotateAngleX = (float)Math.toRadians(10.0D);
    this.body.rotateAngleX += MathHelper.cos(f2 * 0.03F) * 0.15F;
    this.rightArm.rotateAngleX = 0.0F;
    this.leftArm.rotateAngleX = 0.0F;
    this.rightArm.rotateAngleZ = 0.0F;
    this.leftArm.rotateAngleZ = 0.0F;
    this.rightArm.rotateAngleX += MathHelper.cos(f * 0.4F + 3.1415927F) * 0.8F * f1;
    this.leftArm.rotateAngleX += MathHelper.cos(f * 0.4F) * 0.8F * f1;
    this.rightArm.rotateAngleZ += MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
    this.leftArm.rotateAngleZ -= MathHelper.cos(f2 * 0.09F) * 0.05F + 0.05F;
    if (this.onGround > -9990.0F) {
      float f6 = this.onGround;
      this.rightArm.rotateAngleY += this.body.rotateAngleY;
      this.leftArm.rotateAngleY += this.body.rotateAngleY;
      this.leftArm.rotateAngleX += this.body.rotateAngleY;
      f6 = 1.0F - this.onGround;
      f6 *= f6;
      f6 *= f6;
      f6 = 1.0F - f6;
      float f7 = MathHelper.sin(f6 * 3.1415927F);
      float f8 = MathHelper.sin(this.onGround * 3.1415927F) * -(this.head.rotateAngleX - 0.7F) * 0.75F;
      this.rightArm.rotateAngleX = (float)(this.rightArm.rotateAngleX - f7 * 1.2D + f8);
      this.rightArm.rotateAngleY += this.body.rotateAngleY * 2.0F;
      this.rightArm.rotateAngleZ = MathHelper.sin(this.onGround * 3.1415927F) * -0.4F;
    }
    if (this.heldItemRight != 0)
      this.rightArm.rotateAngleX = this.rightArm.rotateAngleX * 0.5F - 0.31415927F * this.heldItemRight;
    this.rightLeg.rotateAngleX = (float)Math.toRadians(-25.0D);
    this.leftLeg.rotateAngleX = (float)Math.toRadians(-25.0D);
    this.rightLeg.rotateAngleX += MathHelper.sin(f * 0.4F) * 1.2F * f1;
    this.leftLeg.rotateAngleX += MathHelper.sin(f * 0.4F + 3.1415927F) * 1.2F * f1;
    this.rightWing.rotateAngleX = (float)Math.toRadians(40.0D);
    this.leftWing.rotateAngleX = (float)Math.toRadians(40.0D);
    this.rightWing.rotateAngleY = (float)Math.toRadians(-40.0D);
    this.leftWing.rotateAngleY = (float)Math.toRadians(40.0D);
    this.rightWing.rotateAngleY += MathHelper.cos(f2 * 0.04F) * 0.5F;
    this.leftWing.rotateAngleY -= MathHelper.cos(f2 * 0.04F) * 0.5F;
    this.tail.rotateAngleX = (float)Math.toRadians(-40.0D);
    this.tail.rotateAngleY = 0.0F;
    this.tail.rotateAngleY += MathHelper.cos(f2 * 0.05F) * 0.15F;
    this.tail.rotateAngleY += MathHelper.sin(f * 0.1F) * 0.6F * f1;
  }
}
