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 Brigadier.NET;
|
|
|
|
|
using Brigadier.NET.Builder;
|
|
|
|
|
using MinecraftClient.CommandHandler;
|
|
|
|
|
using MinecraftClient.Mapping;
|
|
|
|
|
using static MinecraftClient.CommandHandler.CmdResult;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Pathfind : Command
|
|
|
|
|
{
|
|
|
|
|
public override string CmdName => "pathfind";
|
|
|
|
|
public override string CmdUsage => "pathfind <x y z>";
|
|
|
|
|
public override string CmdDesc => Translations.cmd_pathfind_desc;
|
|
|
|
|
|
|
|
|
|
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
|
|
|
|
{
|
|
|
|
|
dispatcher.Register(l => l.Literal("help")
|
|
|
|
|
.Then(l => l.Literal(CmdName)
|
|
|
|
|
.Executes(r => GetUsage(r.Source)))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
dispatcher.Register(l => l.Literal(CmdName)
|
|
|
|
|
.Then(l => l.Argument("location", MccArguments.Location())
|
|
|
|
|
.Executes(r => DoPathfind(r.Source, MccArguments.GetLocation(r, "location"))))
|
|
|
|
|
.Then(l => l.Literal("_help")
|
|
|
|
|
.Executes(r => GetUsage(r.Source))
|
|
|
|
|
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetUsage(CmdResult r)
|
|
|
|
|
{
|
|
|
|
|
return r.SetAndReturn(GetCmdDescTranslated());
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 00:03:43 +08:00
|
|
|
private static int DoPathfind(CmdResult r, Location goal)
|
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
|
|
|
{
|
|
|
|
|
McClient handler = CmdResult.currentHandler!;
|
|
|
|
|
if (!handler.GetTerrainEnabled())
|
|
|
|
|
return r.SetAndReturn(Status.FailNeedTerrain);
|
|
|
|
|
|
|
|
|
|
Location current = handler.GetCurrentLocation();
|
|
|
|
|
goal.ToAbsolute(current);
|
|
|
|
|
|
2026-04-12 00:03:43 +08:00
|
|
|
var (success, message) = handler.MoveToAStar(goal, timeoutMs: 10000);
|
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
|
|
|
|
2026-04-12 00:03:43 +08:00
|
|
|
return r.SetAndReturn(success ? Status.Done : Status.Fail, message);
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|