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

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!

Try overriding onUpdate (and don't forget to call the super).

Wiat, also I noticed you have it follow the owner, do you ever set the owner?

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.