Jump to content

[1.7.10] Tameable entity?


DaveTheModder

Recommended Posts

I've been trying to create a tameable entity, but I hit a roadblock. I can't get it to follow the player. I can do it by telling it to attack the player in the AI, but not actually hurt it, but then, it just keeps following the player at an... uncomfortably... close distance.

 

Here's my code:

 

 

public class EntityFakeWorkbench extends EntityTameable implements IEntityOwnable

{

public EntityFakeWorkbench(World world)

{

super(world);

this.setSize(0.7F, 0.7F);

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(12.0D);

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

}

 

@Override

protected String getLivingSound()

{

return "minecraft:dig.wood";

 

}

 

@Override

protected String getHurtSound()

{

return "minecraft:dig.wood";

}

 

@Override

protected String getDeathSound()

{

return "minecraft:random.chestclosed";

}

 

@Override

public boolean interact(EntityPlayer player)

    {

        ItemStack itemstack = player.inventory.getCurrentItem();

 

        if(itemstack == null)

        {

        int x = (int)player.posX;

        int y = (int)player.posY - 1;

        int z = (int)player.posZ;

        player.openGui(Main.instance, GUIs.WORKBENCH.ordinal(), player.worldObj, x, y, z);

       

        return true;

        }

        else

        {

        return true;

        }

    }

 

@Override

public EntityAgeable createChild(EntityAgeable p_90011_1_)

{

return null;

}

}

 

 

 

How can I make it follow the player? Or, better yet, make it tamed when I right click it with a certain item?

 

Thanks for all help!

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.



×
×
  • Create New...

Important Information

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