Posted February 12, 20178 yr My mob won't attack or even acknowledge the player. It should have everything else it needs from extending EntityMob, and I don't see any classes like EntityZombie, etc, doing anything special... Is setting its AI not enough? public class Hunter extends EntityMob { public Hunter(World world) { super(world); this.experienceValue = 30; this.setSize(0.5F, 1.8F); } @Override protected void applyEntityAttributes() { this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.01); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_SPEED); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.FOLLOW_RANGE); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.LUCK); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS); } @Override protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } protected boolean canEquipItem(ItemStack stack) { return stack.getItem() instanceof ItemSword || stack.getItem() instanceof MeleeWeapon; } @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); return livingdata; } public float getEyeHeight() { return 1.75F; } protected boolean isValidLightLevel() { return true; } }
February 13, 20178 yr Where did applyEntityAI() go? You probably need that. You don't need the @Override in the applyEntityAttributes, and you need to call the super method on that. Look at the EntityZombie class. EDIT: sorry, I was looking at 1.10 source, this may or may not work for you. EDIT 2: Yes, my suggestion is still the same, look at the EntityZombie class. Edited February 13, 20178 yr by Leomelonseeds Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 14, 20178 yr Author 21 hours ago, Leomelonseeds said: Where did applyEntityAI() go? You probably need that. I only see that in EntityZombie. It seems to be pretty useless and it's not in a super class, so why would I use it?
February 14, 20178 yr 21 hours ago, Leomelonseeds said: You don't need the @Override in the applyEntityAttributes, and you need to call the super method on that Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 14, 20178 yr Author 3 minutes ago, Leomelonseeds said: I'm doing everything in that method that's in all super methods, so that shouldn't matter... Edited February 14, 20178 yr by Eria8
February 14, 20178 yr Still, try. You never know whats gonna work. Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 14, 20178 yr Author Just now, Leomelonseeds said: Still, try. You never know whats gonna work. @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.01); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4); } If I do it that way, every time I try to spawn the mob it cancels the spawn and spams this error: "Caused by: java.lang.IllegalArgumentException: Attribute is already registered!". So I completely removed the method, so that it should all be default attributes, and it still changed nothing. The mob still doesn't target the player. Attributes are not the problem.
February 14, 20178 yr Check out this: http://www.minecraftforge.net/forum/topic/29927-the-entity-attribute-system-how-to-manipulate-it-in-code/ Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 14, 20178 yr Author 29 minutes ago, Leomelonseeds said: Check out this: http://www.minecraftforge.net/forum/topic/29927-the-entity-attribute-system-how-to-manipulate-it-in-code/ Okay that helped fix what I was doing wrong with attributes, but it still does not fix the problem. It's even more evidence that the problem has nothing to do with attributes...
February 15, 20178 yr I think you need to add something like this: this.tasks.addTask(2, new EntityAIZombieAttack(this, 1.0D, false)); Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
February 16, 20178 yr Author On 2/14/2017 at 7:06 PM, Leomelonseeds said: I think you need to add something like this: this.tasks.addTask(2, new EntityAIZombieAttack(this, 1.0D, false)); This is what I was looking for. I thought that was something else, didn't see that it extended the EntityAIMeleeAttack which apparently now gives mobs the AI to actually attack. Now just have to fix its glitchy movement... Thanks!
February 16, 20178 yr No problem. Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.
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.