Jump to content

[1.7.10]Mob not attacking player


ryancpexpert

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.