Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.79 KB | None | 0 0
  1. package com.maideniles.beautifulbiomes.model;
  2.  
  3. import net.minecraft.client.model.ModelBase;
  4. import net.minecraft.client.model.ModelRenderer;
  5. import net.minecraft.client.renderer.GlStateManager;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.passive.EntityOcelot;
  9. import net.minecraft.util.math.MathHelper;
  10. import net.minecraftforge.fml.relauncher.Side;
  11. import net.minecraftforge.fml.relauncher.SideOnly;
  12.  
  13. @SideOnly(Side.CLIENT)
  14. public class ModelMintyKitty extends ModelBase
  15. {
  16.     /** The back left leg model for the Ocelot. */
  17.     private final ModelRenderer kittyBackLeftLeg;
  18.     /** The back right leg model for the Ocelot. */
  19.     private final ModelRenderer kittyBackRightLeg;
  20.     /** The front left leg model for the Ocelot. */
  21.     private final ModelRenderer kittyFrontLeftLeg;
  22.     /** The front right leg model for the Ocelot. */
  23.     private final ModelRenderer kittyFrontRightLeg;
  24.     /** The tail model for the Ocelot. */
  25.     private final ModelRenderer kittyTail;
  26.     /** The second part of tail model for the Ocelot. */
  27.     private final ModelRenderer kittyTail2;
  28.     /** The head model for the Ocelot. */
  29.     private final ModelRenderer kittyHead;
  30.     /** The body model for the Ocelot. */
  31.     private final ModelRenderer kittyBody;
  32.     private int state = 1;
  33.  
  34.     public ModelMintyKitty()
  35.     {
  36.         this.setTextureOffset("head.main", 0, 0);
  37.         this.setTextureOffset("head.nose", 0, 24);
  38.         this.setTextureOffset("head.ear1", 0, 10);
  39.         this.setTextureOffset("head.ear2", 6, 10);
  40.         this.kittyHead = new ModelRenderer(this, "head");
  41.         this.kittyHead.addBox("main", -2.5F, -2.0F, -3.0F, 5, 4, 5);
  42.         this.kittyHead.addBox("nose", -1.5F, 0.0F, -4.0F, 3, 2, 2);
  43.         this.kittyHead.addBox("ear1", -2.0F, -3.0F, 0.0F, 1, 1, 2);
  44.         this.kittyHead.addBox("ear2", 1.0F, -3.0F, 0.0F, 1, 1, 2);
  45.         this.kittyHead.setRotationPoint(0.0F, 15.0F, -9.0F);
  46.         this.kittyBody = new ModelRenderer(this, 20, 0);
  47.         this.kittyBody.addBox(-2.0F, 3.0F, -8.0F, 4, 16, 6, 0.0F);
  48.         this.kittyBody.setRotationPoint(0.0F, 12.0F, -10.0F);
  49.         this.kittyTail = new ModelRenderer(this, 0, 15);
  50.         this.kittyTail.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1);
  51.         this.kittyTail.rotateAngleX = 0.9F;
  52.         this.kittyTail.setRotationPoint(0.0F, 15.0F, 8.0F);
  53.         this.kittyTail2 = new ModelRenderer(this, 4, 15);
  54.         this.kittyTail2.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1);
  55.         this.kittyTail2.setRotationPoint(0.0F, 20.0F, 14.0F);
  56.         this.kittyBackLeftLeg = new ModelRenderer(this, 8, 13);
  57.         this.kittyBackLeftLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2);
  58.         this.kittyBackLeftLeg.setRotationPoint(1.1F, 18.0F, 5.0F);
  59.         this.kittyBackRightLeg = new ModelRenderer(this, 8, 13);
  60.         this.kittyBackRightLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2);
  61.         this.kittyBackRightLeg.setRotationPoint(-1.1F, 18.0F, 5.0F);
  62.         this.kittyFrontLeftLeg = new ModelRenderer(this, 40, 0);
  63.         this.kittyFrontLeftLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2);
  64.         this.kittyFrontLeftLeg.setRotationPoint(1.2F, 13.8F, -5.0F);
  65.         this.kittyFrontRightLeg = new ModelRenderer(this, 40, 0);
  66.         this.kittyFrontRightLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2);
  67.         this.kittyFrontRightLeg.setRotationPoint(-1.2F, 13.8F, -5.0F);
  68.     }
  69.  
  70.     /**
  71.      * Sets the models various rotation angles then renders the model.
  72.      */
  73.     public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
  74.     {
  75.         this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);
  76.  
  77.         if (this.isChild)
  78.         {
  79.             float f = 2.0F;
  80.             GlStateManager.pushMatrix();
  81.             GlStateManager.scale(0.75F, 0.75F, 0.75F);
  82.             GlStateManager.translate(0.0F, 10.0F * scale, 4.0F * scale);
  83.             this.kittyHead.render(scale);
  84.             GlStateManager.popMatrix();
  85.             GlStateManager.pushMatrix();
  86.             GlStateManager.scale(0.5F, 0.5F, 0.5F);
  87.             GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
  88.             this.kittyBody.render(scale);
  89.             this.kittyBackLeftLeg.render(scale);
  90.             this.kittyBackRightLeg.render(scale);
  91.             this.kittyFrontLeftLeg.render(scale);
  92.             this.kittyFrontRightLeg.render(scale);
  93.             this.kittyTail.render(scale);
  94.             this.kittyTail2.render(scale);
  95.             GlStateManager.popMatrix();
  96.         }
  97.         else
  98.         {
  99.             this.kittyHead.render(scale);
  100.             this.kittyBody.render(scale);
  101.             this.kittyTail.render(scale);
  102.             this.kittyTail2.render(scale);
  103.             this.kittyBackLeftLeg.render(scale);
  104.             this.kittyBackRightLeg.render(scale);
  105.             this.kittyFrontLeftLeg.render(scale);
  106.             this.kittyFrontRightLeg.render(scale);
  107.         }
  108.     }
  109.  
  110.     /**
  111.      * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
  112.      * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
  113.      * "far" arms and legs can swing at most.
  114.      */
  115.     public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
  116.     {
  117.         this.kittyHead.rotateAngleX = headPitch * 0.017453292F;
  118.         this.kittyHead.rotateAngleY = netHeadYaw * 0.017453292F;
  119.  
  120.         if (this.state != 3)
  121.         {
  122.             this.kittyBody.rotateAngleX = ((float)Math.PI / 2F);
  123.  
  124.             if (this.state == 2)
  125.             {
  126.                 this.kittyBackLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;
  127.                 this.kittyBackRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + 0.3F) * limbSwingAmount;
  128.                 this.kittyFrontLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI + 0.3F) * limbSwingAmount;
  129.                 this.kittyFrontRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
  130.                 this.kittyTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 10F) * MathHelper.cos(limbSwing) * limbSwingAmount;
  131.             }
  132.             else
  133.             {
  134.                 this.kittyBackLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;
  135.                 this.kittyBackRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
  136.                 this.kittyFrontLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
  137.                 this.kittyFrontRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;
  138.  
  139.                 if (this.state == 1)
  140.                 {
  141.                     this.kittyTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 4F) * MathHelper.cos(limbSwing) * limbSwingAmount;
  142.                 }
  143.                 else
  144.                 {
  145.                     this.kittyTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(limbSwing) * limbSwingAmount;
  146.                 }
  147.             }
  148.         }
  149.     }
  150.  
  151.     /**
  152.      * Used for easily adding entity-dependent animations. The second and third float params here are the same second
  153.      * and third as in the setRotationAngles method.
  154.      */
  155.     public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTickTime)
  156.     {
  157.         EntityOcelot entitykitty = (EntityOcelot)entitylivingbaseIn;
  158.         this.kittyBody.rotationPointY = 12.0F;
  159.         this.kittyBody.rotationPointZ = -10.0F;
  160.         this.kittyHead.rotationPointY = 15.0F;
  161.         this.kittyHead.rotationPointZ = -9.0F;
  162.         this.kittyTail.rotationPointY = 15.0F;
  163.         this.kittyTail.rotationPointZ = 8.0F;
  164.         this.kittyTail2.rotationPointY = 20.0F;
  165.         this.kittyTail2.rotationPointZ = 14.0F;
  166.         this.kittyFrontLeftLeg.rotationPointY = 13.8F;
  167.         this.kittyFrontLeftLeg.rotationPointZ = -5.0F;
  168.         this.kittyFrontRightLeg.rotationPointY = 13.8F;
  169.         this.kittyFrontRightLeg.rotationPointZ = -5.0F;
  170.         this.kittyBackLeftLeg.rotationPointY = 18.0F;
  171.         this.kittyBackLeftLeg.rotationPointZ = 5.0F;
  172.         this.kittyBackRightLeg.rotationPointY = 18.0F;
  173.         this.kittyBackRightLeg.rotationPointZ = 5.0F;
  174.         this.kittyTail.rotateAngleX = 0.9F;
  175.  
  176.         if (entitykitty.isSneaking())
  177.         {
  178.             ++this.kittyBody.rotationPointY;
  179.             this.kittyHead.rotationPointY += 2.0F;
  180.             ++this.kittyTail.rotationPointY;
  181.             this.kittyTail2.rotationPointY += -4.0F;
  182.             this.kittyTail2.rotationPointZ += 2.0F;
  183.             this.kittyTail.rotateAngleX = ((float)Math.PI / 2F);
  184.             this.kittyTail2.rotateAngleX = ((float)Math.PI / 2F);
  185.             this.state = 0;
  186.         }
  187.         else if (entitykitty.isSprinting())
  188.         {
  189.             this.kittyTail2.rotationPointY = this.kittyTail.rotationPointY;
  190.             this.kittyTail2.rotationPointZ += 2.0F;
  191.             this.kittyTail.rotateAngleX = ((float)Math.PI / 2F);
  192.             this.kittyTail2.rotateAngleX = ((float)Math.PI / 2F);
  193.             this.state = 2;
  194.         }
  195.         else if (entitykitty.isSitting())
  196.         {
  197.             this.kittyBody.rotateAngleX = ((float)Math.PI / 4F);
  198.             this.kittyBody.rotationPointY += -4.0F;
  199.             this.kittyBody.rotationPointZ += 5.0F;
  200.             this.kittyHead.rotationPointY += -3.3F;
  201.             ++this.kittyHead.rotationPointZ;
  202.             this.kittyTail.rotationPointY += 8.0F;
  203.             this.kittyTail.rotationPointZ += -2.0F;
  204.             this.kittyTail2.rotationPointY += 2.0F;
  205.             this.kittyTail2.rotationPointZ += -0.8F;
  206.             this.kittyTail.rotateAngleX = 1.7278761F;
  207.             this.kittyTail2.rotateAngleX = 2.670354F;
  208.             this.kittyFrontLeftLeg.rotateAngleX = -0.15707964F;
  209.             this.kittyFrontLeftLeg.rotationPointY = 15.8F;
  210.             this.kittyFrontLeftLeg.rotationPointZ = -7.0F;
  211.             this.kittyFrontRightLeg.rotateAngleX = -0.15707964F;
  212.             this.kittyFrontRightLeg.rotationPointY = 15.8F;
  213.             this.kittyFrontRightLeg.rotationPointZ = -7.0F;
  214.             this.kittyBackLeftLeg.rotateAngleX = -((float)Math.PI / 2F);
  215.             this.kittyBackLeftLeg.rotationPointY = 21.0F;
  216.             this.kittyBackLeftLeg.rotationPointZ = 1.0F;
  217.             this.kittyBackRightLeg.rotateAngleX = -((float)Math.PI / 2F);
  218.             this.kittyBackRightLeg.rotationPointY = 21.0F;
  219.             this.kittyBackRightLeg.rotationPointZ = 1.0F;
  220.             this.state = 3;
  221.         }
  222.         else
  223.         {
  224.             this.state = 1;
  225.         }
  226.     }
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement