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

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;
	}
}

 

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 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.

  • 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?

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.

  • 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 by Eria8

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.

  • 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.

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.

  • 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!

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.

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.