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 have created a new entity mob, and gave it the Attack Entity task. I then added more tasks and things, and it seems to have broken it.

 

 

 

public class EntityFreddyMob extends EntityMob{

 

public EntityFreddyMob(World world) {

super(world);

this.setSize(1.0F, 2.0F);

this.tasks.addTask(0, new EntityAIWander(this, 0.5));

this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));

 

}

 

public boolean isAIEnabled() {

return true;

}

 

protected void applyEntityAttributes() {

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5F);

this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(20.0F);

}

@Override

    public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_)

    {

    return false;

    }

 

 

Any help is appreciated.

There's 10 types of people in this world; Those that understand binary and those that don't.

If I remember, you need to include a targetTask.

 

Example:

this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16F, 0, true));

  • Author

It still isn't attacking me, updated code:

 

 

 

public class EntityFreddyMob extends EntityMob{

 

public EntityFreddyMob(World world) {

super(world);

this.setSize(1.0F, 2.0F);

this.tasks.addTask(0, new EntityAIWander(this, 0.5));

this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));

 

}

@Override

public boolean isAIEnabled() {

return true;

}

@Override

protected void applyEntityAttributes() {

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5F);

this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(20.0F);

}

@Override

    public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_)

    {

    return false;

    }

 

}

 

 

I removed the float, as it was giving me an error.

 

EDIT - NVM! Realized that I needed both tasks, problem solved.

There's 10 types of people in this world; Those that understand binary and those that don't.

Guest
This topic is now closed to further replies.

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.