001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    
006    @SideOnly(Side.CLIENT)
007    public class ModelIronGolem extends ModelBase
008    {
009        /** The head model for the iron golem. */
010        public ModelRenderer ironGolemHead;
011    
012        /** The body model for the iron golem. */
013        public ModelRenderer ironGolemBody;
014    
015        /** The right arm model for the iron golem. */
016        public ModelRenderer ironGolemRightArm;
017    
018        /** The left arm model for the iron golem. */
019        public ModelRenderer ironGolemLeftArm;
020        public ModelRenderer field_78175_e;
021        public ModelRenderer field_78173_f;
022    
023        public ModelIronGolem()
024        {
025            this(0.0F);
026        }
027    
028        public ModelIronGolem(float par1)
029        {
030            this(par1, -7.0F);
031        }
032    
033        public ModelIronGolem(float par1, float par2)
034        {
035            short var3 = 128;
036            short var4 = 128;
037            this.ironGolemHead = (new ModelRenderer(this)).setTextureSize(var3, var4);
038            this.ironGolemHead.setRotationPoint(0.0F, 0.0F + par2, -2.0F);
039            this.ironGolemHead.setTextureOffset(0, 0).addBox(-4.0F, -12.0F, -5.5F, 8, 10, 8, par1);
040            this.ironGolemHead.setTextureOffset(24, 0).addBox(-1.0F, -5.0F, -7.5F, 2, 4, 2, par1);
041            this.ironGolemBody = (new ModelRenderer(this)).setTextureSize(var3, var4);
042            this.ironGolemBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
043            this.ironGolemBody.setTextureOffset(0, 40).addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, par1);
044            this.ironGolemBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, par1 + 0.5F);
045            this.ironGolemRightArm = (new ModelRenderer(this)).setTextureSize(var3, var4);
046            this.ironGolemRightArm.setRotationPoint(0.0F, -7.0F, 0.0F);
047            this.ironGolemRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, par1);
048            this.ironGolemLeftArm = (new ModelRenderer(this)).setTextureSize(var3, var4);
049            this.ironGolemLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F);
050            this.ironGolemLeftArm.setTextureOffset(60, 58).addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, par1);
051            this.field_78175_e = (new ModelRenderer(this, 0, 22)).setTextureSize(var3, var4);
052            this.field_78175_e.setRotationPoint(-4.0F, 18.0F + par2, 0.0F);
053            this.field_78175_e.setTextureOffset(37, 0).addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1);
054            this.field_78173_f = (new ModelRenderer(this, 0, 22)).setTextureSize(var3, var4);
055            this.field_78173_f.mirror = true;
056            this.field_78173_f.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + par2, 0.0F);
057            this.field_78173_f.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1);
058        }
059    
060        /**
061         * Sets the models various rotation angles then renders the model.
062         */
063        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
064        {
065            this.setRotationAngles(par2, par3, par4, par5, par6, par7);
066            this.ironGolemHead.render(par7);
067            this.ironGolemBody.render(par7);
068            this.field_78175_e.render(par7);
069            this.field_78173_f.render(par7);
070            this.ironGolemRightArm.render(par7);
071            this.ironGolemLeftArm.render(par7);
072        }
073    
074        /**
075         * Sets the models various rotation angles.
076         */
077        public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6)
078        {
079            this.ironGolemHead.rotateAngleY = par4 / (180F / (float)Math.PI);
080            this.ironGolemHead.rotateAngleX = par5 / (180F / (float)Math.PI);
081            this.field_78175_e.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2;
082            this.field_78173_f.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2;
083            this.field_78175_e.rotateAngleY = 0.0F;
084            this.field_78173_f.rotateAngleY = 0.0F;
085        }
086    
087        /**
088         * Used for easily adding entity-dependent animations. The second and third float params here are the same second
089         * and third as in the setRotationAngles method.
090         */
091        public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4)
092        {
093            EntityIronGolem var5 = (EntityIronGolem)par1EntityLiving;
094            int var6 = var5.getAttackTimer();
095    
096            if (var6 > 0)
097            {
098                this.ironGolemRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)var6 - par4, 10.0F);
099                this.ironGolemLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)var6 - par4, 10.0F);
100            }
101            else
102            {
103                int var7 = var5.getHoldRoseTick();
104    
105                if (var7 > 0)
106                {
107                    this.ironGolemRightArm.rotateAngleX = -0.8F + 0.025F * this.func_78172_a((float)var7, 70.0F);
108                    this.ironGolemLeftArm.rotateAngleX = 0.0F;
109                }
110                else
111                {
112                    this.ironGolemRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par2, 13.0F)) * par3;
113                    this.ironGolemLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par2, 13.0F)) * par3;
114                }
115            }
116        }
117    
118        private float func_78172_a(float par1, float par2)
119        {
120            return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F);
121        }
122    }