mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
feat: add transition-aware path execution core
This commit is contained in:
parent
7ad0a57a3e
commit
360883acf3
14 changed files with 755 additions and 94 deletions
|
|
@ -131,6 +131,22 @@ namespace MinecraftClient.Pathing.Core
|
|||
CancellationToken ct,
|
||||
long timeoutMs = 5000)
|
||||
{
|
||||
if (goal.IsInGoal(startX, startY, startZ))
|
||||
{
|
||||
DebugLog?.Invoke($"[A*] Already in goal at ({startX},{startY},{startZ})");
|
||||
return new PathResult(
|
||||
PathStatus.Success,
|
||||
[new PathNode(startX, startY, startZ)],
|
||||
nodesExplored: 0,
|
||||
elapsedMs: 0);
|
||||
}
|
||||
|
||||
if (!IsGoalReachableFootPosition(ctx, goal))
|
||||
{
|
||||
DebugLog?.Invoke($"[A*] Goal {goal} is not a reachable foot position");
|
||||
return PathResult.Fail(nodesExplored: 0, elapsedMs: 0);
|
||||
}
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
var openSet = new BinaryHeapOpenSet(4096);
|
||||
var nodeMap = new Dictionary<long, PathNode>(4096);
|
||||
|
|
@ -259,5 +275,21 @@ namespace MinecraftClient.Pathing.Core
|
|||
path.Reverse();
|
||||
return path;
|
||||
}
|
||||
|
||||
private static bool IsGoalReachableFootPosition(CalculationContext ctx, IGoal goal)
|
||||
{
|
||||
if (goal is not GoalBlock blockGoal)
|
||||
return true;
|
||||
|
||||
if (!ctx.IsChunkLoaded(blockGoal.X, blockGoal.Z))
|
||||
return true;
|
||||
|
||||
if (blockGoal.Y == int.MinValue)
|
||||
return false;
|
||||
|
||||
return ctx.CanWalkOn(blockGoal.X, blockGoal.Y - 1, blockGoal.Z)
|
||||
&& ctx.CanWalkThrough(blockGoal.X, blockGoal.Y, blockGoal.Z)
|
||||
&& ctx.CanWalkThrough(blockGoal.X, blockGoal.Y + 1, blockGoal.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue