    001package net.minecraft.client.model;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.entity.Entity;
    006import net.minecraft.entity.EntityLiving;
    007import net.minecraft.entity.boss.EntityWither;
    008import net.minecraft.util.MathHelper;
    009
    010@SideOnly(Side.CLIENT)
    011public class ModelWither extends ModelBase
    012{
    013    private ModelRenderer[] field_82905_a;
    014    private ModelRenderer[] field_82904_b;
    015
    016    public ModelWither()
    017    {
    018        this.textureWidth = 64;
    019        this.textureHeight = 64;
    020        this.field_82905_a = new ModelRenderer[3];
    021        this.field_82905_a[0] = new ModelRenderer(this, 0, 16);
    022        this.field_82905_a[0].addBox(-10.0F, 3.9F, -0.5F, 20, 3, 3);
    023        this.field_82905_a[1] = (new ModelRenderer(this)).setTextureSize(this.textureWidth, this.textureHeight);
    024        this.field_82905_a[1].setRotationPoint(-2.0F, 6.9F, -0.5F);
    025        this.field_82905_a[1].setTextureOffset(0, 22).addBox(0.0F, 0.0F, 0.0F, 3, 10, 3);
    026        this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 1.5F, 0.5F, 11, 2, 2);
    027        this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 4.0F, 0.5F, 11, 2, 2);
    028        this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 6.5F, 0.5F, 11, 2, 2);
    029        this.field_82905_a[2] = new ModelRenderer(this, 12, 22);
    030        this.field_82905_a[2].addBox(0.0F, 0.0F, 0.0F, 3, 6, 3);
    031        this.field_82904_b = new ModelRenderer[3];
    032        this.field_82904_b[0] = new ModelRenderer(this, 0, 0);
    033        this.field_82904_b[0].addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8);
    034        this.field_82904_b[1] = new ModelRenderer(this, 32, 0);
    035        this.field_82904_b[1].addBox(-4.0F, -4.0F, -4.0F, 6, 6, 6);
    036        this.field_82904_b[1].rotationPointX = -8.0F;
    037        this.field_82904_b[1].rotationPointY = 4.0F;
    038        this.field_82904_b[2] = new ModelRenderer(this, 32, 0);
    039        this.field_82904_b[2].addBox(-4.0F, -4.0F, -4.0F, 6, 6, 6);
    040        this.field_82904_b[2].rotationPointX = 10.0F;
    041        this.field_82904_b[2].rotationPointY = 4.0F;
    042    }
    043
    044    public int func_82903_a()
    045    {
    046        return 32;
    047    }
    048
    049    /**
    050     * Sets the models various rotation angles then renders the model.
    051     */
    052    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    053    {
    054        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    055        ModelRenderer[] amodelrenderer = this.field_82904_b;
    056        int i = amodelrenderer.length;
    057        int j;
    058        ModelRenderer modelrenderer;
    059
    060        for (j = 0; j < i; ++j)
    061        {
    062            modelrenderer = amodelrenderer[j];
    063            modelrenderer.render(par7);
    064        }
    065
    066        amodelrenderer = this.field_82905_a;
    067        i = amodelrenderer.length;
    068
    069        for (j = 0; j < i; ++j)
    070        {
    071            modelrenderer = amodelrenderer[j];
    072            modelrenderer.render(par7);
    073        }
    074    }
    075
    076    /**
    077     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    078     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    079     * "far" arms and legs can swing at most.
    080     */
    081    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
    082    {
    083        float f6 = MathHelper.cos(par3 * 0.1F);
    084        this.field_82905_a[1].rotateAngleX = (0.065F + 0.05F * f6) * (float)Math.PI;
    085        this.field_82905_a[2].setRotationPoint(-2.0F, 6.9F + MathHelper.cos(this.field_82905_a[1].rotateAngleX) * 10.0F, -0.5F + MathHelper.sin(this.field_82905_a[1].rotateAngleX) * 10.0F);
    086        this.field_82905_a[2].rotateAngleX = (0.265F + 0.1F * f6) * (float)Math.PI;
    087        this.field_82904_b[0].rotateAngleY = par4 / (180F / (float)Math.PI);
    088        this.field_82904_b[0].rotateAngleX = par5 / (180F / (float)Math.PI);
    089    }
    090
    091    /**
    092     * Used for easily adding entity-dependent animations. The second and third float params here are the same second
    093     * and third as in the setRotationAngles method.
    094     */
    095    public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4)
    096    {
    097        EntityWither entitywither = (EntityWither)par1EntityLiving;
    098
    099        for (int i = 1; i < 3; ++i)
    100        {
    101            this.field_82904_b[i].rotateAngleY = (entitywither.func_82207_a(i - 1) - par1EntityLiving.renderYawOffset) / (180F / (float)Math.PI);
    102            this.field_82904_b[i].rotateAngleX = entitywither.func_82210_r(i - 1) / (180F / (float)Math.PI);
    103        }
    104    }
    105}