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.monster.EntityIronGolem;
008
009@SideOnly(Side.CLIENT)
010public class ModelIronGolem extends ModelBase
011{
012    /** The head model for the iron golem. */
013    public ModelRenderer ironGolemHead;
014
015    /** The body model for the iron golem. */
016    public ModelRenderer ironGolemBody;
017
018    /** The right arm model for the iron golem. */
019    public ModelRenderer ironGolemRightArm;
020
021    /** The left arm model for the iron golem. */
022    public ModelRenderer ironGolemLeftArm;
023
024    /** The left leg model for the Iron Golem. */
025    public ModelRenderer ironGolemLeftLeg;
026
027    /** The right leg model for the Iron Golem. */
028    public ModelRenderer ironGolemRightLeg;
029
030    public ModelIronGolem()
031    {
032        this(0.0F);
033    }
034
035    public ModelIronGolem(float par1)
036    {
037        this(par1, -7.0F);
038    }
039
040    public ModelIronGolem(float par1, float par2)
041    {
042        short short1 = 128;
043        short short2 = 128;
044        this.ironGolemHead = (new ModelRenderer(this)).setTextureSize(short1, short2);
045        this.ironGolemHead.setRotationPoint(0.0F, 0.0F + par2, -2.0F);
046        this.ironGolemHead.setTextureOffset(0, 0).addBox(-4.0F, -12.0F, -5.5F, 8, 10, 8, par1);
047        this.ironGolemHead.setTextureOffset(24, 0).addBox(-1.0F, -5.0F, -7.5F, 2, 4, 2, par1);
048        this.ironGolemBody = (new ModelRenderer(this)).setTextureSize(short1, short2);
049        this.ironGolemBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
050        this.ironGolemBody.setTextureOffset(0, 40).addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, par1);
051        this.ironGolemBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, par1 + 0.5F);
052        this.ironGolemRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2);
053        this.ironGolemRightArm.setRotationPoint(0.0F, -7.0F, 0.0F);
054        this.ironGolemRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, par1);
055        this.ironGolemLeftArm = (new ModelRenderer(this)).setTextureSize(short1, short2);
056        this.ironGolemLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F);
057        this.ironGolemLeftArm.setTextureOffset(60, 58).addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, par1);
058        this.ironGolemLeftLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2);
059        this.ironGolemLeftLeg.setRotationPoint(-4.0F, 18.0F + par2, 0.0F);
060        this.ironGolemLeftLeg.setTextureOffset(37, 0).addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1);
061        this.ironGolemRightLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2);
062        this.ironGolemRightLeg.mirror = true;
063        this.ironGolemRightLeg.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + par2, 0.0F);
064        this.ironGolemRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1);
065    }
066
067    /**
068     * Sets the models various rotation angles then renders the model.
069     */
070    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
071    {
072        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
073        this.ironGolemHead.render(par7);
074        this.ironGolemBody.render(par7);
075        this.ironGolemLeftLeg.render(par7);
076        this.ironGolemRightLeg.render(par7);
077        this.ironGolemRightArm.render(par7);
078        this.ironGolemLeftArm.render(par7);
079    }
080
081    /**
082     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
083     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
084     * "far" arms and legs can swing at most.
085     */
086    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
087    {
088        this.ironGolemHead.rotateAngleY = par4 / (180F / (float)Math.PI);
089        this.ironGolemHead.rotateAngleX = par5 / (180F / (float)Math.PI);
090        this.ironGolemLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2;
091        this.ironGolemRightLeg.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2;
092        this.ironGolemLeftLeg.rotateAngleY = 0.0F;
093        this.ironGolemRightLeg.rotateAngleY = 0.0F;
094    }
095
096    /**
097     * Used for easily adding entity-dependent animations. The second and third float params here are the same second
098     * and third as in the setRotationAngles method.
099     */
100    public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4)
101    {
102        EntityIronGolem entityirongolem = (EntityIronGolem)par1EntityLiving;
103        int i = entityirongolem.getAttackTimer();
104
105        if (i > 0)
106        {
107            this.ironGolemRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F);
108            this.ironGolemLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F);
109        }
110        else
111        {
112            int j = entityirongolem.getHoldRoseTick();
113
114            if (j > 0)
115            {
116                this.ironGolemRightArm.rotateAngleX = -0.8F + 0.025F * this.func_78172_a((float)j, 70.0F);
117                this.ironGolemLeftArm.rotateAngleX = 0.0F;
118            }
119            else
120            {
121                this.ironGolemRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par2, 13.0F)) * par3;
122                this.ironGolemLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par2, 13.0F)) * par3;
123            }
124        }
125    }
126
127    private float func_78172_a(float par1, float par2)
128    {
129        return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F);
130    }
131}