Repository navigation
PathfinderConfiguration
This is the control panel.
Pathetic comes with sensible defaults optimized for standard Minecraft-like environments. However, if you want to squeeze out every microsecond or support weird movement types, use the PathfinderConfiguration builder.
PathfinderConfiguration config = PathfinderConfiguration.builder()
// Threading & Safety
.async(true)
.fallback(true)
.maxIterations(50_000)
.maxLength(200)
// Physics & Math
.neighborStrategy(NeighborStrategies.DIAGONAL_3D)
.heuristicStrategy(HeuristicStrategies.SQUARED)
.heuristicWeights(HeuristicWeights.create(0.5, 1, 0.7, 0.3))
// Logic
.provider(new NavigationPointProviderImpl())
.pathfindingHooks(List.of(new DebugPathfindingHook))
.costProcessors(List.of(new BasicCostProcessor()))
.validationProcessors(List.of(Validators.not(new BasicValidator())))
.build();Control how hard the engine works before it gives up.
-
maxIterations(int)The hard kill-switch. Stops the search to prevent infinite loops or server freezes.-
Default:
5000
-
Default:
-
maxLength(int)The maximum path length. Use this to prevent NPCs from trying to calculate a path to the other side of the world map.-
Default:
0(No limit)
-
Default:
-
async(boolean)Iftrue, calculation happens off the main thread. Enable this. Blocking the main thread is 2010 behavior.-
Default:
false(Safety first, but please change it)
-
Default:
-
fallback(boolean)If the target is unreachable, return the closest reachable point instead of failing. Better to walk halfway than to stand still looking stupid.-
Default:
true
-
Default:
How the math works.
-
neighborStrategy(INeighborStrategy)Defines valid moves. Do you want boring NES-style movement (Cardinal) or full 3D freedom?-
Default:
VERTICAL_AND_HORIZONTAL(Manhattan)
-
Default:
-
heuristicStrategy(IHeuristicStrategy)The formula used to guess the distance.LINEARis accurate.SQUAREDis faster but slightly dumber.-
Default:
LINEAR
-
Default:
-
heuristicWeights(HeuristicWeights)The bias. Use this to make the pathfinder hate jumping or love going straight.-
Default:
DEFAULT_WEIGHTS
-
Default:
Where the rubber meets the road.
-
provider(NavigationPointProvider)The Bridge. This connects Pathetic to your actual game data. If you don't set this, the pathfinder thinks the world is empty.- Default: A dummy provider (Everything is walkable).
-
pathfindingHooksThe Spy. Attaches a listener that triggers on every single step of the algorithm.- Use case: Drawing debug particles in-game to visualize the search.
- Warning: This slows things down. Don't leave it on in production unless you hate performance.
-
validationProcessorsThe Bouncers. Custom rules to ban nodes (e.g., "Don't walk into lava", "Don't enter private regions").- Default: None.
-
costProcessorsThe Taxman. Makes nodes expensive without blocking them (e.g., "Walking through mud costs double").- Default: None.
These settings control the Bloom Filters and Grid Regions.
Warning: Touch these only if you understand probability theory or enjoy OutOfMemoryError.
-
gridCellSize(int)The world is sliced into chunks (regions). This defines how big those chunks are.-
Default:
12
-
Default:
-
bloomFilterSize(int)The size of the bit-array for each region. Larger = fewer collisions, more RAM.-
Default:
1000
-
Default:
-
bloomFilterFpp(double)The acceptable "False Positive Probability". Lower = better accuracy, massive memory usage.-
Default:
0.01(1%)
-
Default:
In order to monitor the current pathfinding operation (for debugging purposes for example) you can register hooks to the PathfinderConfiguration.
pathfindingHooks(List<PathfindingHook>)