| 1 | package net.minecraft.client.model;
|
| 2 |
|
| 3 | import net.minecraft.client.renderer.GlStateManager;
|
| 4 | import net.minecraft.entity.Entity;
|
| 5 | import net.minecraft.util.MathHelper;
|
| 6 |
|
| 7 | public class ModelQuadruped extends ModelBase
|
| 8 | {
|
| 9 | public ModelRenderer head = new ModelRenderer(this, 0, 0);
|
| 10 | public ModelRenderer body;
|
| 11 | public ModelRenderer leg1;
|
| 12 | public ModelRenderer leg2;
|
| 13 | public ModelRenderer leg3;
|
| 14 | public ModelRenderer leg4;
|
| 15 | protected float childYOffset = 8.0F;
|
| 16 | protected float childZOffset = 4.0F;
|
| 17 |
|
| 18 | public ModelQuadruped(int p_i1154_1_, float p_i1154_2_)
|
| 19 | {
|
| 20 | this.head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, p_i1154_2_);
|
| 21 | this.head.setRotationPoint(0.0F, (float)(18 - p_i1154_1_), -6.0F);
|
| 22 | this.body = new ModelRenderer(this, 28, 8);
|
| 23 | this.body.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, p_i1154_2_);
|
| 24 | this.body.setRotationPoint(0.0F, (float)(17 - p_i1154_1_), 2.0F);
|
| 25 | this.leg1 = new ModelRenderer(this, 0, 16);
|
| 26 | this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, p_i1154_1_, 4, p_i1154_2_);
|
| 27 | this.leg1.setRotationPoint(-3.0F, (float)(24 - p_i1154_1_), 7.0F);
|
| 28 | this.leg2 = new ModelRenderer(this, 0, 16);
|
| 29 | this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, p_i1154_1_, 4, p_i1154_2_);
|
| 30 | this.leg2.setRotationPoint(3.0F, (float)(24 - p_i1154_1_), 7.0F);
|
| 31 | this.leg3 = new ModelRenderer(this, 0, 16);
|
| 32 | this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, p_i1154_1_, 4, p_i1154_2_);
|
| 33 | this.leg3.setRotationPoint(-3.0F, (float)(24 - p_i1154_1_), -5.0F);
|
| 34 | this.leg4 = new ModelRenderer(this, 0, 16);
|
| 35 | this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, p_i1154_1_, 4, p_i1154_2_);
|
| 36 | this.leg4.setRotationPoint(3.0F, (float)(24 - p_i1154_1_), -5.0F);
|
| 37 | }
|
| 38 |
|
| 39 | /**
|
| 40 | * Sets the models various rotation angles then renders the model.
|
| 41 | */
|
| 42 | 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)
|
| 43 | {
|
| 44 | this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);
|
| 45 |
|
| 46 | if (this.isChild)
|
| 47 | {
|
| 48 | float f = 2.0F;
|
| 49 | GlStateManager.pushMatrix();
|
| 50 | GlStateManager.translate(0.0F, this.childYOffset * scale, this.childZOffset * scale);
|
| 51 | this.head.render(scale);
|
| 52 | GlStateManager.popMatrix();
|
| 53 | GlStateManager.pushMatrix();
|
| 54 | GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);
|
| 55 | GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
|
| 56 | this.body.render(scale);
|
| 57 | this.leg1.render(scale);
|
| 58 | this.leg2.render(scale);
|
| 59 | this.leg3.render(scale);
|
| 60 | this.leg4.render(scale);
|
| 61 | GlStateManager.popMatrix();
|
| 62 | }
|
| 63 | else
|
| 64 | {
|
| 65 | this.head.render(scale);
|
| 66 | this.body.render(scale);
|
| 67 | this.leg1.render(scale);
|
| 68 | this.leg2.render(scale);
|
| 69 | this.leg3.render(scale);
|
| 70 | this.leg4.render(scale);
|
| 71 | }
|
| 72 | }
|
| 73 |
|
| 74 | /**
|
| 75 | * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
|
| 76 | * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
|
| 77 | * "far" arms and legs can swing at most.
|
| 78 | */
|
| 79 | public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
|
| 80 | {
|
| 81 | float f = (180F / (float)Math.PI);
|
| 82 | this.head.rotateAngleX = headPitch / (180F / (float)Math.PI);
|
| 83 | this.head.rotateAngleY = netHeadYaw / (180F / (float)Math.PI);
|
| 84 | this.body.rotateAngleX = ((float)Math.PI / 2F);
|
| 85 | this.leg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
|
| 86 | this.leg2.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
|
| 87 | this.leg3.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
|
| 88 | this.leg4.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
|
| 89 | }
|
| 90 | }
|
| 91 |
|