Jump to content

[Solved] Mobs won't animate


Jacknoshima
 Share

Recommended Posts

I've made a custom mob, I've got the entity file, the render file and the model file

I know the render file is rendering the model because I added extra objects that are showing up

The only trouble is my mobs won't animate

They won't walk, they just jump from place to place after lagging for about 10 seconds

 

I've looked over ever entity, render and model file in vanilla to find out what I'm missing, I've checked over the code at least a hundred times, everything is how it should be, I just can't work out what's missing

 

I'll add the code for the three files below

 

Render File

 

package deadworld;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderDemon extends RenderLiving
{
    private ModelBiped field_82434_o;
    protected ModelBiped field_82437_k;
    protected ModelBiped field_82435_l;
    protected ModelDemon modelBipedMain;
    protected static EntityDemon entitydemon;
    private int field_82431_q = 1;

    public RenderDemon(ModelBase modelBase, float par1)
    {
        super(new ModelDemon(), 0.5F);
        this.modelBipedMain = (ModelDemon)modelBase;
	// TODO Auto-generated constructor stub
}
    
    public void renderMummyPharaoh(EntityDemon entityMummyPharaoh, double par2, double par4, double par6, float par8, float par9){
// this.entityMummyPharaoh = entityMummyPharaoh;
        super.doRenderLiving(entitydemon, par2, par4, par6, par8, par9);
    }

    
    
    protected int func_82429_a(EntityDemon par1EntityDemon, int par2, float par3)
    {
        EntityLiving EntityDemon;
	this.func_82427_a(par1EntityDemon);
        return super.shouldRenderPass(par1EntityDemon, par2, par3);
}

private void func_82427_a(EntityLiving par1EntityDemon) {
	// TODO Auto-generated method stub

}

public void func_82426_a(EntityDemon par1EntityDemon, double par2, double par4, double par6, float par8, float par9)
    {
        this.func_82427_a(par1EntityDemon);
        super.doRenderLiving(par1EntityDemon, par2, par4, par6, par8, par9);
    }

    protected void func_82430_a(EntityDemon par1EntityDemon, float par2, float par3, float par4)
    {

        super.rotateCorpse(par1EntityDemon, par2, par3, par4);
    }

    /**
     * Queries whether should render the specified pass or not.
     */
    protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3)
    {
        return this.func_82429_a((EntityDemon)par1EntityLiving, par2, par3);
    }

    protected void rotateCorpse(EntityLiving par1EntityLiving, float par2, float par3, float par4)
    {
        this.func_82430_a((EntityDemon)par1EntityLiving, par2, par3, par4);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    @Override
    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    {
        this.func_82426_a((EntityDemon)par1EntityLiving, par2, par4, par6, par8, par9);
    }
    
    @Override
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.func_82426_a((EntityDemon)par1Entity, par2, par4, par6, par8, par9);
    }
}

 

 

Model File

 

package deadworld;

import java.util.Random;

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

public class ModelDemon extends ModelBase
{
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;
    ModelRenderer Shape1;
    ModelRenderer Shape2;
  
  public ModelDemon()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-4F, -8F, -4F, 8, 8, ;
      head.setRotationPoint(0F, 0F, 0F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 16, 16);
      body.addBox(-4F, 0F, -2F, 8, 12, 4);
      body.setRotationPoint(0F, 0F, 0F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      rightarm = new ModelRenderer(this, 40, 16);
      rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);
      rightarm.setRotationPoint(-5F, 2F, 0F);
      rightarm.setTextureSize(64, 32);
      rightarm.mirror = true;
      setRotation(rightarm, 0F, 0F, 0F);
      leftarm = new ModelRenderer(this, 40, 16);
      leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);
      leftarm.setRotationPoint(5F, 2F, 0F);
      leftarm.setTextureSize(64, 32);
      leftarm.mirror = true;
      setRotation(leftarm, 0F, 0F, 0F);
      rightleg = new ModelRenderer(this, 0, 16);
      rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      rightleg.setRotationPoint(-2F, 12F, 0F);
      rightleg.setTextureSize(64, 32);
      rightleg.mirror = true;
      setRotation(rightleg, 0F, 0F, 0F);
      leftleg = new ModelRenderer(this, 0, 16);
      leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      leftleg.setRotationPoint(2F, 12F, 0F);
      leftleg.setTextureSize(64, 32);
      leftleg.mirror = true;
      setRotation(leftleg, 0F, 0F, 0F);
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 1, 6, 1);
      Shape1.setRotationPoint(4F, -11F, -1F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 0);
      Shape2.addBox(0F, 0F, 0F, 1, 6, 1);
      Shape2.setRotationPoint(-5F, -11F, -1F);
      Shape2.setTextureSize(64, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    head.render(f5);
    body.render(f5);
    rightarm.render(f5);
    leftarm.render(f5);
    rightleg.render(f5);
    leftleg.render(f5);
    Shape1.render(f5);
    Shape2.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    
    
    this.leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    
    this.rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
  }
  
  /**
   * 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(EntityLiving par1EntityLiving, float par2, float par3, float par4) {}

  public ModelRenderer getRandomModelBox(Random par1Random)
  {
      return (ModelRenderer)this.boxList.get(par1Random.nextInt(this.boxList.size()));
  }

}

 

 

Entity File

 

package deadworld;

import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityDemon extends EntityMob {

private int angerLevel = 0;
private int randomSoundDelay;

public EntityDemon(World par1World) {
super(par1World);
this.texture = "/mods/jnoshima_deadworld/textures/mobs/demon.png";
this.moveSpeed = 0.10F;
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));
this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(3, new EntityAIWander(this, this.moveSpeed));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));
}

@Override
public int getMaxHealth() {
	return 22;
}

protected boolean isAIEnabled() {
	return true;
    }

public int getAttackStrength(Entity par1Entity) {
	return 8;
}

public String getHurtSound() {
	return "mob.zombie.hurt";
}

public String getDeathSound() {
	return "mob.zombie.death";
}
}

 

 

Part in the main file where I registered the entity and render

 

	EntityRegistry.registerModEntity(EntityDemon.class, "Demon", 2, this, 42, 252, true);
	EntityRegistry.addSpawn(EntityDemon.class, 100, 1, 2, EnumCreatureType.monster, Deadworld.deadBiome);
	LanguageRegistry.instance().addStringLocalization("entity.EntityDemon.Deadworld.name", "Demon");

	RenderingRegistry.registerEntityRenderingHandler(EntityDemon.class, new RenderDemon(null, 0));

 

 

So, unless I'm, literally, missing another file that animates the mob, I have no idea what I'm missing and if it is another file, I have no idea which it is

 

Any help would be appreciated, because I'm officially out of ideas

Link to comment
Share on other sites

... you know those moments where you're very happy but also want to scream because the solution was so simple?

 

I'm having that now

 

Thank you

That worked :D

In which case, what was the number you used? That would be nice, because I don't really know; I was just guessing and I need help with entities myself.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

I lowered it incrementally

... tbh I don't even know why it was so high

in the end I just used 1

 

so it's

 

EntityRegistry.registerModEntity(EntitySpiritMob.class, "Spirit", 1, this, 41, 1, true);

 

It was kinda jumpy at 10 but a lot better, so I imagine 1 - 5 would work nicely

Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

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