Skip to content

Conversation

@aShanki
Copy link
Contributor

@aShanki aShanki commented Feb 1, 2026

Description

Implements the foundational A* pathfinding system for entity navigation, addressing the "Navigation / Pathfinding (A* implementation)" item in #1406.

This PR provides the core pathfinding algorithms without navigation controllers or movement controls (which will be added in follow-up PRs as they require entity structure changes).

Core A* Algorithm

  • PathFinder - Complete A* implementation with configurable heuristic (1.5x fudging factor)
  • BinaryHeap - Custom min-heap priority queue with O(log n) operations for open set management
  • Node - Graph node representation with g/h/f cost tracking and parent references
  • Path - Sequence of nodes from start to destination with traversal state
  • Target - Goal position tracking with best node selection
  • PathType - 25 terrain types with associated cost penalties (malus values)

Node Evaluators (Movement Types)

Different evaluators handle different entity movement capabilities:

  • WalkNodeEvaluator (521 lines) - Ground-based walking

    • Jump detection (up to 1.125 blocks)
    • Fall handling (up to 3 blocks)
    • Stairs and slope traversal
    • Door and fence awareness
  • SwimNodeEvaluator (321 lines) - Water-based movement

    • Full 3D swimming navigation
    • Optional water breaching
    • Fluid detection
  • FlyNodeEvaluator (352 lines) - Aerial movement

    • Unrestricted 3D flying
    • Block collision avoidance
  • AmphibiousNodeEvaluator (242 lines) - Hybrid movement

    • Seamless land/water transitions
    • For frogs, turtles, axolotls

Path Type Awareness

The pathfinding system considers 25 terrain types including:

  • Blocked: Fences, closed doors, lava
  • Dangerous: Fire (16.0 cost), cacti, sweet berry bushes
  • Water: 8.0 cost penalty
  • Walkable: Open (0.0), doors, rails

Algorithm Details

  • A* with heuristic fudging factor (1.5x) for performance
  • Multi-target support with partial path fallback
  • Configurable max visited nodes limit
  • Parent node tracking for path reconstruction

Testing

The pathfinding algorithms are based on vanilla Minecraft 1.21.11 implementation:

  • Core A* logic matches vanilla PathFinder.java
  • Node evaluators match vanilla movement type handlers
  • Path type costs match vanilla malus values
  • Binary heap operations verified against vanilla implementation

Notes

This PR lays the foundation for mob AI movement. The navigation controllers (GroundPathNavigation, FlyingPathNavigation, etc.) and movement controls (MoveControl, JumpControl) will be added in subsequent PRs as they require entity structure modifications.

The existing simple Navigator in mod.rs remains unchanged as a placeholder for backwards compatibility.

Partially addresses #1406:

  • Navigation / Pathfinding (A* implementation) - Core algorithms
  • Navigation / Pathfinding - Navigation controllers (follow-up PR)
  • Jump Control (follow-up PR)
  • Move Control (follow-up PR)

Implements the foundational pathfinding system:

Core A* Algorithm:
- PathFinder with A* search algorithm
- BinaryHeap priority queue for open set
- Node representation with g/h/f costs
- Path reconstruction and representation
- Target tracking with best node selection
- PathType enum with 25 terrain cost types

Node Evaluators (movement types):
- WalkNodeEvaluator: Ground walking with jumps/falls
- SwimNodeEvaluator: 3D water navigation
- FlyNodeEvaluator: 3D aerial movement
- AmphibiousNodeEvaluator: Hybrid land/water movement

This provides the pathfinding infrastructure. Navigation controllers
and movement controls will be added in follow-up PRs.

Addresses Pumpkin-MC#1406 (Navigation / Pathfinding)
@aShanki
Copy link
Contributor Author

aShanki commented Feb 1, 2026

dont flame me for the AI genned description, im tryna file smaller PRs for integration (since id rather not PR 40k LOC all at once)

@aShanki aShanki marked this pull request as draft February 1, 2026 15:50
- Fix unused_self warnings with allow attributes for trait methods
- Use is_some_and instead of map_or(false, ...) for Option checks
- Combine identical match arms in PathType::malus
- Rename test functions to remove redundant test_ prefix
- Add allow for module_inception, too_many_arguments, unused_async
- Change &mut Vec to &mut [Target] slice parameter
The insert function was returning the original index before up_heap,
but when a node bubbles up the heap, its final position may differ.
Now up_heap returns the final index and insert returns that value,
ensuring change_cost operates on the correct node.
@aShanki aShanki marked this pull request as ready for review February 2, 2026 01:20
@aShanki
Copy link
Contributor Author

aShanki commented Feb 2, 2026

Ready to review btw

@CuzImClicks
Copy link
Contributor

holy ai

@Snowiiii
Copy link
Member

Snowiiii commented Feb 2, 2026

@aShanki are you sure this is based on Vanilla ?, looks really custom

@aShanki
Copy link
Contributor Author

aShanki commented Feb 2, 2026

It's based on 1.21.11 vanilla decompiled code. Nearly identical to mcs default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants