Posted May 30, 201510 yr 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!
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.