Posted March 5, 20169 yr So I've written a custom Entity; nothing special, it just extends EntityTameable, follows the player around and attacks stuff for them. The only difference is that it's summoned from an item, rather than tamed in the traditional way. However, when the user quits, then comes back in, the entity takes damage until it dies. Here's the class in case it's needed: package com.nosrick.masterofmagic.entities; import java.util.UUID; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityOwnable; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntityGuardianSpirit extends EntityTameable implements IEntityOwnable { public EntityGuardianSpirit(World worldIn) { super(worldIn); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(2, new EntityAIFollowOwner(this, 0.4D, 10.0F, 2.0F)); this.tasks.addTask(3, new EntityAIWander(this, 0.2D)); this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(4, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); // standard attributes registered to EntityLivingBase getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.80D); getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.8D); getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); // need to register any additional attributes getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); } @Override public String getOwnerId() { return this.dataWatcher.getWatchableObjectString(17); } @Override public EntityLivingBase getOwner() { UUID uuid = UUID.fromString(this.getOwnerId()); EntityPlayer owner = this.worldObj.getPlayerEntityByUUID(uuid); return owner; } public void setOwnerId(String owner) { this.dataWatcher.updateObject(17, owner); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } }
March 5, 20169 yr Author Sorry for the double post, but I'm going to use this thread to log my adventures in case anyone else has the same problem. It seems the entity is taking damage from an "inWall" source, even when they are standing in the middle of an open field. I'm not sure why.
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.