private void manageMovingToLastKnowMoveLocation(double distanceToTargetSq) { if (distanceToTargetSq <= (double) this.maxChaseDistanceSq && this.pathRetryTimer >= 20) { if (this.entityHost.getNavigator().getPath() != null && this.entityHost.getNavigator().getPath().equals(lastChasePath)) { this.entityHost.getNavigator().clearPath(); } } else if (this.entityHost.getNavigator().noPath()) { lastChasePath = this.entityHost.getNavigator().getPathToEntityLiving(attackTarget); this.entityHost.getNavigator().setPath(lastChasePath, this.entityMoveSpeed); } }
@Override public void startExecuting() { if (!entity.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, speed)) { // System.out.println("EntityAIFlyingFindPerch.startExecuting: No path"); } }
public void updateTask() { if(this.myrmex.guardingEntity != null && (this.myrmex.getDistance(this.myrmex.guardingEntity) > 30 || this.myrmex.getNavigator().noPath())) { this.myrmex.getNavigator().tryMoveToEntityLiving(this.myrmex.guardingEntity, movementSpeed); } }
public void moveToItem(Entity entity) { Path pathentity = getNavigator().getPathToEntityLiving(entity); if (pathentity != null) { getNavigator().setPath(pathentity, 0.5D); } }
@Override public void updateTask() { if (!started || updatesSincePathing > 20) { started = true; int speed = 1; // mob.getNavigator().setAvoidsWater(false); boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed); if (!res) { mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed); } updatesSincePathing = 0; } else { updatesSincePathing++; } }
@Override public boolean shouldContinueExecuting() { if (this.entityPathNavigate.noPath()) { this.entity.attackStateMachine = 0; return false; } return this.entity.attackStateMachine == 2; }
private boolean isRunningAway() { if (runningAwayTo == null) { return false; } if (getNavigator().noPath()) { runningAwayTo = null; return false; } final Path path = getNavigator().getPath(); PathPoint dest = path != null ? path.getFinalPathPoint() : null; return dest != null && dest.equals(runningAwayTo); }
protected final void setPath(double x, double y, double z) { Path path = trimPath(npc.getNavigator().getPathToXYZ(x, y, z)); npc.getNavigator().setPath(path, moveSpeed); }
/** * Execute a one shot task or start executing a continuous task */ @Override public void startExecuting() { if (this.entityPathEntity != null) { this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed); } }
/** * Resets the task */ @Override public void resetTask() { getNavigator().clearPath(); }
@Override public void updateTask() { Path currentPath = this.entity.getNavigator().getPath(); if (this.shore != null && !this.path.isSamePath(currentPath)) { Path path = this.entity.getNavigator().getPathToPos(this.shore); if (path != null && !path.isSamePath(currentPath)) { this.path = path; this.entity.getNavigator().setPath(path, 1.5); } } } }
@Override public void updateTask() { Path currentPath = this.dinosaur.getNavigator().getPath(); if (this.path != null) { PathPoint finalPathPoint = this.path.getFinalPathPoint(); if (currentPath == null || !currentPath.getFinalPathPoint().equals(finalPathPoint)) { Path path = this.dinosaur.getNavigator().getPathToXYZ(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z); this.dinosaur.getNavigator().setPath(path, 1.0); this.path = path; } } if (this.giveUpTime <= 0 || (this.dinosaur.getStayAwakeTime() <= 0 && (this.path == null || this.path.isFinished()))) { this.dinosaur.setSleeping(true); } this.giveUpTime--; }
@Override public void updateTask() { EntityLivingBase owner = owned.getOwner(); if (owner == null) { return; } double distance = getDistanceSqFromOwner(); if (distance < minDistanceSq) { owned.asEntity().getNavigator().clearPath(); } if (--pathingTimer <= 0) { pathingTimer = 10; owned.asEntity().getNavigator().tryMoveToEntityLiving(owner, followSpeed); } } }
public boolean shouldExecute() { if(!this.myrmex.canMove() || !this.myrmex.shouldEnterHive() && !this.myrmex.getNavigator().noPath() || this.myrmex.canSeeSky()){ return false; } MyrmexHive village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 300); if (village == null) { village = this.myrmex.getHive(); } if (village == null) { return false; } else { target = getNearPos(MyrmexHive.getGroundedPos(this.myrmex.world, village.getCenter())); this.path = this.myrmex.getNavigator().getPathToPos(target); return this.path != null; } }
@Override public boolean tryMoveToEntityLiving(Entity entityIn, double speedIn) { return super.tryMoveToEntityLiving(entityIn, speedIn); }
protected final void setPath(BlockPos pos) { Path path = trimPath(npc.getNavigator().getPathToPos(pos)); npc.getNavigator().setPath(path, moveSpeed); }
@Nullable @Override public Path getPath() { return super.getPath(); }
/** * 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; } } }
@Nullable @Override public Path getPathToEntityLiving(Entity entityIn) { return super.getPathToEntityLiving(entityIn); }
@Nullable @Override public Path getPathToPos(BlockPos pos) { return super.getPathToPos(pos); }