PathFindering - Mod library for custom pathfinding in Minecraft.
This is a PathFindering, mod library with custom pathfinding algorithms A, D, jSMA (Custom, created by Ackerman Studios, optimized). Is a brand-new library to replace old minecraft pathfinder by other algorithms. Is very useful for creating custom NPC's with not-standard path creating.
Source GitHub
How to use
- Download mod and place in /mods folder
- Run Minecraft with other mods.
In Mod Developement
JAR-Dependency
- Download JAR-file
- Open IDE (IntelliJ IDEA, Eclipse)
- Open "Dependencies" or other and select PathFindering-0x(version).jar
API Docs (for Devs)
AStarPathfinder | class, PathFinder
Methods: public List<PathNode> findPath( PathNode start, PathNode goal, WorldAdapter world, Heuristic heuristic, CostStack costs, PersonalityProfile prof, CustomPersonalityProfile prof1, boolean useCustomProfile ); Java-Doc: Returns list of nodes to walking Params: start - Start pos goal - End pos world - Current world adapter redshell.pathfindering.AStar.MCWorldAdapter or other with implementation of redshell.pathfindering.util.WorldAdapter and all methods from interface heuristic - Use Heuristic-Lambda function
Heuristic FUNC = (from, to) -> { ... return double_value; }}
costs - Weights to change path calculation. WARNING: Send <b>CostStack</b> in this form
<pre>1. In first value put <b>dangerWeight</b> function</pre>
<pre>2. In second value put <b>heightWeight</b> function</pre>
<pre>3. In third value put <b>randomness</b> function</pre>
<pre>4. Other functions</pre>
WARNING NOT WORKS WITH
redshell.pathfindering.util.CustomPersonalityProfile prof - A* correction profile prof1 - A* correction profile for variability useCustomProfile - Switch from {@link redshell.pathfindering.AStar.PersonalityProfile} to {@link redshell.pathfindering.util.CustomPersonalityProfile} Retuns: Path to walk, in PathNode's
DStarPathfinder | class, PathFinder
Methods: public void updateNodes(PathNode startPos, WorldAdapter world, CostStack cost) Java-Doc: Local update: only updates nodes in openList and neighbors of changed nodes.
public List<PathNode> reconstructPath(PathNode start) API-Note: Reconstruct generated path by apply D* Lite for low GC (Garbage Collector) loading
jSMAPathfinder | class, PathFinder
Java-Doc: This is a Scout Movement Algorithm TOP 1 by architecture hardest pathfinding algorithm. This algorithm works by these steps:
A* path getting
A* path correcting by D* algorithm, on all 10-15 ticks
Used DFS (Danger Filter System) to more accuracy path
Used 170deg FOV + Raycast to analyze all in FOV 4.1: Used IPCS (Image Path Correction System) to correct more path by vision
Interesting fact: This pathfinder is a copy of Pathfinding of Attack on Titans scouts
Methods:
public List<PathNode> calculatePath(EntityCreature entity,
PathNode start,
PathNode goal,
WorldAdapter world,
Heuristic heuristic,
CostStack costs,
CustomPersonalityProfile prof,
AStarPathfinder A_star,
DStarPathfinder D_star,
PathController ctrl,
VisionController ctrl1)
Java-Doc:
The jSMA (java Scout Movement Algoriithm) is a module-system PathFinder. Based on A, D Lite, Image Path Corrector and Filtering System
Scout Movement Algorithm Explained
How it works?
jSMA works on 4 steps:
1. A* build path by parameters.
2. D* correct A* path by changing blocked path points. Is need for minimum CPU loading
3. Danger Filter System correcting path by finding safest PathNode's
4. Image Path Correction System (VisionController -> IPCS}) by 170deg FOV + Raycast change path to not blocked by blocks
Setting up before using:
To usage, you need to setup all parameters. Use this examples, only replace all values marked with {@code // Test-only, replace by …} to own values.
Params:
entity - if use in {EntityCreature#onUpdate()} replace by "this" or own Entity instance
start - start position. Use this java PathNode start = new PathNode(this.posX, this.posY, this.posZ);
goal - end position. Use this java PathNode goal = new PathNode(x, y, z); // Test-only, replace x, y, z by real end-point values
world - WorldAdapter adapter to check position parameters. Use java MCWorldAdapter adapter = new MCWorldAdapter(this.world); // USE IN EntityCreature IMPLEMENTATION CLASS
heuristic - heuristic function. Heuristic is FunctionalInterface and you can use lambda-implementator. Use java
Heuristic h = (from, to) -> {
double dx = from.x - to.x;
double dz = from.z - to.z;
return Math.sqrt(dx * dx + dz * dz);
}; // You can replace Math.sqrt by own calculation function
costs - CostStack to usage place functions by CostStack#add(CostFunction). CostFunction creation: java
CostStack stack = new CostStack();
stack.add((from, to) -> return 0.0; ); // Replace return 0.0; by own value
//....}
prof - CustomPersonalityProfile profile with parameters to cost correction (aka CustomPersonalityProfile#addWeight(double). Use java
CustomPersonalityProfile profile = new CustomPersonalityProfile();
profile.addWeight(0.0); // Replace 0.0 by own weight value
//....}