| 1 | package net.minecraft.client.model;
|
| 2 |
|
| 3 | import net.minecraft.entity.Entity;
|
| 4 | import net.minecraft.util.MathHelper;
|
| 5 |
|
| 6 | public class ModelBook extends ModelBase
|
| 7 | {
|
| 8 | /** Right cover renderer (when facing the book) */
|
| 9 | public ModelRenderer coverRight = (new ModelRenderer(this)).setTextureOffset(0, 0).addBox(-6.0F, -5.0F, 0.0F, 6, 10, 0);
|
| 10 |
|
| 11 | /** Left cover renderer (when facing the book) */
|
| 12 | public ModelRenderer coverLeft = (new ModelRenderer(this)).setTextureOffset(16, 0).addBox(0.0F, -5.0F, 0.0F, 6, 10, 0);
|
| 13 |
|
| 14 | /** The right pages renderer (when facing the book) */
|
| 15 | public ModelRenderer pagesRight = (new ModelRenderer(this)).setTextureOffset(0, 10).addBox(0.0F, -4.0F, -0.99F, 5, 8, 1);
|
| 16 |
|
| 17 | /** The left pages renderer (when facing the book) */
|
| 18 | public ModelRenderer pagesLeft = (new ModelRenderer(this)).setTextureOffset(12, 10).addBox(0.0F, -4.0F, -0.01F, 5, 8, 1);
|
| 19 |
|
| 20 | /** Right cover renderer (when facing the book) */
|
| 21 | public ModelRenderer flippingPageRight = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0);
|
| 22 |
|
| 23 | /** Right cover renderer (when facing the book) */
|
| 24 | public ModelRenderer flippingPageLeft = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0);
|
| 25 |
|
| 26 | /** The renderer of spine of the book */
|
| 27 | public ModelRenderer bookSpine = (new ModelRenderer(this)).setTextureOffset(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2, 10, 0);
|
| 28 |
|
| 29 | public ModelBook()
|
| 30 | {
|
| 31 | this.coverRight.setRotationPoint(0.0F, 0.0F, -1.0F);
|
| 32 | this.coverLeft.setRotationPoint(0.0F, 0.0F, 1.0F);
|
| 33 | this.bookSpine.rotateAngleY = ((float)Math.PI / 2F);
|
| 34 | }
|
| 35 |
|
| 36 | /**
|
| 37 | * Sets the models various rotation angles then renders the model.
|
| 38 | */
|
| 39 | public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
|
| 40 | {
|
| 41 | this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);
|
| 42 | this.coverRight.render(scale);
|
| 43 | this.coverLeft.render(scale);
|
| 44 | this.bookSpine.render(scale);
|
| 45 | this.pagesRight.render(scale);
|
| 46 | this.pagesLeft.render(scale);
|
| 47 | this.flippingPageRight.render(scale);
|
| 48 | this.flippingPageLeft.render(scale);
|
| 49 | }
|
| 50 |
|
| 51 | /**
|
| 52 | * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
|
| 53 | * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
|
| 54 | * "far" arms and legs can swing at most.
|
| 55 | */
|
| 56 | public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
|
| 57 | {
|
| 58 | float f = (MathHelper.sin(limbSwing * 0.02F) * 0.1F + 1.25F) * netHeadYaw;
|
| 59 | this.coverRight.rotateAngleY = (float)Math.PI + f;
|
| 60 | this.coverLeft.rotateAngleY = -f;
|
| 61 | this.pagesRight.rotateAngleY = f;
|
| 62 | this.pagesLeft.rotateAngleY = -f;
|
| 63 | this.flippingPageRight.rotateAngleY = f - f * 2.0F * limbSwingAmount;
|
| 64 | this.flippingPageLeft.rotateAngleY = f - f * 2.0F * ageInTicks;
|
| 65 | this.pagesRight.rotationPointX = MathHelper.sin(f);
|
| 66 | this.pagesLeft.rotationPointX = MathHelper.sin(f);
|
| 67 | this.flippingPageRight.rotationPointX = MathHelper.sin(f);
|
| 68 | this.flippingPageLeft.rotationPointX = MathHelper.sin(f);
|
| 69 | }
|
| 70 | }
|
| 71 |
|