Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey all, I'm working on a simple npc mod for personal use. EntityNPCCompanion has a Render class that extends RenderBiped and uses ModelBiped. For some reason, whenever I have him extend EntityTameable, he glitches out and falls through the world. :o

 

Here's my code:

 

public class EntityNPCCompanion extends EntityTameable implements IEntityOwnable

{

public EntityNPCCompanion(World world)

{

super(world);

this.setTamed(true);

        this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F));

this.tasks.addTask(1, new EntityAISwimming(this));

this.tasks.addTask(1, new EntityAIWander(this, 1.0D));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

this.tasks.addTask(1, new EntityAILookIdle(this));

}

 

@Override

    public boolean isAIEnabled()

    {

        return true;

    }

 

@Override

public boolean canDespawn()

{

return false;

}

 

@Override

public void applyEntityAttributes()

{

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);

this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);

this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(60.0D);

}

 

@Override

public boolean interact(EntityPlayer player)

    {

        ItemStack itemstack = player.inventory.getCurrentItem();

 

        if(itemstack == null)

        {

        this.func_152115_b(player.getUniqueID().toString());

        return true;

        }

        else

        {

        return true;

        }

    }

 

@Override

public EntityAgeable createChild(EntityAgeable p_90011_1_)

{

return null;

}

}

 

 

Does anyone know what's wrong?

 

Thanks for your help!

FYI, EntityTameable already implements IEntityOwnable, so you don't need to explicitly implement it in your class (although I don't think it hurts).

 

You need to also post your model class code and your code for registering your renderer. Thanks.

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

  • Author

FYI, EntityTameable already implements IEntityOwnable, so you don't need to explicitly implement it in your class (although I don't think it hurts).

 

You need to also post your model class code and your code for registering your renderer. Thanks.

 

Here's my RenderNPC:

 

 

public class RenderNPC extends RenderBiped

{

public RenderNPC(ModelBiped parModelBase, float par2)

{

super(parModelBase, par2);

}

 

@Override

protected ResourceLocation getEntityTexture(Entity entity)

{

return new ResourceLocation("minecraft:textures/entity/steve.png");

}

}

 

 

Here's my ClientProxy:

 

 

public class ClientProxy extends CommonProxy

{

@Override

public void registerRendering()

{

RenderingRegistry.registerEntityRenderingHandler(EntityNPCCompanion.class, new RenderNPC(new ModelBiped(), 0.5F));

}

}

 

 

  • Author

Bumperino.

 

If anyone has a solution to this, I'd appreciate all help!

 

(NOTE: I didn't see anything in the rules banning bumping, so... @_@)

this.setTamed(true);

 

I don't know much about entity tamables but i think you have to set the owner when you set it to tamed.

  • Author

this.setTamed(true);

 

I don't know much about entity tamables but i think you have to set the owner when you set it to tamed.

 

Erm... Not exactly the question I had in the post, but I appreciate the thought!

I can't think of any reason why EntityTameable specifically would cause the entity to glitch like that, which leads me to suspect you changed more than just the parent class.

 

You will need to provide us with some EXACT details: set up your code so it works correctly (no falling through ground) and post that. Then change ONLY the parent class to EntityTameable, NOTHING else, and check if that really does cause the issue.

  • Author

I can't think of any reason why EntityTameable specifically would cause the entity to glitch like that, which leads me to suspect you changed more than just the parent class.

 

You will need to provide us with some EXACT details: set up your code so it works correctly (no falling through ground) and post that. Then change ONLY the parent class to EntityTameable, NOTHING else, and check if that really does cause the issue.

 

What works:

 

public class EntityNPCCompanion extends EntityMob

{

public EntityNPCCompanion(World world)

{

super(world);

this.tasks.addTask(1, new EntityAISwimming(this));

this.tasks.addTask(1, new EntityAIWander(this, 1.0D));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

this.tasks.addTask(1, new EntityAILookIdle(this));

}

 

@Override

    public boolean isAIEnabled()

    {

        return true;

    }

 

@Override

public boolean canDespawn()

{

return false;

}

 

@Override

public void applyEntityAttributes()

{

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);

this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);

this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(60.0D);

}

 

@Override

public boolean interact(EntityPlayer player)

    {

        ItemStack itemstack = player.inventory.getCurrentItem();

 

        if(itemstack == null)

        {

        return true;

        }

        else

        {

        return false;

        }

    }

 

//Commented out because EntityMob didn't like it.

// @Override

// public EntityAgeable createChild(EntityAgeable p_90011_1_)

// {

// return null;

// }

}

 

 

What doesn't work:

 

public class EntityNPCCompanion extends EntityTameable

{

public EntityNPCCompanion(World world)

{

super(world);

this.tasks.addTask(1, new EntityAISwimming(this));

this.tasks.addTask(1, new EntityAIWander(this, 1.0D));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));

this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

this.tasks.addTask(1, new EntityAILookIdle(this));

}

 

@Override

    public boolean isAIEnabled()

    {

        return true;

    }

 

@Override

public boolean canDespawn()

{

return false;

}

 

@Override

public void applyEntityAttributes()

{

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);

this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);

this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(60.0D);

}

 

@Override

public boolean interact(EntityPlayer player)

    {

        ItemStack itemstack = player.inventory.getCurrentItem();

 

        if(itemstack == null)

        {

        return true;

        }

        else

        {

        return false;

        }

    }

 

@Override

public EntityAgeable createChild(EntityAgeable p_90011_1_)

{

return null;

}

}

 

  • Author

Well that certainly is a mystery :\

 

You should at least implement createChild to not return null and see if that makes any difference (don't see why it would, but then I don't see why what you have isn't working).

 

Other than that, I have no idea, sorry.

 

Ah, well, I guess if nothing works I could just have it chase the player as an EntityMob but never actually hurt him. Thanks for your help!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.