net.minecraft.entity.ai.EntityAINearestAttackableTarget Java Examples

The following examples show how to use net.minecraft.entity.ai.EntityAINearestAttackableTarget. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityAINearestAttackableCivTarget.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
public EntityAINearestAttackableCivTarget(EntityToroNpc npc) {
	super(npc, false, false);

	this.taskOwner = npc;
	this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(npc);
	this.setMutexBits(1);

	this.targetEntitySelector = new Predicate<EntityPlayer>() {
		public boolean apply(@Nullable EntityPlayer target) {

			if (target == null) {
				return false;
			}

			if (!EntitySelectors.NOT_SPECTATING.apply(target)) {
				return false;
			}

			if (!isSuitableTarget(taskOwner, target, false, true)) {
				return false;
			}

			return shouldAttackPlayerBasedOnCivilization(target);
		}
	};
}
 
Example #2
Source File: EntityEnderminy.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
public EntityEnderminy(World world) {
  super(world);
  setSize(0.6F * 0.5F, 2.9F * 0.25F);
  stepHeight = 1.0F;

  tasks.addTask(0, new EntityAISwimming(this));
  tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
  tasks.addTask(7, new EntityAIWander(this, 1.0D));
  tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  tasks.addTask(8, new EntityAILookIdle(this));
  targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));

  if(attackIfLookingAtPlayer) {
    targetTasks.addTask(2, new AIFindPlayer());
  }

  if(attackCreepers) {
    targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityCreeper>(this, EntityCreeper.class, true, true));
  }
}
 
Example #3
Source File: EntityGuard.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
protected void initEntityAI() {
	areaAI = new EntityAIMoveIntoArea(this, 0.5D, 30);
	tasks.addTask(0, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.6D, false));
	tasks.addTask(4, areaAI);
	tasks.addTask(7, new EntityAIWander(this, 0.35D));
	tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));

	targetTasks.addTask(2, new EntityAINearestAttackableCivTarget(this));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityMob>(this, EntityMob.class, 10, false, false, new Predicate<EntityMob>() {
		@Override
		public boolean apply(EntityMob target) {
			return !(target instanceof EntityCreeper);
		}
	}));
}
 
Example #4
Source File: EntityRainbowGuard.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void ai() {
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAtAttention(this));
	tasks.addTask(4, new EntityAIAttackMelee(this, 0.5D, false));
	tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(5, new EntityAILookIdle(this));
	targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
 
Example #5
Source File: EntityClayGolem.java    From Artifacts with MIT License 5 votes vote down vote up
public EntityClayGolem(World par1World)
{
    super(par1World);
    //this.moveSpeed = 0.16F;
    /*this.setSize(1.4F, 2.9F);
    this.getNavigator().setAvoidsWater(true);
    this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.288D, false));
    this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityZombie.class, 0.288D, true));
    this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 0.16D));
    this.tasks.addTask(4, new EntityAIWander(this, 0.16D));
    this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(6, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityZombie.class, 0, true));
    //this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true, true, IMob.mobSelector));
    //this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityZombie.class, 0, false, true, IMob.mobSelector));*/
    this.getNavigator().setAvoidsWater(true);
    this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
    this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
    this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D));
    this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, 1.0D, false));
    this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(7, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
}
 
Example #6
Source File: DroneAINearestAttackableTarget.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public DroneAINearestAttackableTarget(EntityDrone drone, boolean checkSight, boolean easyTargetsOnly,
        ProgWidget widget){
    super(drone, checkSight, easyTargetsOnly);
    this.drone = drone;
    this.widget = widget;
    theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(drone);
    setMutexBits(1);
}
 
Example #7
Source File: EntityWitherWitch.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public EntityWitherWitch(World world) {
  super(world);
  rangedAttackAI = new EntityAIRangedAttack(this, 1, 60, 10);
  tasks.addTask(1, new EntityAISwimming(this));
  tasks.addTask(1, new EntityAISwimming(this));    
  tasks.addTask(2, rangedAttackAI);
  tasks.addTask(2, new EntityAIWander(this, 1.0D));
  tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  tasks.addTask(3, new EntityAILookIdle(this));
  targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
  targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true));
}
 
Example #8
Source File: EntityFallenMount.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public EntityFallenMount(World world) {
  super(world);
  setGrowingAge(0);
  setHorseSaddled(true);

  tasks.taskEntries.clear();
  tasks.addTask(0, new EntityAISwimming(this));
  tasks.addTask(6, new EntityAIWander(this, 1.2D));
  tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
  tasks.addTask(8, new EntityAILookIdle(this));

  findTargetAI = new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true);
  attackAI = new EntityAIAttackMelee(this, MOUNTED_ATTACK_MOVE_SPEED, false);
  updateAttackAI(); 
}
 
Example #9
Source File: EntityArcher.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public EntityArcher(World par1World) {
    super(par1World);
    this.isImmuneToFire = true;
    this.tasks.addTask(1, new EntityAISwimming(this));
    this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector));
    this.tasks.addTask(4, new EntityAIWander(this, 0.30D));
}
 
Example #10
Source File: EntityHalloweenCow.java    From Moo-Fluids with GNU General Public License v3.0 5 votes vote down vote up
protected void applyEntityAI() {
  this.tasks.addTask(4, new EntityHalloweenCow.AICowAttack(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
  targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityPlayer>
      (this, EntityPlayer.class, true));
  targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityVillager>
      (this, EntityVillager.class, false));
  targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityIronGolem>
      (this, EntityIronGolem.class, true));
}
 
Example #11
Source File: EntityEndermite.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public EntityEndermite(World world) {
	super(world);
	sorter = new EntityAINearestAttackableTarget.Sorter(this);

	experienceValue = 3;
	setSize(0.4F, 0.3F);
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
	tasks.addTask(3, new EntityAIWander(this, 1.0D));
	tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));
	targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 10, true));
}
 
Example #12
Source File: TransIconHerobrineButWithBetterPantsEntity.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void initEntityAI() {
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIWander(this, 0.6));
    this.tasks.addTask(2, new EntityAIAttackRanged(this, 0.6, 20, 6.0F));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 32.0F));
    this.tasks.addTask(8, new EntityAILookIdle(this));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, NotchButWithWorsererPantsEntity.class, false));
}
 
Example #13
Source File: EntityBas.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void ai() {
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.5D, false));
	tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(3, new EntityAILookIdle(this));
	targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
 
Example #14
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void ai() {
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackRanged(this, 1.0D, 16, 10.0F));
	tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(3, new EntityAILookIdle(this));
	targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
 
Example #15
Source File: EntitySentry.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(0, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.5D, false));
	tasks.addTask(7, new EntityAIWander(this, 0.35D));
	tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));

	targetTasks.addTask(2, new EntityAINearestAttackableCivTarget(this));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityMob>(this, EntityMob.class, 2, false, false, new Predicate<EntityMob>() {
		@Override
		public boolean apply(EntityMob target) {
			return !(target instanceof EntityCreeper);
		}
	}));
}
 
Example #16
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(1, new EntityAIStayCentered(this));
	tasks.addTask(4, new AIAttack(this));
	tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 20.0F));
	targetTasks.addTask(1,
			new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new MonolithEyeTargetSelector(this)));
}
 
Example #17
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.4D, false));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityToroNpc.class, true));
	targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
	targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntityAnimal.class, false));
}
 
Example #18
Source File: EntityAINearestAttackableTargetFiltered.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public EntityAINearestAttackableTargetFiltered(EntityCreature creature, Class<T> classTarget, int chance, boolean checkSight, boolean onlyNearby, @Nullable final Predicate<? super T> targetSelector) {
	super(creature, checkSight, onlyNearby);
	this.targetClass = classTarget;
	this.targetChance = chance;
	this.sorter = new EntityAINearestAttackableTarget.Sorter(creature);
	this.setMutexBits(1);

	UUID exclude = creature.getEntityData().getUniqueId("owner");

	this.targetEntitySelector = (Predicate<T>) entity -> (entity != null && !entity.getUniqueID().equals(exclude)) && (targetSelector == null || targetSelector.apply(entity) && (EntitySelectors.NOT_SPECTATING.apply(entity) && EntityAINearestAttackableTargetFiltered.this.isSuitableTarget(entity, false)));
}
 
Example #19
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public EntityFallenKnight(World world) {
  super(world);
  targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityVillager>(this, EntityVillager.class, false));
}
 
Example #20
Source File: EntitySpiritWight.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void applyEntityAI() {
	targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
}