Jump to content

[Solved] Mobs won't animate


Jacknoshima

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been trying to give a little transparency to a block and a custom model, but I'm running into the same issue with the transparency of the block Some guides say I use ItemBlockRenderTypes.setRenderLayer in a ClientEvent class but its deprecated, I already tried to set a Properties in Properties.copy(Blocks.FLOWERPOT) But the render in game still doesn't has transparency, only as an Item  
    • My friends and I are modding to survive But recently I want to use cmd to open the server instead of making the single player game public But when I used two methods to start the server, I encountered two problems first A I used forge to install the server files Created using the original server jar The server was installed successfully and the mod was also loaded successfully. But after I replaced the world file with my survival map, I found that the mod items inside disappeared but could be taken from creation again. So I tried to install the server using forge first B I have studied forge for a long time but successfully installed it. But when I put in mods it crashed But mods can be installed on the server   我和我的朋友們正在mod為了生存 但是最近我想用cmd打開伺服器而不是把單人遊戲公開 但是當我使用兩種方法啟動伺服器時,我遇到了兩個問題 首先AI使用forge安裝伺服器檔案使用原始伺服器jar 建立伺服器已成功安裝,mod 也已成功載入。但是當我用我的生存地圖替換世界文件後,我發現裡面的mod物品消失了,但可以再次從創建中取出。所以我嘗試先使用forge安裝伺服器,BI研究了forge很久但成功安裝了它。但是當我安裝 mods 時它崩潰了但是 mods 可以安裝在伺服器上 我和我的朋友正在mod生存 但最近我想使用cmd開啟伺服器而不是單人遊戲公開   但是當我使用了兩種方法開啟伺服器時遇到了兩種問題   第1個A 我使用了forge安裝伺服器文件 在使用原版伺服器jar建立    伺服器安裝成功 mod也順利加載  但是我將我的生存地圖替換世界文件後發現裡面的mod物品消失了但可以再次從創造拿取  所以我嘗試使用forge安裝伺服器   第2個B forge我研究了很久但也成功安裝了 但是當我放入 mods 之後發生了崩潰 但是mods在1A伺服器上是可以安裝的 Ps 我用谷歌翻譯 so    
    • That’s probably not it because as I stated I’ve done it before. I did it like deadass 10 - 20 times when trying to learn to make this mod pack because I kept wanting to reset my profiles and such. So it definitely works, it looks like maybe the creephosting files were the things that couldn’t be reached I tried reading the crash log
    • I don't know if this is the right place or not, but I have put together a custom modpack and I am in need of others to help me. It's a questing modpack with a lore book i'm currently writing out through Patchouli, and i am in need of somebody who will assist me in making the quests for the pack. It's a Zombie apocalypse modpack inspired by Deceasedcraft  with a tinge of magic and RPG mechanics via Mine and slash. Is there anybody willing to assist me as i'm one person building a modpack I could also use help with optimizations since that's not really my strong suite. 
    • File a report to SPYRECOVERY36 @ gmail com he can legitimately assist in proper review and recovery of all your assets that was stolen. Endeavor to submit your request for a refund to his mail . He also spy and hack any device remotely without any trace. Contact via spyrecovery36 @ gm ail com  
  • Topics

×
×
  • Create New...

Important Information

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