Jump to content

[1.7.10] [Forge] [SOLVED] Custom Mob Animation Help


Recommended Posts

Posted

I'm having trouble with my mob's walking animation. I want the top part of its leg's to be angled and move and the bottom part to give with the top part. But they both keep spinning.

 

Here is my code

package common.zeroquest.client.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;

import org.lwjgl.opengl.GL11;

import common.zeroquest.entity.EntityRedZertum;
import common.zeroquest.entity.EntityZertum;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ModelZertum extends ModelBase
{
  //fields
    ModelRenderer Nose;
    ModelRenderer Ear2;
    ModelRenderer Ear1;
    ModelRenderer Head;
    ModelRenderer LeftHindLeg2;
    ModelRenderer LeftHindLeg1;
    ModelRenderer RightHindLeg2;
    ModelRenderer RightHindLeg1;
    ModelRenderer Mane1;
    ModelRenderer RightLeg;
    ModelRenderer LeftLeg;
    ModelRenderer Tail1;
    ModelRenderer Mane2;
    ModelRenderer Torso;
    ModelRenderer Tail2;
    ModelRenderer Neck;
  
  public ModelZertum()
  {
    textureWidth = 128;
    textureHeight = 64;
    
    Nose = new ModelRenderer(this, 25, 27);
    Nose.addBox(-1.5F, 0F, -3F, 3, 3, 4);
    Nose.setRotationPoint(0F, 2.5F, -15F);
    Nose.setTextureSize(64, 32);
    Nose.mirror = true;
    setRotation(Nose, 0F, 0F, 0F);
    Ear2 = new ModelRenderer(this, 40, 28);
    Ear2.addBox(-1F, -3F, 0F, 2, 3, 1);
    Ear2.setRotationPoint(2F, -0.5F, -10.5F);
    Ear2.setTextureSize(64, 32);
    Ear2.mirror = true;
    setRotation(Ear2, 0F, 0F, 0F);
    Ear1 = new ModelRenderer(this, 40, 28);
    Ear1.addBox(-1F, -3F, 0F, 2, 3, 1);
    Ear1.setRotationPoint(-2F, -0.5F, -10.5F);
    Ear1.setTextureSize(64, 32);
    Ear1.mirror = true;
    setRotation(Ear1, 0F, 0F, 0F);
    Head = new ModelRenderer(this, 25, 15);
    Head.addBox(-3F, -0.5F, -14F, 6, 6, 5);
    Head.setRotationPoint(-0.5F, 6F, -3F);
    Head.setTextureSize(64, 32);
    Head.mirror = true;
    setRotation(Head, 0F, 0F, 0F);
      LeftHindLeg1 = new ModelRenderer(this, 11, 18);
      LeftHindLeg1.addBox(-1F, 0F, -1F, 2, 5, 3);
      LeftHindLeg1.setRotationPoint(1.5F, 13F, 5F);
      LeftHindLeg1.setTextureSize(128, 64);
      LeftHindLeg1.mirror = true;
      setRotation(LeftHindLeg1, -0.2974289F, 0F, 0F);
      LeftHindLeg2 = new ModelRenderer(this, 9, 44);
      LeftHindLeg2.addBox(-1F, 0F, -1F, 2, 8, 2);
      LeftHindLeg2.setRotationPoint(0F, 3F, -1.5F);
      LeftHindLeg2.setTextureSize(128, 64);
      LeftHindLeg2.mirror = true;
      setRotation(LeftHindLeg2, 0F, 0F, 0F);
      RightHindLeg1 = new ModelRenderer(this, 11, 31);
      RightHindLeg1.addBox(-1F, 0F, -1F, 2, 5, 3);
      RightHindLeg1.setRotationPoint(-2.5F, 13F, 5F);
      RightHindLeg1.setTextureSize(128, 64);
      RightHindLeg1.mirror = true;
      setRotation(RightHindLeg1, -0.2974289F, 0F, 0F);
      RightHindLeg2 = new ModelRenderer(this, 0, 44);
      RightHindLeg2.addBox(-1F, 0F, -1F, 2, 8, 2);
      RightHindLeg2.setRotationPoint(0F, 3F, -1.5F);
      RightHindLeg2.setTextureSize(128, 64);
      RightHindLeg2.mirror = true;
      setRotation(RightHindLeg2, 0F, 0F, 0F);
      Mane1 = new ModelRenderer(this, 43, 0);
      Mane1.addBox(-3F, -3F, -3F, 6, 6, 7);
      Mane1.setRotationPoint(-0.5F, 14F, -3F);
      Mane1.setTextureSize(128, 64);
      Mane1.mirror = true;
      setRotation(Mane1, 1.496439F, 0F, 0F);
      Neck = new ModelRenderer(this, 0, 0);
      Neck.addBox(-2.5F, -12F, -4F, 4, 7, 4);
      Neck.setRotationPoint(0.5F, 0F, 0F);
      Neck.setTextureSize(64, 32);
      Neck.mirror = true;
      setRotation(Neck, -0.6015813F, 0F, 0F);
      Mane2 = new ModelRenderer(this, 18, 0);
      Mane2.addBox(-2.5F, -7F, -3.6F, 5, 6, 7);
      Mane2.setRotationPoint(0F, 0F, 0F);
      Mane2.setTextureSize(64, 32);
      Mane2.mirror = true;
      setRotation(Mane2, -0.34653F, 0F, 0F);
      RightLeg = new ModelRenderer(this, 0, 30);
      RightLeg.addBox(-1F, 0F, -1F, 2, 10, 2);
      RightLeg.setRotationPoint(-3F, 14F, -4F);
      RightLeg.setTextureSize(128, 64);
      RightLeg.mirror = true;
      setRotation(RightLeg, 0F, 0F, 0F);
      LeftLeg = new ModelRenderer(this, 0, 16);
      LeftLeg.addBox(-1F, 0F, -1F, 2, 10, 2);
      LeftLeg.setRotationPoint(2F, 14F, -4F);
      LeftLeg.setTextureSize(128, 64);
      LeftLeg.mirror = true;
      setRotation(LeftLeg, 0F, 0F, 0F);
      Tail1 = new ModelRenderer(this, 91, 0);
      Tail1.addBox(-1.5F, 0F, -1F, 4, 8, 4);
      Tail1.setRotationPoint(-1F, 14F, 5F);
      Tail1.setTextureSize(128, 64);
      Tail1.mirror = true;
      setRotation(Tail1, 1.315962F, 0F, 0F);
      Tail2 = new ModelRenderer(this, 110, 0);
      Tail2.addBox(-1.5F, 0F, -1F, 3, 8, 3);
      Tail2.setRotationPoint(0.5F, 6F, 0F);
      Tail2.setTextureSize(64, 32);
      Tail2.mirror = true;
      setRotation(Tail2, 0.141605F, 0F, 0F);
      Torso = new ModelRenderer(this, 69, 0);
      Torso.addBox(-2.5F, -3F, -3F, 5, 9, 5);
      Torso.setRotationPoint(-0.5F, 12.5F, 1F);
      Torso.setTextureSize(128, 64);
      Torso.mirror = true;
      setRotation(Torso, 1.496439F, 0F, 0F);
      Head.addChild(Nose);
      Head.addChild(Ear1);
      Head.addChild(Ear2);
      LeftHindLeg1.addChild(LeftHindLeg2);
      RightHindLeg1.addChild(RightHindLeg2);
      Mane1.addChild(Mane2);
      Mane1.addChild(Neck);
      Tail1.addChild(Tail2);
  }
  
  public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
  {
      super.render(par1Entity, par2, par3, par4, par5, par6, par7);
      this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
      if (this.isChild)
      {
          float f6 = 2.0F;
          GL11.glPushMatrix();
          GL11.glTranslatef(0.0F, 5.0F * par7, 2.0F * par7);
          Head.render(par7);
          GL11.glPopMatrix();
          GL11.glPushMatrix();
          GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
          GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
          LeftHindLeg1.render(par7);
          RightHindLeg1.render(par7);
          Mane1.render(par7);
          RightLeg.render(par7);
          LeftLeg.render(par7);
          Tail1.render(par7);
          Torso.render(par7);
          GL11.glPopMatrix();
      }
      else
      {
          GL11.glPushMatrix();
          GL11.glScalef(1.5F, 1.5F, 1.5F);
          GL11.glTranslatef(0.0F, -0.5F, 0.0F);
          Head.render(par7);
          LeftHindLeg1.render(par7);
          RightHindLeg1.render(par7);
          Mane1.render(par7);
          RightLeg.render(par7);
          LeftLeg.render(par7);
          Tail1.render(par7);
          Torso.render(par7);
          GL11.glPopMatrix();
      }
  }
  
  /**
   * Used for easily adding entity-dependent animations. The second and third float params here are the same second
   * and third as in the setRotationAngles method.
   */
  public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
  {
      EntityZertum entityzertum = (EntityZertum)par1EntityLivingBase;
      
      this.RightHindLeg1.rotateAngleX = RightHindLeg1.rotateAngleX + MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
      this.LeftHindLeg1.rotateAngleX = LeftHindLeg1.rotateAngleX + MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3;
      this.RightLeg.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3;
      this.LeftLeg.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;
  
      this.Head.rotateAngleZ = entityzertum.getInterestedAngle(par4) + entityzertum.getShakeAngle(par4, 0.0F);
      this.Mane1.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.08F);
      this.Torso.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.16F);
      this.Tail1.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.32F);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
  {
    super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity);
    this.Head.rotateAngleX = par5 / (280F / (float)Math.PI);
    this.Head.rotateAngleY = par4 / (180F / (float)Math.PI);
    this.Mane1.rotateAngleY = par4 / (180F / (float)Math.PI);
    //this.Tail1.rotateAngleX = par3;
  }
}

 

Here is what it SUPPOSE to look like:

width=727 height=467http://i1319.photobucket.com/albums/t661/Nova_Leary/ZertumRedesign_zpsf00afd39.png[/img]

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

You keep adding on to your angles so even with a trig function that goes negative, if you keep adding on to your previous it will still generally accumulate in a weird way.  Instead I think you should have a fixed starting angle for each leg and only add the trig to that. 

 

Maybe something like:

this.RightHindLeg1.rotateAngleX = rightLegStartingRotation + MathHelper.cos(par2 * 0.6662F) * 1.4F * par3;

 

Where you should replace rightLegStartingRotation with whatever value the middle of the animation is supposed to have (maybe 0 in your case).  Do that for each rotation.

 

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! also yes, I read the FAQ.
    • Please read the FAQ (link is orange banner at top of page), and post logs as described there, to an external site such as https://mclo.gs  
    • Hi! I've got a modpack with about 56 mods that has, up until now, been running pretty well. Starting today, any world i try to open causes minecraft to crash. It isn't the game itself- the main menu opens up fine.  I tried changing the ram allocated with both the minecraft launcher, and the forge launcher. No success with either. I tried deleting the JEI folder and letting it remake itself. No success. I tried turning off multiple mods. No success. I tried turning off JEI incase that was the issue. No dice. If you need to know specifically which mods I have installed, let me know, and I'll send them all to you. I've included the very first crash log. Please let me know if there's anything I can do! https://pastebin.com/Zfv6gWN7 -- Crash log on Pastebin (if this doesnt work, let me know)
    • I had this issue on ftb-stoneblock-3-1.11.5 (most recent version right now, installed through CurseForge), but my friend didn't get it when installing the same pack in the same way. I tried reinstalling the modpack several times, didn't help. I later finally solved it by updating REI Plugin Compatibilities (REIPC) in my StoneBlock client from version 8.0.69 to 8.0.89 (the most recent one as of now).
    • Delete the personality-client.toml file in your config folder and add this mod: https://www.curseforge.com/minecraft/mc-mods/night-config-fixes  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.