Minecraft-Console-Client/MinecraftClient/Pathing/Execution/PathSegment.cs
BruceChen 4b49135107 feat: add parkour moves and template-based path execution system
Phase 2.2: MoveParkour for sprint-jump across 1-2 block gaps (distance 2-3)
and ascending parkour (distance 2, +1Y). Registered in BuildDefaultMoves
with CalculationContext.AllowParkour gating.

Phase 3.1-3.2: Template execution engine replacing the waypoint queue system.
- IActionTemplate interface with per-tick state machine pattern
- Templates: Walk, Ascend, Descend, Climb, Fall, SprintJump
- ActionTemplateFactory maps MoveType to the correct template
- PathExecutor drives sequential template execution with logging
- PathSegmentManager handles replanning on failure (up to 5 retries)
- McClient integration: MoveToAStar now creates PathSegmentManager,
  UpdatePathfindingInput delegates to it, CancelMovement/ClientIsMoving
  updated for both old and new systems.

Tested on 1.21.11: straight walk, zigzag maze, stair ascent,
1-gap and 2-gap sprint jumps all pass.

Made-with: Cursor
2026-04-12 18:43:32 +00:00

33 lines
1.1 KiB
C#

using System.Collections.Generic;
using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Execution
{
public sealed class PathSegment
{
public required Location Start { get; init; }
public required Location End { get; init; }
public required MoveType MoveType { get; init; }
public static List<PathSegment> FromPath(IReadOnlyList<PathNode> nodes)
{
var segments = new List<PathSegment>(nodes.Count - 1);
for (int i = 1; i < nodes.Count; i++)
{
var prev = nodes[i - 1];
var curr = nodes[i];
segments.Add(new PathSegment
{
Start = new Location(prev.X + 0.5, prev.Y, prev.Z + 0.5),
End = new Location(curr.X + 0.5, curr.Y, curr.Z + 0.5),
MoveType = curr.MoveUsed
});
}
return segments;
}
public override string ToString() =>
$"{MoveType}: ({Start.X:F1},{Start.Y:F1},{Start.Z:F1})->({End.X:F1},{End.Y:F1},{End.Z:F1})";
}
}