    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import org.lwjgl.opengl.GL11;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class ModelWolf extends ModelBase
    009    {
    010        /** main box for the wolf head */
    011        public ModelRenderer wolfHeadMain;
    012
    013        /** The wolf's body */
    014        public ModelRenderer wolfBody;
    015
    016        /** Wolf'se first leg */
    017        public ModelRenderer wolfLeg1;
    018
    019        /** Wolf's second leg */
    020        public ModelRenderer wolfLeg2;
    021
    022        /** Wolf's third leg */
    023        public ModelRenderer wolfLeg3;
    024
    025        /** Wolf's fourth leg */
    026        public ModelRenderer wolfLeg4;
    027
    028        /** The wolf's tail */
    029        ModelRenderer wolfTail;
    030
    031        /** The wolf's mane */
    032        ModelRenderer wolfMane;
    033
    034        public ModelWolf()
    035        {
    036            float var1 = 0.0F;
    037            float var2 = 13.5F;
    038            this.wolfHeadMain = new ModelRenderer(this, 0, 0);
    039            this.wolfHeadMain.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, var1);
    040            this.wolfHeadMain.setRotationPoint(-1.0F, var2, -7.0F);
    041            this.wolfBody = new ModelRenderer(this, 18, 14);
    042            this.wolfBody.addBox(-4.0F, -2.0F, -3.0F, 6, 9, 6, var1);
    043            this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F);
    044            this.wolfMane = new ModelRenderer(this, 21, 0);
    045            this.wolfMane.addBox(-4.0F, -3.0F, -3.0F, 8, 6, 7, var1);
    046            this.wolfMane.setRotationPoint(-1.0F, 14.0F, 2.0F);
    047            this.wolfLeg1 = new ModelRenderer(this, 0, 18);
    048            this.wolfLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, var1);
    049            this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F);
    050            this.wolfLeg2 = new ModelRenderer(this, 0, 18);
    051            this.wolfLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, var1);
    052            this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F);
    053            this.wolfLeg3 = new ModelRenderer(this, 0, 18);
    054            this.wolfLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, var1);
    055            this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F);
    056            this.wolfLeg4 = new ModelRenderer(this, 0, 18);
    057            this.wolfLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, var1);
    058            this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F);
    059            this.wolfTail = new ModelRenderer(this, 9, 18);
    060            this.wolfTail.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, var1);
    061            this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F);
    062            this.wolfHeadMain.setTextureOffset(16, 14).addBox(-3.0F, -5.0F, 0.0F, 2, 2, 1, var1);
    063            this.wolfHeadMain.setTextureOffset(16, 14).addBox(1.0F, -5.0F, 0.0F, 2, 2, 1, var1);
    064            this.wolfHeadMain.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 3, 4, var1);
    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            super.render(par1Entity, par2, par3, par4, par5, par6, par7);
    073            this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    074
    075            if (this.isChild)
    076            {
    077                float var8 = 2.0F;
    078                GL11.glPushMatrix();
    079                GL11.glTranslatef(0.0F, 5.0F * par7, 2.0F * par7);
    080                this.wolfHeadMain.renderWithRotation(par7);
    081                GL11.glPopMatrix();
    082                GL11.glPushMatrix();
    083                GL11.glScalef(1.0F / var8, 1.0F / var8, 1.0F / var8);
    084                GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
    085                this.wolfBody.render(par7);
    086                this.wolfLeg1.render(par7);
    087                this.wolfLeg2.render(par7);
    088                this.wolfLeg3.render(par7);
    089                this.wolfLeg4.render(par7);
    090                this.wolfTail.renderWithRotation(par7);
    091                this.wolfMane.render(par7);
    092                GL11.glPopMatrix();
    093            }
    094            else
    095            {
    096                this.wolfHeadMain.renderWithRotation(par7);
    097                this.wolfBody.render(par7);
    098                this.wolfLeg1.render(par7);
    099                this.wolfLeg2.render(par7);
    100                this.wolfLeg3.render(par7);
    101                this.wolfLeg4.render(par7);
    102                this.wolfTail.renderWithRotation(par7);
    103                this.wolfMane.render(par7);
    104            }
    105        }
    106
    107        /**
    108         * Used for easily adding entity-dependent animations. The second and third float params here are the same second
    109         * and third as in the setRotationAngles method.
    110         */
    111        public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4)
    112        {
    113            EntityWolf var5 = (EntityWolf)par1EntityLiving;
    114
    115            if (var5.isAngry())
    116            {
    117                this.wolfTail.rotateAngleY = 0.0F;
    118            }
    119            else
    120            {
    121                this.wolfTail.rotateAngleY = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
    122            }
    123
    124            if (var5.isSitting())
    125            {
    126                this.wolfMane.setRotationPoint(-1.0F, 16.0F, -3.0F);
    127                this.wolfMane.rotateAngleX = ((float)Math.PI * 2F / 5F);
    128                this.wolfMane.rotateAngleY = 0.0F;
    129                this.wolfBody.setRotationPoint(0.0F, 18.0F, 0.0F);
    130                this.wolfBody.rotateAngleX = ((float)Math.PI / 4F);
    131                this.wolfTail.setRotationPoint(-1.0F, 21.0F, 6.0F);
    132                this.wolfLeg1.setRotationPoint(-2.5F, 22.0F, 2.0F);
    133                this.wolfLeg1.rotateAngleX = ((float)Math.PI * 3F / 2F);
    134                this.wolfLeg2.setRotationPoint(0.5F, 22.0F, 2.0F);
    135                this.wolfLeg2.rotateAngleX = ((float)Math.PI * 3F / 2F);
    136                this.wolfLeg3.rotateAngleX = 5.811947F;
    137                this.wolfLeg3.setRotationPoint(-2.49F, 17.0F, -4.0F);
    138                this.wolfLeg4.rotateAngleX = 5.811947F;
    139                this.wolfLeg4.setRotationPoint(0.51F, 17.0F, -4.0F);
    140            }
    141            else
    142            {
    143                this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F);
    144                this.wolfBody.rotateAngleX = ((float)Math.PI / 2F);
    145                this.wolfMane.setRotationPoint(-1.0F, 14.0F, -3.0F);
    146                this.wolfMane.rotateAngleX = this.wolfBody.rotateAngleX;
    147                this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F);
    148                this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F);
    149                this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F);
    150                this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F);
    151                this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F);
    152                this.wolfLeg1.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
    153                this.wolfLeg2.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3;
    154                this.wolfLeg3.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3;
    155                this.wolfLeg4.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
    156            }
    157
    158            this.wolfHeadMain.rotateAngleZ = var5.getInterestedAngle(par4) + var5.getShakeAngle(par4, 0.0F);
    159            this.wolfMane.rotateAngleZ = var5.getShakeAngle(par4, -0.08F);
    160            this.wolfBody.rotateAngleZ = var5.getShakeAngle(par4, -0.16F);
    161            this.wolfTail.rotateAngleZ = var5.getShakeAngle(par4, -0.2F);
    162        }
    163
    164        /**
    165         * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    166         * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    167         * "far" arms and legs can swing at most.
    168         */
    169        public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
    170        {
    171            super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity);
    172            this.wolfHeadMain.rotateAngleX = par5 / (180F / (float)Math.PI);
    173            this.wolfHeadMain.rotateAngleY = par4 / (180F / (float)Math.PI);
    174            this.wolfTail.rotateAngleX = par3;
    175        }
    176    }