Hello, I'm trying to basically do what the title says. I have a passive mob which extends entityliving, and I would like it to attack the player if the player attacks it. I tried taking some code from both the cow and the wolf to try and implement this. Below, is what I have. Currently, it does not attack at all. Also for some reason the movement of my mob in general is very glitchy and random. Any help would be appreciated.
package kmccmk9.witchcraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIBeg;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraft.src.*;
public class EntityBee extends EntityLiving {
public EntityBee(World par1World) {
super(par1World);
this.getNavigator().setAvoidsWater(true);
this.setSize(0.5F, 0.5F);
this.setEntityHealth(25F);
this.setAIMoveSpeed(2F);
this.tasks.addTask(0, new EntityAILookIdle(this));
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(4, new EntityAILookIdle(this));
}
protected int getDropItemId()
{
return Item.porkRaw.itemID;
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i);
}
}