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