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