/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Zoe Lee (Kihira)
 *
 * See LICENSE for full License
 */

package kihira.tails.client.model;

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

public class ModelRaccoonTail extends ModelTailBase {

    private ModelRenderer tailBase;
    private ModelRenderer tail1;
    private ModelRenderer tail2;
    private ModelRenderer tailTip;

    public ModelRaccoonTail() {
        this.tailBase = new ModelRenderer(this, 12, 16);
        this.tailBase.addBox(-1F, -1F, 0F, 2, 2, 2);
        this.tailBase.setRotationPoint(0F, 0F, 0F);

        this.tail1 = new ModelRenderer(this, 0, 16);
        this.tail1.addBox(-1.5F, -1.5F, 0F, 3, 3, 3);
        this.tail1.setRotationPoint(0F, 0F, 1F);
        this.setRotationDegrees(this.tail1, -40F, 0F, 0F);

        this.tail2 = new ModelRenderer(this, 0, 0);
        this.tail2.addBox(-2F, -2F, 0F, 4, 4, 12);
        this.tail2.setRotationPoint(0F, 0F, 2F);
        this.setRotationDegrees(this.tail2, -30F, 0F, 0F);

        this.tailTip = new ModelRenderer(this, 0, 22);
        this.tailTip.addBox(-1.5F, -1.5F, 0F, 3, 3, 1);
        this.tailTip.setRotationPoint(0F, 0F, 12F);

        this.tail2.addChild(this.tailTip);
        this.tail1.addChild(this.tail2);
        this.tailBase.addChild(this.tail1);
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        float seed = this.getAnimationTime(8000, entity);

        this.tailBase.rotateAngleY = (float) (Math.cos(seed - 1) / 15F);
        this.tail1.rotateAngleY = (float) (Math.cos(seed - 2) / 15F);
        this.tail2.rotateAngleY = (float) (Math.cos(seed - 3) / 15F);
    }

    @Override
    public void render(EntityLivingBase theEntity, int subtype, float partialTicks) {
        this.setRotationAngles(0, 0, 0, 0, 0, 0, theEntity);

        this.tailBase.render(0.0625F);
    }
}
@@ -269,16 +269,103 @@
 ingBase;
+%0Aimport net.minecraft.entity.player.EntityPlayer;%0Aimport net.minecraft.util.MathHelper;
 %0A%0Apublic
@@ -1590,17 +1590,25 @@
 loat par
-6
+tialTicks
 , Entity
@@ -1632,20 +1632,24 @@
   float 
-seed
+timestep
  = this.
@@ -1684,125 +1684,1098 @@
 y);%0A
-%0A        this.tailBase.rotateAngleY = (float) (Math.cos(seed - 1) / 15F);%0A        this.tail1.rotateAngleY = (float) (
+        double xAngleOffset = 0;%0A        double yAngleOffset = 0;%0A        double zAngleOffset = 0;%0A        double yAngleMultiplier = 0; //Used to suppress sway when running%0A%0A        if (entity instanceof EntityPlayer) %7B%0A            if (!entity.isRiding()) %7B%0A                double%5B%5D angles = getMotionAngles((EntityPlayer) entity, partialTicks);%0A%0A                xAngleOffset = angles%5B0%5D;%0A                yAngleOffset = angles%5B1%5D;%0A                zAngleOffset = angles%5B2%5D;%0A                yAngleMultiplier = (1 - (xAngleOffset * 2F)); //Used to suppress sway when running%0A%0A                xAngleOffset = MathHelper.clamp_double(xAngleOffset * 0.6D, -1D, 0.45D);%0A                zAngleOffset = MathHelper.clamp_double(zAngleOffset * 0.5D, -0.5D, 0.5D);%0A            %7D%0A            //Mounted%0A            else %7B%0A                xAngleOffset = Math.toRadians(20F);%0A                yAngleMultiplier = 0.2F;%0A            %7D%0A        %7D%0A        else %7B%0A            yAngleMultiplier = 1F; //Used to suppress sway when running%0A        %7D%0A%0A        setRotationRadians(tailBase, xAngleOffset, (-zAngleOffset + 
 Math
@@ -2783,69 +2783,347 @@
 cos(
-seed - 2
+timestep - 1
 ) / 15F
-);%0A        this.tail2.rotateAngleY = (float) (
+ + yAngleOffset) * yAngleMultiplier, -zAngleOffset / 4F);%0A        setRotationRadians(tail1, Math.toRadians(-40F) + xAngleOffset, (-zAngleOffset + Math.cos(timestep - 1) / 15F + yAngleOffset) * yAngleMultiplier, -zAngleOffset / 4F);%0A        setRotationRadians(tail2, Math.toRadians(-30F) + xAngleOffset, (-zAngleOffset + 
 Math
@@ -3131,23 +3131,82 @@
 cos(
-seed - 3
+timestep - 1
 ) / 15F
+ + yAngleOffset) * yAngleMultiplier, -zAngleOffset / 4F
 );%0A 
@@ -3357,17 +3357,28 @@
 , 0, 0, 
-0
+partialTicks
 , theEnt

Add in movement animation for raccoon tail