Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.94 KB | None | 0 0
  1. @OnlyIn(Dist.CLIENT)
  2. public class EntityWarthogModel<T extends EntityWarthog> extends EntityModel<T>
  3. {
  4.     private float headRotationAngleX;
  5.     public RendererModel body;
  6.     public RendererModel tail;
  7.     public RendererModel head;
  8.     public RendererModel leg1;
  9.     public RendererModel leg2;
  10.     public RendererModel leg3;
  11.     public RendererModel leg4;
  12.     public RendererModel jaws;
  13.     public RendererModel tusk1;
  14.     public RendererModel tusk2;
  15.    
  16.    public EntityWarthogModel()
  17.    {
  18.       this.textureWidth = 64;
  19.       this.textureHeight = 32;
  20.       this.tail = new RendererModel(this, 28, 6);
  21.       this.tail.setRotationPoint(0.0F, -2.6F, 7.0F);
  22.       this.tail.addBox(-0.5F, 0.0F, -0.5F, 1, 7, 1, 0.0F);
  23.       this.setRotateAngle(tail, 0.27314402793711257F, 0.0F, 0.0F);
  24.       this.leg3 = new RendererModel(this, 50, 0);
  25.       this.leg3.setRotationPoint(-2.8F, 2.6F, -4.8F);
  26.       this.leg3.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F);
  27.       this.tusk1 = new RendererModel(this, 23, 0);
  28.       this.tusk1.setRotationPoint(1.2F, 0.8F, -2.1F);
  29.       this.tusk1.addBox(0.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F);
  30.       this.setRotateAngle(tusk1, 0.0F, 0.0F, -0.18203784098300857F);
  31.       this.leg1 = new RendererModel(this, 50, 0);
  32.       this.leg1.setRotationPoint(2.8F, 2.6F, 6.0F);
  33.       this.leg1.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F);
  34.       this.tusk2 = new RendererModel(this, 23, 0);
  35.       this.tusk2.setRotationPoint(-1.2F, 0.8F, -2.1F);
  36.       this.tusk2.addBox(-3.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F);
  37.       this.setRotateAngle(tusk2, 0.0F, 0.0F, 0.18203784098300857F);
  38.       this.head = new RendererModel(this, 0, 0);
  39.       this.head.setRotationPoint(0.0F, -2.8F, -5.0F);
  40.       this.head.addBox(-3.5F, -3.5F, -7.0F, 7, 7, 7, 0.0F);
  41.       this.body = new RendererModel(this, 18, 0);
  42.       this.body.setRotationPoint(0.0F, 13.6F, 0.0F);
  43.       this.body.addBox(-4.5F, -4.5F, -7.0F, 9, 8, 14, 0.0F);
  44.       this.leg2 = new RendererModel(this, 50, 0);
  45.       this.leg2.setRotationPoint(-2.8F, 2.6F, 6.0F);
  46.       this.leg2.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F);
  47.       this.leg4 = new RendererModel(this, 50, 0);
  48.       this.leg4.setRotationPoint(2.8F, 2.6F, -4.8F);
  49.       this.leg4.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F);
  50.       this.jaws = new RendererModel(this, 2, 14);
  51.       this.jaws.setRotationPoint(0.0F, 1.5F, -6.0F);
  52.       this.jaws.addBox(-2.5F, -2.0F, -3.0F, 5, 4, 3, 0.0F);
  53.       this.jaws.addChild(this.tusk1);
  54.       this.jaws.addChild(this.tusk2);
  55.       this.head.addChild(this.jaws);
  56.       this.body.addChild(this.leg1);
  57.       this.body.addChild(this.leg2);
  58.       this.body.addChild(this.leg3);
  59.       this.body.addChild(this.leg4);
  60.       this.body.addChild(this.tail);
  61.    }
  62.    
  63.    
  64.    public void setLivingAnimations(T entityIn, float limbSwing, float limbSwingAmount, float partialTick)
  65.    {
  66.        super.setLivingAnimations(entityIn, limbSwing, limbSwingAmount, partialTick);
  67.        this.headRotationAngleX = entityIn.getHeadRotationAngleX(partialTick);
  68.    }
  69.    
  70.    public void setRotateAngle(RendererModel modelRenderer, float x, float y, float z)
  71.    {
  72.        modelRenderer.rotateAngleX = x;
  73.        modelRenderer.rotateAngleY = y;
  74.        modelRenderer.rotateAngleZ = z;
  75.    }
  76.    
  77.    public void render(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
  78.    {
  79.           this.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
  80.           if (this.isChild)
  81.           {
  82.              float f = 2.0F;
  83.              GlStateManager.pushMatrix();
  84.              GlStateManager.translatef(0.0F, 6.0F * scale, 0.0F);
  85.              this.head.render(scale);
  86.              GlStateManager.popMatrix();
  87.              GlStateManager.pushMatrix();
  88.              GlStateManager.scalef(0.5F / f, 0.5F / f, 0.5F / f);
  89.              GlStateManager.translatef(0.0F, 24.0F * scale, 0.0F);
  90.              this.body.render(scale);
  91.              GlStateManager.popMatrix();
  92.           }
  93.           else
  94.           {
  95.              this.body.render(scale);
  96.              this.head.render(scale);
  97.           }
  98.  
  99.     }
  100.  
  101.    public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor)
  102.    {
  103.         super.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);
  104.         this.head.rotateAngleX = this.headRotationAngleX;
  105.         this.head.rotateAngleX = headPitch * ((float)Math.PI / 180F);
  106.         this.head.rotateAngleY = netHeadYaw * ((float)Math.PI / 180F);
  107.         this.body.rotateAngleX = ((float)Math.PI / 2F);
  108.         this.leg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
  109.         this.leg2.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
  110.         this.leg3.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
  111.         this.leg4.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
  112.    }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement