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