SDK Pathfinder Reference
The pathfinder module — blocking Walker, WalkerPath teleport-and-steps plans, five algorithms, collision/transport/teleport data, strategic pathing, and boat pathing.
World pathfinding and walking: the blocking Walker, the pluggable algorithm engine behind WalkerPath, local/strategic pathing, collision maps, transports, teleports, requirements, and boat pathing for sailing. Source of truth: docs/sdk-pathfinder-reference.md in the n3Client repository.
Purpose and shape
Three entry levels:
Walker— blocking world-walk API for worker threads (walkTo,sailTo,cancel,isWalking).StrategicPathing— compute/follow aListofWorldPointwith run/stamina handling, as aStepHandleror executed inline.LocalPathfinder/PathfinderAlgo— the engines;WalkerPath.getinstantiates whichever implementationClientConfig.pathfinderImplnames (defaultHYBRID_BFS,base-api/src/main/java/dev/n3u/util/ClientConfig.java,@ConfigKey(value = "pathfinderImpl", defaultValue = "HYBRID_BFS")).
Startup and data resources
Walker's static initializer loads four resources once (api/src/main/java/dev/n3u/services/pathfinder/Walker.java:33): GlobalCollisionMap.load(), ObjectMap.load(), TileTypeMap.load(), NavGraph.load(). Load failure is logged ([Pathfinder] Failed to load collision map) and the getters return null — everything downstream will fail, so a load error is fatal to walking. The maps themselves are generated during the build by MapResourceGenerator (api/build.gradle.kts, generateMapResources task, outputs map.dat/graph.dat/tile_type.dat under build/generated/pathfinder).
PathfinderAlgo maps enum constants to implementation classes by reflection (base-api/src/main/java/dev/n3u/services/pathfinder/PathfinderAlgo.java): HYBRID_BFS, BI_DIR_BFS, FLOW_FIELD, ASTAR, JPS — each getPathfinder() loads from Static.getClassLoader() and throws RuntimeException on a missing class.
Walker — blocking world walks
Verified surface (Walker.java:63-222; walk entry points :90-116, Setting :63-66, sailTo :70, core walk :138-204, cancel :210, isWalking :221):
walkTo(WorldPoint)/walkTo(WorldPoint, BooleanSupplier stopCondition)— computesWalkerPath.getafter snapping the target withcollisionMap.nearestWalkableEuclidean(target, 5)(Walker.java:123), then steps until done, until the stop condition fires, or until cancelled.walkTo(List<WorldArea>)(+ stop-condition overload) — walks to the closest of the areas.cancel(),isWalking().Setting—toggleRunRange(25–35) andconsumeStaminaRange(50–60) randomized per walk.sailTo(WorldPoint)— delegates toBoatPathing.travelTo(sailing navigation).
Control flow of a walk(WorldPoint, stopCondition): after the final path step it waits up to 50 idle-ticks for arrival (Walker.java:170), re-walking if the endpoint became unreachable, and always runs currentPath.shutdown() + GameManager.clearPathPoints() in finally (Walker.java:201-204). A second concurrent walk is rejected with [Pathfinder] Already walking! and returns false (:143-146).
Invariants:
- Never call
walkTo/sailToon the client thread — the step loop sleeps viaDelays.tick(), which throws on the client thread (see SDK Game Reference). - One walk at a time, client-wide (
runningflag). stopConditionreturning true ends the walk and is the only waywalkreturnstrue(Walker.java:153,160,177); a completedWalkerPath.step()loop with plain arrival falls through toreturn false(:207).
WalkerPath — teleport-and-steps plan
WalkerPath.get(WorldPoint) / get(List<WorldArea>) / get(target, PathfinderAlgo) (api/src/main/java/dev/n3u/services/pathfinder/model/WalkerPath.java:76 and overloads, algo selection :79,104) run the selected algorithm, attach its Teleport (from teleports/), and produce a List<IStep> plan. Steps are not just moves: the class owns stamina-potion ids, dialogue handling, prayer checks and widget interactions executed while walking (WalkerPath.java imports and fields, e.g. the STAMINA id table :44). step() advances one step; cancel()/shutdown() release resources; path drawing goes through GameManager when ClientConfig.shouldDrawWalkerPath() is on.
IPathfinder (find(target) + getTeleport()) and IStep (getPosition, getPackedPosition, getTransport, hasTransport) are the engine contracts (abstractions/).
Algorithms
Under implimentations/ (package spelling is upstream): hybridbfs (default — BFS over a local collision view, also powering LocalPathfinder), bidirbfs, flowfield, astar, jps. Each contributes *Algo and *Step types (the enum instantiates only the *Algo); astar, jps, flowfield and bidirbfs also carry a *Cache, while the default hybridbfs BFS cache lives in collections/BFSCache.java (imported by LocalPathfinder.java:4). Long-distance behavior is augmented by:
transports/—Transport,LongTransport,TransportLoader, and the data tables undertransports/data/(fairy rings, charter ships, canoes, gnome gliders, spirit trees, dwarven carts, minecarts, Barnaby/charter maps).teleports/—Teleport,TeleportItem,TeleportSpell,TeleportLoader, plusMovementConstantsand aPointDistanceComparator.requirements/—Requirements/RequirementsBuilderwithItemRequirement,SkillRequirement,QuestRequirement,VarRequirement,WorldRequirement,Comparison/Reduction— gate transports and teleports on player state.
Strategic and local pathing
StrategicPathing(StrategicPathing.java:57-197):execute(path)at:57(worker threads),getStepHandler(path)at:68(embeds run-toggling and per-tileMovementAPI.walkToWorldPointinto aStepHandler),stepAlongat:92,102,pathTo(goal[, dangerous[, impassable]])at:132,144,157,pathToSet(...)at:166,179. Works off aLocalCollisionMapand avoidable/impassable tile sets — designed for danger-aware routes.LocalPathfinder(LocalPathfinder.java:18-63): singletonget().findPath(start, end)— BFS overCollisionUtilwithBFSCache/IntQueue, returnsList<HybridBFSStep>. This is the in-scene, memory-light engine.
Sailing pathing
sailing/ holds BoatPathing (used by Walker.sailTo), BoatCollisionAPI, BoatHullCache, BoatPathingDebug, and sailing/graph/NavGraph (+GraphNode, NavGraphLoader). Water routes are a graph problem separate from the land algorithms; the NClient.get/setShipHeading accessors tie into boat control (see SDK Client Reference).
Developer tooling
ui/TransportEditorFrame + ui/components/* edit the transport JSON tables; ui/TransportOverlay renders them in-game. collision/ exposes GlobalCollisionMap, FlagMap/Flags, SparseBitSet, Properties, and MapResourceGenerator for map maintenance; tiletype/TileTypeMap and objects/ObjectMap annotate tiles/objects. collision.MapResourcesTest (api/src/test/java/dev/n3u/services/pathfinder/collision/MapResourcesTest.java) is the automated guard over the generated resources.
Worked example — interruptible walk on a worker thread
import dev.n3u.services.pathfinder.Walker;
import net.runelite.api.coords.WorldPoint;
import dev.n3u.api.threaded.Delays;
import dev.n3u.util.NPlugin;
public class WalkerDemo extends NPlugin
{
private volatile boolean stop = false;
@Override
public void loop() throws Exception
{
if (Walker.isWalking()) {
Delays.tick();
return;
}
// Walk from anywhere to the G.E. big bank; stop early if `stop` flips
Walker.walkTo(new WorldPoint(3164, 3483, 0), () -> stop);
// walkTo blocks until arrival, stop condition, or cancel(); paths are shut down in finally
}
}Expected result: the plugin walks toward the target; flips of stop end the walk with true. Failure handling: unreachable targets snap to the nearest walkable tile within 5; arrival failures re-walk up to 50 idle ticks then give up; a second concurrent walkTo logs and returns false; call Walker.cancel() on plugin shutdown to release the running path.
Thread affinity
Walker, StrategicPathing.execute, and WalkerPath stepping are worker-thread APIs (they sleep through Delays.tick()). Of the compute-only members, only nearestWalkableEuclidean (collision/CollisionMap.java:42, over the static map data loaded once in Walker's static block, :33-35) is thread-agnostic. StrategicPathing.pathTo/pathToSet wrap the whole BFS in Static.invoke (StrategicPathing.java:219), so the computation runs on the client thread; LocalPathfinder.findPath (LocalPathfinder.java:32-42) reads client state directly with no Static.invoke and must be called on the client thread. The engine is single-flight per client (running flag); one walker serves all plugins.
Tests
MapResourcesTest covers the collision/resource generation pipeline. No algorithm-level test exists for AStarAlgo/JPSAlgo/FlowFieldAlgo/BiDirBFSAlgo/HybridBFSAlgo semantics (verified git ls-files "api/src/test/java", 2026-11-06). The repository tracks a follow-up for fixture maps with expected shortest paths per algorithm, including transport and teleport integration cases.
Known limits
PathfinderAlgoresolves implementations reflectively at walk time; a badpathfinderImplvalue fails with a wrappedRuntimeExceptionon the next walk, not at config time.- Generated
map.dat/graph.dat/tile_type.datship with the build; a game update that changes collision requires regenerating them (MapResourceGenerator) before walking is correct again. Walkerexposes no progress callback; observe progress viaPlayerEx.getLocal().getWorldPoint()or thedrawWalkerPathoverlay.- Package name
implimentationsis a historical misspelling retained for compatibility — do not "fix" it when importing.
SDK Packets Reference
Low-level packet construction and parsing — the NPacketWriter typed send methods, the send pipeline, PacketBuffer codecs, and packet events.
External Plugins
Build external n3Client plugins — Gradle dependencies and version pins, the NPlugin loop contract, lifecycle sharp edges, and sideloading.