    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.util.MathHelper;
    007import org.lwjgl.opengl.GL11;
    008
    009@SideOnly(Side.CLIENT)
    010public class ModelQuadruped extends ModelBase
    011{
    012    public ModelRenderer head = new ModelRenderer(this, 0, 0);
    013    public ModelRenderer body;
    014    public ModelRenderer leg1;
    015    public ModelRenderer leg2;
    016    public ModelRenderer leg3;
    017    public ModelRenderer leg4;
    018    protected float field_78145_g = 8.0F;
    019    protected float field_78151_h = 4.0F;
    020
    021    public ModelQuadruped(int par1, float par2)
    022    {
    023        this.head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, par2);
    024        this.head.setRotationPoint(0.0F, (float)(18 - par1), -6.0F);
    025        this.body = new ModelRenderer(this, 28, 8);
    026        this.body.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, par2);
    027        this.body.setRotationPoint(0.0F, (float)(17 - par1), 2.0F);
    028        this.leg1 = new ModelRenderer(this, 0, 16);
    029        this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    030        this.leg1.setRotationPoint(-3.0F, (float)(24 - par1), 7.0F);
    031        this.leg2 = new ModelRenderer(this, 0, 16);
    032        this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    033        this.leg2.setRotationPoint(3.0F, (float)(24 - par1), 7.0F);
    034        this.leg3 = new ModelRenderer(this, 0, 16);
    035        this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    036        this.leg3.setRotationPoint(-3.0F, (float)(24 - par1), -5.0F);
    037        this.leg4 = new ModelRenderer(this, 0, 16);
    038        this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2);
    039        this.leg4.setRotationPoint(3.0F, (float)(24 - par1), -5.0F);
    040    }
    041
    042    /**
    043     * Sets the models various rotation angles then renders the model.
    044     */
    045    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    046    {
    047        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    048
    049        if (this.isChild)
    050        {
    051            float var8 = 2.0F;
    052            GL11.glPushMatrix();
    053            GL11.glTranslatef(0.0F, this.field_78145_g * par7, this.field_78151_h * par7);
    054            this.head.render(par7);
    055            GL11.glPopMatrix();
    056            GL11.glPushMatrix();
    057            GL11.glScalef(1.0F / var8, 1.0F / var8, 1.0F / var8);
    058            GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
    059            this.body.render(par7);
    060            this.leg1.render(par7);
    061            this.leg2.render(par7);
    062            this.leg3.render(par7);
    063            this.leg4.render(par7);
    064            GL11.glPopMatrix();
    065        }
    066        else
    067        {
    068            this.head.render(par7);
    069            this.body.render(par7);
    070            this.leg1.render(par7);
    071            this.leg2.render(par7);
    072            this.leg3.render(par7);
    073            this.leg4.render(par7);
    074        }
    075    }
    076
    077    /**
    078     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    079     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    080     * "far" arms and legs can swing at most.
    081     */
    082    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
    083    {
    084        this.head.rotateAngleX = par5 / (180F / (float)Math.PI);
    085        this.head.rotateAngleY = par4 / (180F / (float)Math.PI);
    086        this.body.rotateAngleX = ((float)Math.PI / 2F);
    087        this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
    088        this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;
    089        this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;
    090        this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
    091    }
    092}