Minecraft-Console-Client/MinecraftClient/Pathing/Execution/ActionTemplateFactory.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

27 lines
1.1 KiB
C#

using System;
using MinecraftClient.Pathing.Core;
using MinecraftClient.Pathing.Execution.Templates;
namespace MinecraftClient.Pathing.Execution
{
/// <summary>
/// Maps a PathSegment (MoveType + start/end) to the appropriate IActionTemplate.
/// </summary>
public static class ActionTemplateFactory
{
public static IActionTemplate Create(PathSegment segment)
{
return segment.MoveType switch
{
MoveType.Traverse => new WalkTemplate(segment.Start, segment.End),
MoveType.Diagonal => new WalkTemplate(segment.Start, segment.End),
MoveType.Ascend => new AscendTemplate(segment.Start, segment.End),
MoveType.Descend => new DescendTemplate(segment.Start, segment.End),
MoveType.Fall => new FallTemplate(segment.Start, segment.End),
MoveType.Climb => new ClimbTemplate(segment.Start, segment.End),
MoveType.Parkour => new SprintJumpTemplate(segment.Start, segment.End),
_ => throw new ArgumentException($"Unknown MoveType: {segment.MoveType}")
};
}
}
}