    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.EntityOcelot;
    008import net.minecraft.util.MathHelper;
    009import org.lwjgl.opengl.GL11;
    010
    011@SideOnly(Side.CLIENT)
    012public class ModelOcelot extends ModelBase
    013{
    014    /** The back left leg model for the Ocelot. */
    015    ModelRenderer ocelotBackLeftLeg;
    016
    017    /** The back right leg model for the Ocelot. */
    018    ModelRenderer ocelotBackRightLeg;
    019
    020    /** The front left leg model for the Ocelot. */
    021    ModelRenderer ocelotFrontLeftLeg;
    022
    023    /** The front right leg model for the Ocelot. */
    024    ModelRenderer ocelotFrontRightLeg;
    025
    026    /** The tail model for the Ocelot. */
    027    ModelRenderer ocelotTail;
    028
    029    /** The second part of tail model for the Ocelot. */
    030    ModelRenderer ocelotTail2;
    031
    032    /** The head model for the Ocelot. */
    033    ModelRenderer ocelotHead;
    034
    035    /** The body model for the Ocelot. */
    036    ModelRenderer ocelotBody;
    037    int field_78163_i = 1;
    038
    039    public ModelOcelot()
    040    {
    041        this.setTextureOffset("head.main", 0, 0);
    042        this.setTextureOffset("head.nose", 0, 24);
    043        this.setTextureOffset("head.ear1", 0, 10);
    044        this.setTextureOffset("head.ear2", 6, 10);
    045        this.ocelotHead = new ModelRenderer(this, "head");
    046        this.ocelotHead.addBox("main", -2.5F, -2.0F, -3.0F, 5, 4, 5);
    047        this.ocelotHead.addBox("nose", -1.5F, 0.0F, -4.0F, 3, 2, 2);
    048        this.ocelotHead.addBox("ear1", -2.0F, -3.0F, 0.0F, 1, 1, 2);
    049        this.ocelotHead.addBox("ear2", 1.0F, -3.0F, 0.0F, 1, 1, 2);
    050        this.ocelotHead.setRotationPoint(0.0F, 15.0F, -9.0F);
    051        this.ocelotBody = new ModelRenderer(this, 20, 0);
    052        this.ocelotBody.addBox(-2.0F, 3.0F, -8.0F, 4, 16, 6, 0.0F);
    053        this.ocelotBody.setRotationPoint(0.0F, 12.0F, -10.0F);
    054        this.ocelotTail = new ModelRenderer(this, 0, 15);
    055        this.ocelotTail.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1);
    056        this.ocelotTail.rotateAngleX = 0.9F;
    057        this.ocelotTail.setRotationPoint(0.0F, 15.0F, 8.0F);
    058        this.ocelotTail2 = new ModelRenderer(this, 4, 15);
    059        this.ocelotTail2.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1);
    060        this.ocelotTail2.setRotationPoint(0.0F, 20.0F, 14.0F);
    061        this.ocelotBackLeftLeg = new ModelRenderer(this, 8, 13);
    062        this.ocelotBackLeftLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2);
    063        this.ocelotBackLeftLeg.setRotationPoint(1.1F, 18.0F, 5.0F);
    064        this.ocelotBackRightLeg = new ModelRenderer(this, 8, 13);
    065        this.ocelotBackRightLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2);
    066        this.ocelotBackRightLeg.setRotationPoint(-1.1F, 18.0F, 5.0F);
    067        this.ocelotFrontLeftLeg = new ModelRenderer(this, 40, 0);
    068        this.ocelotFrontLeftLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2);
    069        this.ocelotFrontLeftLeg.setRotationPoint(1.2F, 13.8F, -5.0F);
    070        this.ocelotFrontRightLeg = new ModelRenderer(this, 40, 0);
    071        this.ocelotFrontRightLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2);
    072        this.ocelotFrontRightLeg.setRotationPoint(-1.2F, 13.8F, -5.0F);
    073    }
    074
    075    /**
    076     * Sets the models various rotation angles then renders the model.
    077     */
    078    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    079    {
    080        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    081
    082        if (this.isChild)
    083        {
    084            float var8 = 2.0F;
    085            GL11.glPushMatrix();
    086            GL11.glScalef(1.5F / var8, 1.5F / var8, 1.5F / var8);
    087            GL11.glTranslatef(0.0F, 10.0F * par7, 4.0F * par7);
    088            this.ocelotHead.render(par7);
    089            GL11.glPopMatrix();
    090            GL11.glPushMatrix();
    091            GL11.glScalef(1.0F / var8, 1.0F / var8, 1.0F / var8);
    092            GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
    093            this.ocelotBody.render(par7);
    094            this.ocelotBackLeftLeg.render(par7);
    095            this.ocelotBackRightLeg.render(par7);
    096            this.ocelotFrontLeftLeg.render(par7);
    097            this.ocelotFrontRightLeg.render(par7);
    098            this.ocelotTail.render(par7);
    099            this.ocelotTail2.render(par7);
    100            GL11.glPopMatrix();
    101        }
    102        else
    103        {
    104            this.ocelotHead.render(par7);
    105            this.ocelotBody.render(par7);
    106            this.ocelotTail.render(par7);
    107            this.ocelotTail2.render(par7);
    108            this.ocelotBackLeftLeg.render(par7);
    109            this.ocelotBackRightLeg.render(par7);
    110            this.ocelotFrontLeftLeg.render(par7);
    111            this.ocelotFrontRightLeg.render(par7);
    112        }
    113    }
    114
    115    /**
    116     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    117     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    118     * "far" arms and legs can swing at most.
    119     */
    120    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
    121    {
    122        this.ocelotHead.rotateAngleX = par5 / (180F / (float)Math.PI);
    123        this.ocelotHead.rotateAngleY = par4 / (180F / (float)Math.PI);
    124
    125        if (this.field_78163_i != 3)
    126        {
    127            this.ocelotBody.rotateAngleX = ((float)Math.PI / 2F);
    128
    129            if (this.field_78163_i == 2)
    130            {
    131                this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2;
    132                this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + 0.3F) * 1.0F * par2;
    133                this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI + 0.3F) * 1.0F * par2;
    134                this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2;
    135                this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 10F) * MathHelper.cos(par1) * par2;
    136            }
    137            else
    138            {
    139                this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2;
    140                this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2;
    141                this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2;
    142                this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2;
    143
    144                if (this.field_78163_i == 1)
    145                {
    146                    this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 4F) * MathHelper.cos(par1) * par2;
    147                }
    148                else
    149                {
    150                    this.ocelotTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(par1) * par2;
    151                }
    152            }
    153        }
    154    }
    155
    156    /**
    157     * Used for easily adding entity-dependent animations. The second and third float params here are the same second
    158     * and third as in the setRotationAngles method.
    159     */
    160    public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4)
    161    {
    162        EntityOcelot var5 = (EntityOcelot)par1EntityLiving;
    163        this.ocelotBody.rotationPointY = 12.0F;
    164        this.ocelotBody.rotationPointZ = -10.0F;
    165        this.ocelotHead.rotationPointY = 15.0F;
    166        this.ocelotHead.rotationPointZ = -9.0F;
    167        this.ocelotTail.rotationPointY = 15.0F;
    168        this.ocelotTail.rotationPointZ = 8.0F;
    169        this.ocelotTail2.rotationPointY = 20.0F;
    170        this.ocelotTail2.rotationPointZ = 14.0F;
    171        this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 13.8F;
    172        this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -5.0F;
    173        this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 18.0F;
    174        this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 5.0F;
    175        this.ocelotTail.rotateAngleX = 0.9F;
    176
    177        if (var5.isSneaking())
    178        {
    179            ++this.ocelotBody.rotationPointY;
    180            this.ocelotHead.rotationPointY += 2.0F;
    181            ++this.ocelotTail.rotationPointY;
    182            this.ocelotTail2.rotationPointY += -4.0F;
    183            this.ocelotTail2.rotationPointZ += 2.0F;
    184            this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F);
    185            this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F);
    186            this.field_78163_i = 0;
    187        }
    188        else if (var5.isSprinting())
    189        {
    190            this.ocelotTail2.rotationPointY = this.ocelotTail.rotationPointY;
    191            this.ocelotTail2.rotationPointZ += 2.0F;
    192            this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F);
    193            this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F);
    194            this.field_78163_i = 2;
    195        }
    196        else if (var5.isSitting())
    197        {
    198            this.ocelotBody.rotateAngleX = ((float)Math.PI / 4F);
    199            this.ocelotBody.rotationPointY += -4.0F;
    200            this.ocelotBody.rotationPointZ += 5.0F;
    201            this.ocelotHead.rotationPointY += -3.3F;
    202            ++this.ocelotHead.rotationPointZ;
    203            this.ocelotTail.rotationPointY += 8.0F;
    204            this.ocelotTail.rotationPointZ += -2.0F;
    205            this.ocelotTail2.rotationPointY += 2.0F;
    206            this.ocelotTail2.rotationPointZ += -0.8F;
    207            this.ocelotTail.rotateAngleX = 1.7278761F;
    208            this.ocelotTail2.rotateAngleX = 2.670354F;
    209            this.ocelotFrontLeftLeg.rotateAngleX = this.ocelotFrontRightLeg.rotateAngleX = -0.15707964F;
    210            this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 15.8F;
    211            this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -7.0F;
    212            this.ocelotBackLeftLeg.rotateAngleX = this.ocelotBackRightLeg.rotateAngleX = -((float)Math.PI / 2F);
    213            this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 21.0F;
    214            this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 1.0F;
    215            this.field_78163_i = 3;
    216        }
    217        else
    218        {
    219            this.field_78163_i = 1;
    220        }
    221    }
    222}