    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 ModelBook extends ModelBase
    008    {
    009        /** Right cover renderer (when facing the book) */
    010        public ModelRenderer coverRight = (new ModelRenderer(this)).setTextureOffset(0, 0).addBox(-6.0F, -5.0F, 0.0F, 6, 10, 0);
    011
    012        /** Left cover renderer (when facing the book) */
    013        public ModelRenderer coverLeft = (new ModelRenderer(this)).setTextureOffset(16, 0).addBox(0.0F, -5.0F, 0.0F, 6, 10, 0);
    014
    015        /** The right pages renderer (when facing the book) */
    016        public ModelRenderer pagesRight = (new ModelRenderer(this)).setTextureOffset(0, 10).addBox(0.0F, -4.0F, -0.99F, 5, 8, 1);
    017
    018        /** The left pages renderer (when facing the book) */
    019        public ModelRenderer pagesLeft = (new ModelRenderer(this)).setTextureOffset(12, 10).addBox(0.0F, -4.0F, -0.01F, 5, 8, 1);
    020
    021        /** Right cover renderer (when facing the book) */
    022        public ModelRenderer flippingPageRight = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0);
    023
    024        /** Right cover renderer (when facing the book) */
    025        public ModelRenderer flippingPageLeft = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0);
    026
    027        /** The renderer of spine of the book */
    028        public ModelRenderer bookSpine = (new ModelRenderer(this)).setTextureOffset(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2, 10, 0);
    029
    030        public ModelBook()
    031        {
    032            this.coverRight.setRotationPoint(0.0F, 0.0F, -1.0F);
    033            this.coverLeft.setRotationPoint(0.0F, 0.0F, 1.0F);
    034            this.bookSpine.rotateAngleY = ((float)Math.PI / 2F);
    035        }
    036
    037        /**
    038         * Sets the models various rotation angles then renders the model.
    039         */
    040        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    041        {
    042            this.setRotationAngles(par2, par3, par4, par5, par6, par7);
    043            this.coverRight.render(par7);
    044            this.coverLeft.render(par7);
    045            this.bookSpine.render(par7);
    046            this.pagesRight.render(par7);
    047            this.pagesLeft.render(par7);
    048            this.flippingPageRight.render(par7);
    049            this.flippingPageLeft.render(par7);
    050        }
    051
    052        /**
    053         * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
    054         * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
    055         * "far" arms and legs can swing at most.
    056         */
    057        public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6)
    058        {
    059            float var7 = (MathHelper.sin(par1 * 0.02F) * 0.1F + 1.25F) * par4;
    060            this.coverRight.rotateAngleY = (float)Math.PI + var7;
    061            this.coverLeft.rotateAngleY = -var7;
    062            this.pagesRight.rotateAngleY = var7;
    063            this.pagesLeft.rotateAngleY = -var7;
    064            this.flippingPageRight.rotateAngleY = var7 - var7 * 2.0F * par2;
    065            this.flippingPageLeft.rotateAngleY = var7 - var7 * 2.0F * par3;
    066            this.pagesRight.rotationPointX = MathHelper.sin(var7);
    067            this.pagesLeft.rotationPointX = MathHelper.sin(var7);
    068            this.flippingPageRight.rotationPointX = MathHelper.sin(var7);
    069            this.flippingPageLeft.rotationPointX = MathHelper.sin(var7);
    070        }
    071    }