@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; }
/** * 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.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;
--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;
@Override public boolean shouldExecute() { EntityPlayer player = entity.world.getClosestPlayerToEntity(entity, entity.getButterfly().getGenome().getPrimary().getFlightDistance()); if (player == null || player.isSneaking()) { return false; } if (!entity.getEntitySenses().canSee(player)) { return false; } flightTarget = getRandomDestination(); if (flightTarget == null) { return false; } if (player.getDistanceSq(flightTarget.x, flightTarget.y, flightTarget.z) < player.getDistance(entity)) { return false; } entity.setDestination(flightTarget); entity.setState(EnumButterflyState.FLYING); return true; }
@Override public void updateTask() { if (attackTime > 0) { attackTime--; } else { EntityLivingBase target = entity.getAttackTarget(); if (target != null) { double d0 = this.entity.getDistanceSq(target.posX, target.getEntityBoundingBox().minY, target.posZ); boolean canSee = this.entity.getEntitySenses().canSee(target); boolean couldSee = this.seeTime > 0; if (canSee != couldSee) { this.seeTime = 0; } if (canSee) { ++this.seeTime; this.entity.faceEntity(target, 19.0F, 10.0F); this.entity.getLookHelper().setLookPositionWithEntity(target, 30.0F, 30.0F); } else { --this.seeTime; } if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) { attack(target); this.attackTime = attackCooldown; entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20)); } else { this.entity.getNavigator().tryMoveToEntityLiving(target, 1.0); } } } }
boolean canSee = entityHost.getEntitySenses().canSee(attackTarget2);
@Override public void onCollideWithPlayer(EntityPlayer player) { super.onCollideWithPlayer(player); if (player.isSneaking()) player.setSneaking(false); byte duration = 0; if (!getEntityWorld().isRemote && player.getEntityBoundingBox().maxY >= getEntityBoundingBox().minY && player.getEntityBoundingBox().minY <= getEntityBoundingBox().maxY && captured()) if (getEntityWorld().getDifficulty().ordinal() > 1) if (getEntityWorld().getDifficulty() == EnumDifficulty.NORMAL) duration = 5; else if (getEntityWorld().getDifficulty() == EnumDifficulty.HARD) duration = 10; if (duration > 0 && rand.nextInt(50) == 0) { player.addPotionEffect(new PotionEffect(MobEffects.POISON, duration * 20, 0)); setisStinging(true); getEntityWorld().playSound(null, getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.HOSTILE, 0.5F, 2F); } if (!player.capabilities.isCreativeMode && !getEntityWorld().isRemote && !captured()) if(getEntitySenses().canSee(player)) player.startRiding(this, true); }
@Override public void updateTask() { double distance = this.dilophosaurus.getDistanceSq(this.target.posX, this.target.getEntityBoundingBox().minY, this.target.posZ); boolean canSee = this.dilophosaurus.getEntitySenses().canSee(this.target);