@Nullable @Override protected Vec3d getPosition() { return RandomPositionGenerator.findRandomTarget(skater, 16, 0); } }
@Nullable protected Vec3d getRandomDestination() { if (entity.isInWater()) { return getRandomDestinationUpwards(); } Vec3d entityPos = new Vec3d(entity.posX, entity.posY, entity.posZ); Vec3d randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(entity, 16, 7, entityPos); if (randomTarget != null && validateDestination(randomTarget, false)) { return randomTarget; } return null; }
protected Vec3d getWanderPosition() { return RandomPositionGenerator.getLandPos(this.entity, 10, 10); }
public Path getPathToEntityLiving(EntityAnimal entityIn, EntityCyclops cyclops) { PathNavigate navi = entityIn.getNavigator(); Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(entityIn, 2, 7, new Vec3d(cyclops.posX, cyclops.posY, cyclops.posZ)); if(vec3d != null){ BlockPos blockpos = new BlockPos(vec3d); return navi.getPathToPos(blockpos); } return null; } }
@Nullable private Path getPathToTarget(EntityAgeable npc) { Path path = npc.getNavigator().getPathToPos(pos); if (path != null) return path; else { //Grab a random block towards the target Vec3d vec = RandomPositionGenerator.findRandomTargetBlockTowards(npc, 10, 7, new Vec3d((double) pos.getX() + 0.5D, (double) pos.getY() + 1D, (double) pos.getZ() + 0.5D)); if (vec != null) { return npc.getNavigator().getPathToPos(new BlockPos(vec)); } else return null; } }
@Nullable @Override protected Vec3d getPosition() { return RandomPositionGenerator.findRandomTarget(locust, 32, 32); } }
@Nullable private Path getPathAwayFromTarget() { Vec3d vec = RandomPositionGenerator.findRandomTargetBlockAwayFrom(npc, (int) distanceRequired / 2, 3, new Vec3d((double) blockTarget.getX() + 0.5D, (double) blockTarget.getY(), (double) blockTarget.getZ() + 0.5D)); if (vec != null) { blockTarget = new BlockPos(vec); //Update the target, so we don't teleport back return npc.getNavigator().getPathToPos(blockTarget); } else return null; }
@Nullable private Path getPathToTarget() { Path path = npc.getNavigator().getPathToPos(blockTarget); if (path != null) return path; else { //Grab a random block towards the target Vec3d vec = RandomPositionGenerator.findRandomTargetBlockTowards(npc, 16, 7, new Vec3d((double) blockTarget.getX() + 0.5D, (double) blockTarget.getY(), (double) blockTarget.getZ() + 0.5D)); if (vec != null) { return npc.getNavigator().getPathToPos(new BlockPos(vec)); } else return null; } }
/** * Find a good place within the restaurant to eat. * @return the next state to go to. */ private STATE findPlaceToEat() { if (placeToPath == null) { final Vec3d placeToEat = RandomPositionGenerator.getLandPos(citizen, PLACE_TO_EAT_DISTANCE, 0); if (placeToEat == null) { waitingTicks = 0; return EAT; } placeToPath = new BlockPos(placeToEat); } if (citizen.isWorkerAtSiteWithMove(placeToPath, MIN_DISTANCE_TO_RESTAURANT)) { waitingTicks = 0; return EAT; } return FIND_PLACE_TO_EAT; }
@Nullable protected Vec3d getPosition() { return RandomPositionGenerator.findRandomTarget(entity, 32, 32); }
@Override public boolean shouldExecute() { if (!npc.getIsAIEnabled()) return false; // assume not fleeing, reduce fear level early if (fearLevel > 0) fearLevel--; ticker++; if (ticker != TICKER_MAX) return false; ticker = 0; boolean flee = false; findNearbyRelevantEntities(); if (!npc.nearbyHostiles.isEmpty()) { Entity nearestHostile = npc.nearbyHostiles.iterator().next(); if (npc.getTownHallPosition().isPresent() || npc.hasHome()) flee = true; else { fleeVector = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.npc, MAX_FLEE_RANGE, HEIGHT_CHECK, new Vec3d(nearestHostile.posX, nearestHostile.posY, nearestHostile.posZ)); flee = fleeVector != null && nearestHostile.getDistanceSq(fleeVector.x, fleeVector.y, fleeVector.z) >= nearestHostile.getDistanceSq(this.npc); } if (flee) { if (nearestHostile instanceof EntityLivingBase) npc.setAttackTarget((EntityLivingBase) nearestHostile); else AncientWarfareNPC.LOG.error("Attempted to flee an entity that isn't EntityLiving: '" + EntityList.getEntityString(nearestHostile) + "', ignoring! Please report this error."); } } return flee; }
/** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.insidePosX = -1; BlockPos blockpos = this.doorInfo.getInsideBlockPos(); int i = blockpos.getX(); int j = blockpos.getY(); int k = blockpos.getZ(); if (this.entityObj.getDistanceSq(blockpos) > 256.0D) { Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.entityObj, 14, 3, new Vec3d((double) i + 0.5D, (double) j, (double) k + 0.5D)); if (vec3d != null) { this.entityObj.getNavigator().tryMoveToXYZ(vec3d.x, vec3d.y, vec3d.z, 1.0D); } } else { this.entityObj.getNavigator().tryMoveToXYZ((double) i + 0.5D, (double) j, (double) k + 0.5D, 1.0D); } } }
@Override protected Vec3d getWanderPosition() { Vec3d vec3d = null; for(int i = 0; i < 100; i++) { Vec3d vec = RandomPositionGenerator.getLandPos(this.entity, 32, 7); if(vec == null) { continue; } else if(vec3d == null || this.entity.getPositionVector().distanceTo(vec) < this.entity.getPositionVector().distanceTo(vec3d)) { vec3d = vec; } } return vec3d == null ? super.getWanderPosition() : vec3d; }
@Override public boolean shouldExecute() { if (this.swimmingEntity.getRNG().nextFloat() < 0.50) { return false; } Vec3d target = RandomPositionGenerator.findRandomTarget(this.swimmingEntity, 6, 2); if (target == null) { return false; } else { this.xPosition = target.x; this.yPosition = target.y; this.zPosition = target.z; return true; } }
/** * Returns whether the EntityAIBase should begin execution. */ @Override public boolean shouldExecute() { if (!this.theEntity.shouldEmergencyHeal()) { return false; } //This part almost doesn't matter List<T> list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector)); if (list.isEmpty()) { return true; //No entities nearby, so I can freely heal } else { this.closestLivingEntity = list.get(0); Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); if (vec3d == null) { return false; //Nowhere to run, gotta fight! } else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSq(this.theEntity)) { return false; //I'll be headed off if I choose this direction. } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z); return this.entityPathEntity != null; } } }
private void attemptToTeleportToSafety(BlockPos go) { Vec3d vec = RandomPositionGenerator.findRandomTargetBlockTowards(npc, 3, 32, new Vec3d((double) go.getX() + 0.5D, (double) go.getY() + 1D, (double) go.getZ() + 0.5D)); if (vec != null) { BlockPos pos = new BlockPos(vec); if (EntityHelper.isSpawnable(npc.world, pos) && EntityHelper.isSpawnable(npc.world, pos.up()) && npc.world.getBlockState(pos.down()).isSideSolid(npc.world, pos.down(), EnumFacing.UP)) { npc.setPositionAndUpdate(pos.getX() + 0.5D, pos.getY() + 1D, pos.getZ() + 0.5D); } } }
/** * {@inheritDoc} * Returns whether the EntityAIBase should begin execution. * True when age less than 100, when a random (120) is chosen correctly, and when a citizen is nearby. */ @Override public boolean shouldExecute() { if (isTooOld() || checkForRandom() || citizen.getDesiredActivity() == DesiredActivity.SLEEP) { return false; } Vec3d vec3d = null; if(vec3d == null) { vec3d = RandomPositionGenerator.getLandPos(citizen, 10, 7); if (vec3d == null) { return false; } } vec3d = new Vec3d(vec3d.x, BlockPosUtil.getValidHeight(vec3d, CompatibilityUtils.getWorld(citizen)), vec3d.z); this.xPosition = vec3d.x; this.yPosition = vec3d.y; this.zPosition = vec3d.z; return true; }
@Override public boolean shouldExecute() { int chance = executionChance; if (isOnLeaves()) { chance *= 2; } if (entity.getRNG().nextInt(chance) != 0) { return false; } Vec3d vec3 = RandomPositionGenerator.findRandomTarget(entity, 4, 2); if (vec3 == null || entity.posY - vec3.y < -2) { return false; } randPosX = vec3.x; randPosY = vec3.y; randPosZ = vec3.z; return true; }
@Override public boolean shouldExecute() { if (this.entity.attackStateMachine == 2) { EntityLivingBase attacked = this.entity.getAttackTarget(); if (attacked == null) { return false; } Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, 16, 7, new Vec3d(attacked.posX, attacked.posY, attacked.posZ)); if (vec3d == null) { return false; } else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSq(this.entity)) { return false; } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z); return this.entityPathEntity != null; } } return false; }
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, new Vec3d((double) this.doorInfo.getDoorBlockPos().getX(), (double) this.doorInfo.getDoorBlockPos().getY(), (double) this.doorInfo.getDoorBlockPos().getZ()));