    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    @SideOnly(Side.CLIENT)
    007    public class ModelBat extends ModelBase
    008    {
    009        private ModelRenderer batHead;
    010
    011        /** The body box of the bat model. */
    012        private ModelRenderer batBody;
    013
    014        /** The inner right wing box of the bat model. */
    015        private ModelRenderer batRightWing;
    016
    017        /** The inner left wing box of the bat model. */
    018        private ModelRenderer batLeftWing;
    019
    020        /** The outer right wing box of the bat model. */
    021        private ModelRenderer batOuterRightWing;
    022
    023        /** The outer left wing box of the bat model. */
    024        private ModelRenderer batOuterLeftWing;
    025
    026        public ModelBat()
    027        {
    028            this.textureWidth = 64;
    029            this.textureHeight = 64;
    030            this.batHead = new ModelRenderer(this, 0, 0);
    031            this.batHead.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6);
    032            ModelRenderer var1 = new ModelRenderer(this, 24, 0);
    033            var1.addBox(-4.0F, -6.0F, -2.0F, 3, 4, 1);
    034            this.batHead.addChild(var1);
    035            ModelRenderer var2 = new ModelRenderer(this, 24, 0);
    036            var2.mirror = true;
    037            var2.addBox(1.0F, -6.0F, -2.0F, 3, 4, 1);
    038            this.batHead.addChild(var2);
    039            this.batBody = new ModelRenderer(this, 0, 16);
    040            this.batBody.addBox(-3.0F, 4.0F, -3.0F, 6, 12, 6);
    041            this.batBody.setTextureOffset(0, 34).addBox(-5.0F, 16.0F, 0.0F, 10, 6, 1);
    042            this.batRightWing = new ModelRenderer(this, 42, 0);
    043            this.batRightWing.addBox(-12.0F, 1.0F, 1.5F, 10, 16, 1);
    044            this.batOuterRightWing = new ModelRenderer(this, 24, 16);
    045            this.batOuterRightWing.setRotationPoint(-12.0F, 1.0F, 1.5F);
    046            this.batOuterRightWing.addBox(-8.0F, 1.0F, 0.0F, 8, 12, 1);
    047            this.batLeftWing = new ModelRenderer(this, 42, 0);
    048            this.batLeftWing.mirror = true;
    049            this.batLeftWing.addBox(2.0F, 1.0F, 1.5F, 10, 16, 1);
    050            this.batOuterLeftWing = new ModelRenderer(this, 24, 16);
    051            this.batOuterLeftWing.mirror = true;
    052            this.batOuterLeftWing.setRotationPoint(12.0F, 1.0F, 1.5F);
    053            this.batOuterLeftWing.addBox(0.0F, 1.0F, 0.0F, 8, 12, 1);
    054            this.batBody.addChild(this.batRightWing);
    055            this.batBody.addChild(this.batLeftWing);
    056            this.batRightWing.addChild(this.batOuterRightWing);
    057            this.batLeftWing.addChild(this.batOuterLeftWing);
    058        }
    059
    060        /**
    061         * not actually sure this is size, is not used as of now, but the model would be recreated if the value changed and
    062         * it seems a good match for a bats size
    063         */
    064        public int getBatSize()
    065        {
    066            return 36;
    067        }
    068
    069        /**
    070         * Sets the models various rotation angles then renders the model.
    071         */
    072        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    073        {
    074            EntityBat var8 = (EntityBat)par1Entity;
    075
    076            if (var8.getIsBatHanging())
    077            {
    078                this.batHead.rotateAngleX = par6 / (180F / (float)Math.PI);
    079                this.batHead.rotateAngleY = (float)Math.PI - par5 / (180F / (float)Math.PI);
    080                this.batHead.rotateAngleZ = (float)Math.PI;
    081                this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F);
    082                this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F);
    083                this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F);
    084                this.batBody.rotateAngleX = (float)Math.PI;
    085                this.batRightWing.rotateAngleX = -0.15707964F;
    086                this.batRightWing.rotateAngleY = -((float)Math.PI * 2F / 5F);
    087                this.batOuterRightWing.rotateAngleY = -1.7278761F;
    088                this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX;
    089                this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY;
    090                this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY;
    091            }
    092            else
    093            {
    094                this.batHead.rotateAngleX = par6 / (180F / (float)Math.PI);
    095                this.batHead.rotateAngleY = par5 / (180F / (float)Math.PI);
    096                this.batHead.rotateAngleZ = 0.0F;
    097                this.batHead.setRotationPoint(0.0F, 0.0F, 0.0F);
    098                this.batRightWing.setRotationPoint(0.0F, 0.0F, 0.0F);
    099                this.batLeftWing.setRotationPoint(0.0F, 0.0F, 0.0F);
    100                this.batBody.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(par4 * 0.1F) * 0.15F;
    101                this.batBody.rotateAngleY = 0.0F;
    102                this.batRightWing.rotateAngleY = MathHelper.cos(par4 * 1.3F) * (float)Math.PI * 0.25F;
    103                this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY;
    104                this.batOuterRightWing.rotateAngleY = this.batRightWing.rotateAngleY * 0.5F;
    105                this.batOuterLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY * 0.5F;
    106            }
    107
    108            this.batHead.render(par7);
    109            this.batBody.render(par7);
    110        }
    111    }