feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder
Made-with: Cursor
2026-04-11 01:48:10 +08:00
|
|
|
using MinecraftClient.Mapping;
|
|
|
|
|
using MinecraftClient.Pathing.Moves;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Pathing.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Thread-safe snapshot of world state and player capabilities for path planning.
|
|
|
|
|
/// Created once at the start of a search; all move calculations read from this.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class CalculationContext
|
|
|
|
|
{
|
|
|
|
|
public World World { get; }
|
|
|
|
|
public bool CanSprint { get; }
|
|
|
|
|
public bool AllowParkour { get; }
|
|
|
|
|
public bool AllowParkourAscend { get; }
|
|
|
|
|
public bool AllowDiagonalDescend { get; }
|
|
|
|
|
public int MaxFallHeight { get; }
|
feat: add 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:
- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)
MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall
SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance
All movements verified on 1.21.11 local server.
Made-with: Cursor
2026-04-11 14:45:54 +08:00
|
|
|
public int MaxFallHeightWater { get; }
|
|
|
|
|
public bool AllowLadderGrabDuringFall { get; }
|
feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder
Made-with: Cursor
2026-04-11 01:48:10 +08:00
|
|
|
public double JumpPenalty { get; }
|
|
|
|
|
public double WalkCost { get; }
|
|
|
|
|
public double SprintCost { get; }
|
|
|
|
|
public double SneakCost { get; }
|
2026-04-18 06:14:45 +00:00
|
|
|
public MoveType PreviousMoveType { get; internal set; }
|
feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder
Made-with: Cursor
2026-04-11 01:48:10 +08:00
|
|
|
|
|
|
|
|
public CalculationContext(
|
|
|
|
|
World world,
|
|
|
|
|
bool canSprint = true,
|
|
|
|
|
bool allowParkour = false,
|
|
|
|
|
bool allowParkourAscend = false,
|
|
|
|
|
bool allowDiagonalDescend = true,
|
|
|
|
|
int maxFallHeight = 3,
|
feat: add 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:
- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)
MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall
SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance
All movements verified on 1.21.11 local server.
Made-with: Cursor
2026-04-11 14:45:54 +08:00
|
|
|
int maxFallHeightWater = 256,
|
|
|
|
|
bool allowLadderGrabDuringFall = true,
|
feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder
Made-with: Cursor
2026-04-11 01:48:10 +08:00
|
|
|
double jumpPenalty = ActionCosts.JumpPenalty)
|
|
|
|
|
{
|
|
|
|
|
World = world;
|
|
|
|
|
CanSprint = canSprint;
|
|
|
|
|
AllowParkour = allowParkour;
|
|
|
|
|
AllowParkourAscend = allowParkourAscend;
|
|
|
|
|
AllowDiagonalDescend = allowDiagonalDescend;
|
|
|
|
|
MaxFallHeight = maxFallHeight;
|
feat: add 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:
- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)
MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall
SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance
All movements verified on 1.21.11 local server.
Made-with: Cursor
2026-04-11 14:45:54 +08:00
|
|
|
MaxFallHeightWater = maxFallHeightWater;
|
|
|
|
|
AllowLadderGrabDuringFall = allowLadderGrabDuringFall;
|
feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder
Made-with: Cursor
2026-04-11 01:48:10 +08:00
|
|
|
JumpPenalty = jumpPenalty;
|
|
|
|
|
WalkCost = ActionCosts.WalkOneBlock;
|
|
|
|
|
SprintCost = CanSprint ? ActionCosts.SprintOneBlock : ActionCosts.WalkOneBlock;
|
|
|
|
|
SneakCost = ActionCosts.SneakOneBlock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Block GetBlock(int x, int y, int z)
|
|
|
|
|
=> World.GetBlock(new Location(x, y, z));
|
|
|
|
|
|
|
|
|
|
public Material GetMaterial(int x, int y, int z)
|
|
|
|
|
=> GetBlock(x, y, z).Type;
|
|
|
|
|
|
|
|
|
|
public bool CanWalkThrough(int x, int y, int z)
|
|
|
|
|
=> MoveHelper.CanWalkThrough(this, x, y, z);
|
|
|
|
|
|
|
|
|
|
public bool CanWalkOn(int x, int y, int z)
|
|
|
|
|
=> MoveHelper.CanWalkOn(this, x, y, z);
|
|
|
|
|
|
|
|
|
|
public bool IsFullyPassable(int x, int y, int z)
|
|
|
|
|
=> MoveHelper.IsFullyPassable(this, x, y, z);
|
|
|
|
|
|
|
|
|
|
public bool IsChunkLoaded(int x, int z)
|
|
|
|
|
{
|
|
|
|
|
int cx = x >> 4;
|
|
|
|
|
int cz = z >> 4;
|
|
|
|
|
var col = World[cx, cz];
|
|
|
|
|
return col is not null && col.FullyLoaded;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|