    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;
    007
    008@SideOnly(Side.CLIENT)
    009public class ModelSpider extends ModelBase
    010{
    011    /** The spider's head box */
    012    public ModelRenderer spiderHead;
    013
    014    /** The spider's neck box */
    015    public ModelRenderer spiderNeck;
    016
    017    /** The spider's body box */
    018    public ModelRenderer spiderBody;
    019
    020    /** Spider's first leg */
    021    public ModelRenderer spiderLeg1;
    022
    023    /** Spider's second leg */
    024    public ModelRenderer spiderLeg2;
    025
    026    /** Spider's third leg */
    027    public ModelRenderer spiderLeg3;
    028
    029    /** Spider's fourth leg */
    030    public ModelRenderer spiderLeg4;
    031
    032    /** Spider's fifth leg */
    033    public ModelRenderer spiderLeg5;
    034
    035    /** Spider's sixth leg */
    036    public ModelRenderer spiderLeg6;
    037
    038    /** Spider's seventh leg */
    039    public ModelRenderer spiderLeg7;
    040
    041    /** Spider's eight leg */
    042    public ModelRenderer spiderLeg8;
    043
    044    public ModelSpider()
    045    {
    046        float f = 0.0F;
    047        byte b0 = 15;
    048        this.spiderHead = new ModelRenderer(this, 32, 4);
    049        this.spiderHead.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, f);
    050        this.spiderHead.setRotationPoint(0.0F, (float)b0, -3.0F);
    051        this.spiderNeck = new ModelRenderer(this, 0, 0);
    052        this.spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, f);
    053        this.spiderNeck.setRotationPoint(0.0F, (float)b0, 0.0F);
    054        this.spiderBody = new ModelRenderer(this, 0, 12);
    055        this.spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, f);
    056        this.spiderBody.setRotationPoint(0.0F, (float)b0, 9.0F);
    057        this.spiderLeg1 = new ModelRenderer(this, 18, 0);
    058        this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f);
    059        this.spiderLeg1.setRotationPoint(-4.0F, (float)b0, 2.0F);
    060        this.spiderLeg2 = new ModelRenderer(this, 18, 0);
    061        this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f);
    062        this.spiderLeg2.setRotationPoint(4.0F, (float)b0, 2.0F);
    063        this.spiderLeg3 = new ModelRenderer(this, 18, 0);
    064        this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f);
    065        this.spiderLeg3.setRotationPoint(-4.0F, (float)b0, 1.0F);
    066        this.spiderLeg4 = new ModelRenderer(this, 18, 0);
    067        this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f);
    068        this.spiderLeg4.setRotationPoint(4.0F, (float)b0, 1.0F);
    069        this.spiderLeg5 = new ModelRenderer(this, 18, 0);
    070        this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f);
    071        this.spiderLeg5.setRotationPoint(-4.0F, (float)b0, 0.0F);
    072        this.spiderLeg6 = new ModelRenderer(this, 18, 0);
    073        this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f);
    074        this.spiderLeg6.setRotationPoint(4.0F, (float)b0, 0.0F);
    075        this.spiderLeg7 = new ModelRenderer(this, 18, 0);
    076        this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f);
    077        this.spiderLeg7.setRotationPoint(-4.0F, (float)b0, -1.0F);
    078        this.spiderLeg8 = new ModelRenderer(this, 18, 0);
    079        this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f);
    080        this.spiderLeg8.setRotationPoint(4.0F, (float)b0, -1.0F);
    081    }
    082
    083    /**
    084     * Sets the models various rotation angles then renders the model.
    085     */
    086    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    087    {
    088        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
    089        this.spiderHead.render(par7);
    090        this.spiderNeck.render(par7);
    091        this.spiderBody.render(par7);
    092        this.spiderLeg1.render(par7);
    093        this.spiderLeg2.render(par7);
    094        this.spiderLeg3.render(par7);
    095        this.spiderLeg4.render(par7);
    096        this.spiderLeg5.render(par7);
    097        this.spiderLeg6.render(par7);
    098        this.spiderLeg7.render(par7);
    099        this.spiderLeg8.render(par7);
    100    }
    101
    102    /**
    103     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    104     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    105     * "far" arms and legs can swing at most.
    106     */
    107    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
    108    {
    109        this.spiderHead.rotateAngleY = par4 / (180F / (float)Math.PI);
    110        this.spiderHead.rotateAngleX = par5 / (180F / (float)Math.PI);
    111        float f6 = ((float)Math.PI / 4F);
    112        this.spiderLeg1.rotateAngleZ = -f6;
    113        this.spiderLeg2.rotateAngleZ = f6;
    114        this.spiderLeg3.rotateAngleZ = -f6 * 0.74F;
    115        this.spiderLeg4.rotateAngleZ = f6 * 0.74F;
    116        this.spiderLeg5.rotateAngleZ = -f6 * 0.74F;
    117        this.spiderLeg6.rotateAngleZ = f6 * 0.74F;
    118        this.spiderLeg7.rotateAngleZ = -f6;
    119        this.spiderLeg8.rotateAngleZ = f6;
    120        float f7 = -0.0F;
    121        float f8 = 0.3926991F;
    122        this.spiderLeg1.rotateAngleY = f8 * 2.0F + f7;
    123        this.spiderLeg2.rotateAngleY = -f8 * 2.0F - f7;
    124        this.spiderLeg3.rotateAngleY = f8 * 1.0F + f7;
    125        this.spiderLeg4.rotateAngleY = -f8 * 1.0F - f7;
    126        this.spiderLeg5.rotateAngleY = -f8 * 1.0F + f7;
    127        this.spiderLeg6.rotateAngleY = f8 * 1.0F - f7;
    128        this.spiderLeg7.rotateAngleY = -f8 * 2.0F + f7;
    129        this.spiderLeg8.rotateAngleY = f8 * 2.0F - f7;
    130        float f9 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + 0.0F) * 0.4F) * par2;
    131        float f10 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + (float)Math.PI) * 0.4F) * par2;
    132        float f11 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI / 2F)) * 0.4F) * par2;
    133        float f12 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2;
    134        float f13 = Math.abs(MathHelper.sin(par1 * 0.6662F + 0.0F) * 0.4F) * par2;
    135        float f14 = Math.abs(MathHelper.sin(par1 * 0.6662F + (float)Math.PI) * 0.4F) * par2;
    136        float f15 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI / 2F)) * 0.4F) * par2;
    137        float f16 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2;
    138        this.spiderLeg1.rotateAngleY += f9;
    139        this.spiderLeg2.rotateAngleY += -f9;
    140        this.spiderLeg3.rotateAngleY += f10;
    141        this.spiderLeg4.rotateAngleY += -f10;
    142        this.spiderLeg5.rotateAngleY += f11;
    143        this.spiderLeg6.rotateAngleY += -f11;
    144        this.spiderLeg7.rotateAngleY += f12;
    145        this.spiderLeg8.rotateAngleY += -f12;
    146        this.spiderLeg1.rotateAngleZ += f13;
    147        this.spiderLeg2.rotateAngleZ += -f13;
    148        this.spiderLeg3.rotateAngleZ += f14;
    149        this.spiderLeg4.rotateAngleZ += -f14;
    150        this.spiderLeg5.rotateAngleZ += f15;
    151        this.spiderLeg6.rotateAngleZ += -f15;
    152        this.spiderLeg7.rotateAngleZ += f16;
    153        this.spiderLeg8.rotateAngleZ += -f16;
    154    }
    155}