@Override protected boolean shouldCloseOnTarget(double dist) { return (dist > attackDistance || !this.npc.getEntitySenses().canSee(getTarget())); }
public static boolean isTarget(NpcBase npc, @Nullable EntityLivingBase target, boolean checkSight) { return target != null && !(target == npc || !target.isEntityAlive() || !npc.canTarget(target) || target instanceof EntityPlayer && ((EntityPlayer) target).capabilities.disableDamage || checkSight && !npc.getEntitySenses().canSee(target)); }
public boolean apply(@Nullable Entity entity) { return entity.isEntityAlive() && PixieAIFlee.this.pixie.getEntitySenses().canSee(entity) && !PixieAIFlee.this.pixie.isOnSameTeam(entity); } };
public boolean apply(@Nullable Entity entity) { return entity instanceof EntityPlayer && entity.isEntityAlive() && StymphalianBirdAIFlee.this.stymphalianBird.getEntitySenses().canSee(entity) && !StymphalianBirdAIFlee.this.stymphalianBird.isOnSameTeam(entity); } };
@Override protected boolean shouldCloseOnTarget(double dist) { return (dist > getAttackDistanceSq() || !this.npc.getEntitySenses().canSee(this.getTarget())); }
@Override protected boolean shouldCloseOnTarget(double distanceToEntity) { double attackDistance = (npc.width / 2D) + (getTarget().width / 2D) + attackReach; return (distanceToEntity > (attackDistance * attackDistance)) || !npc.getEntitySenses().canSee(getTarget()) ; }
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { this.canBeSeenSelector = p_apply_1_ -> p_apply_1_.isEntityAlive() && EntityAIRetreatToHeal.this.theEntity.getEntitySenses().canSee(p_apply_1_); this.theEntity = theEntityIn; this.classToAvoid = classToAvoidIn; this.avoidTargetSelector = avoidTargetSelectorIn; this.avoidDistance = avoidDistanceIn; this.farSpeed = farSpeedIn; this.nearSpeed = nearSpeedIn; this.entityPathNavigate = theEntityIn.getNavigator(); this.setMutexBits(3); }
/** * Returns the closest entity to avoid. * * @return Entity to avoid. */ private Entity getClosestToAvoid() { if (targetEntityClass == EntityPlayer.class) { return CompatibilityUtils.getWorld(theEntity).getClosestPlayerToEntity(theEntity, (double) distanceFromEntity); } else { final Optional<Entity> entityOptional = CompatibilityUtils.getWorld(theEntity).getEntitiesInAABBexcluding( theEntity, theEntity.getEntityBoundingBox().expand( (double) distanceFromEntity, 3.0D, (double) distanceFromEntity), target -> target.isEntityAlive() && EntityAICitizenAvoidEntity.this.theEntity.getEntitySenses().canSee(target)) .stream() .filter(targetEntityClass::isInstance) .findFirst(); return entityOptional.isPresent() ? entityOptional.get() : null; } }
/** * A static method used to see if an entity is a suitable target through a number of checks. */ public static boolean isSuitableTarget(EntityLiving attacker, @Nullable EntityLivingBase target, boolean includeInvincibles, boolean checkSight) { if (target == null) { return false; } else if (target == attacker) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!attacker.canAttackClass(target.getClass())) { return false; } else if (attacker.isOnSameTeam(target)) { return false; } else { if (attacker instanceof IEntityOwnable && ((IEntityOwnable) attacker).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable) attacker).getOwnerId().equals(((IEntityOwnable) target).getOwnerId())) { return false; } if (target == ((IEntityOwnable) attacker).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer) target).capabilities.disableDamage) { return false; } return !checkSight || attacker.getEntitySenses().canSee(target); } }
@Override public void updateTask() { if (creepAttackTarget == null) { swellingCreep.setCreeperState(-1); } else if (swellingCreep.getDistanceSq(creepAttackTarget) > 49.0D) { swellingCreep.setCreeperState(-1); } else if (!swellingCreep.getEntitySenses().canSee(creepAttackTarget)) { swellingCreep.setCreeperState(-1); } else { swellingCreep.setCreeperState(1); } } }
@Override public boolean shouldExecute() { if (vampire.wantsBlood()) { List<EntityCreature> list = vampireEntity.getEntityWorld().getEntitiesWithinAABB(EntityCreature.class, getBiteBoundingBox()); if (list.size() > 1) { try { list.sort((o1, o2) -> vampireEntity.getDistanceSq(o1) > vampireEntity.getDistanceSq(o2) ? 1 : -1); } catch (Exception e) { //TODO investigate issue //java.lang.IllegalArgumentException: Comparison method violates its general contract! //at java.util.TimSort.mergeHi(TimSort.java:895) //http://openeye.openmods.info/crashes/796f6b43ea81b10156658bd4f662e0c1 } } for (EntityCreature o : list) { if (vampireEntityLiving != null) { if (!vampireEntityLiving.getEntitySenses().canSee(o) || o.hasCustomName()) { continue; } } creature = ExtendedCreature.get(o); if (creature.canBeBitten(vampire)) { return true; } } } creature = null; return false; }
@Override public boolean shouldExecute() { player = mob.world.getClosestPlayerToEntity(mob, minDistance); if (player == null) { return false; } if (!mob.getEntitySenses().canSee(player)) { return false; } Vec3d randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7, new Vec3d(player.posX, player.posY, player.posZ)); if (randomTarget == null) { return false; } if (player.getDistanceSq(randomTarget.x, randomTarget.y, randomTarget.z) < player.getDistance(mob)) { return false; } path = pathNavigator.getPathToXYZ(randomTarget.x, randomTarget.y, randomTarget.z); return path != null; }
if (target != null && !target.isDead && this.entity.getEntitySenses().canSee(target) ) { return false; if (!entity.equals(this.entity) && !entity.isInLava() && this.entity.getEntitySenses().canSee(entity) && this.canAttack(entity)) { double score = entity.getHealth() <= 0.0F ? (this.entity.getDistanceSq(entity) / entity.getHealth()) : 0;
/** * Updates the task */ public void updateTask() { double distanceToTargetSq = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.getEntityBoundingBox().minY, this.attackTarget.posZ); boolean canSee = this.entityHost.getEntitySenses().canSee(this.attackTarget); if (canSee) { lastKnownShootLocation = new Vec3d(attackTarget.prevPosX, attackTarget.prevPosY, attackTarget.prevPosZ); shootPatienceTime = 60; ++this.pathRetryTimer; } else { this.pathRetryTimer = 0; } manageMovingToLastKnowMoveLocation(distanceToTargetSq); if (shootPatienceTime == 0) { lastKnownShootLocation = null; } if (lastKnownShootLocation != null) { manageShooting(canSee, distanceToTargetSq); shootPatienceTime--; } else { this.entityHost.getLookHelper().setLookPosition(attackTarget.posX, attackTarget.posY + attackTarget.getEyeHeight(), attackTarget.posZ, 30.0F, 30.0F); } }
--this.delayCounter; if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F)) { this.targetX = entitylivingbase.posX; this.targetY = entitylivingbase.getEntityBoundingBox().minY;
--this.delayCounter; if ((this.longMemory || this.chicken.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.chicken.getRNG().nextFloat() < 0.05F)) { this.targetX = entitylivingbase.posX; this.targetY = entitylivingbase.getEntityBoundingBox().minY;
--ticksUntilNextPathingAttempt; if ((longMemory || attacker.getEntitySenses().canSee(entitylivingbase)) && ticksUntilNextPathingAttempt <= 0 && (targetX == 0.0D && targetY == 0.0D && targetZ == 0.0D || entitylivingbase.getDistanceSq(targetX, targetY, targetZ) >= 1.0D || attacker.getRNG().nextFloat() < 0.05F)) {
} else { if (this.shouldCheckSight) { if (this.taskOwner.getEntitySenses().canSee(entitylivingbase)) { this.targetUnseenTicks = 0; } else if (++this.targetUnseenTicks > this.unseenMemoryTicks) {
--this.delayCounter; if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F)) { this.targetX = entitylivingbase.posX; this.targetY = entitylivingbase.getEntityBoundingBox().minY;
--delayCounter; if ((longMemory || attacker.getEntitySenses().canSee(entitylivingbase)) && delayCounter <= 0 && (targetX == 0.0D && targetY == 0.0D && targetZ == 0.0D || entitylivingbase.getDistanceSq(targetX, targetY, targetZ) >= 1.0D || attacker.getRNG().nextFloat() < 0.05F)) { targetX = entitylivingbase.posX;