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-11 12:46:38 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using MinecraftClient.Mapping;
|
|
|
|
|
using MinecraftClient.Physics;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Pathing.Execution
|
|
|
|
|
{
|
|
|
|
|
public enum PathExecutorState
|
|
|
|
|
{
|
|
|
|
|
InProgress,
|
|
|
|
|
Failed,
|
|
|
|
|
Complete
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drives a sequence of PathSegments by instantiating the correct IActionTemplate
|
|
|
|
|
/// for each segment and ticking it every game tick.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class PathExecutor
|
|
|
|
|
{
|
|
|
|
|
private readonly List<PathSegment> _segments;
|
|
|
|
|
private int _currentIndex;
|
|
|
|
|
private IActionTemplate? _currentTemplate;
|
|
|
|
|
private readonly Action<string>? _debugLog;
|
|
|
|
|
|
|
|
|
|
public bool IsComplete => _currentIndex >= _segments.Count && _currentTemplate is null;
|
|
|
|
|
public int CurrentIndex => _currentIndex;
|
|
|
|
|
public int TotalSegments => _segments.Count;
|
|
|
|
|
public PathSegment? CurrentSegment =>
|
|
|
|
|
_currentIndex < _segments.Count ? _segments[_currentIndex] : null;
|
|
|
|
|
|
|
|
|
|
public PathExecutor(List<PathSegment> segments, Action<string>? debugLog = null)
|
|
|
|
|
{
|
|
|
|
|
_segments = segments;
|
|
|
|
|
_currentIndex = 0;
|
|
|
|
|
_debugLog = debugLog;
|
|
|
|
|
AdvanceToNextSegment();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 18:46:42 +08:00
|
|
|
public PathExecutorState Tick(Location pos, PlayerPhysics physics, MovementInput input, World world)
|
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-11 12:46:38 +08:00
|
|
|
{
|
|
|
|
|
if (_currentTemplate is null)
|
2026-04-12 18:46:42 +08:00
|
|
|
{
|
|
|
|
|
input.Reset();
|
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-11 12:46:38 +08:00
|
|
|
return PathExecutorState.Complete;
|
2026-04-12 18:46:42 +08:00
|
|
|
}
|
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-11 12:46:38 +08:00
|
|
|
|
2026-04-12 18:46:42 +08:00
|
|
|
var state = _currentTemplate.Tick(pos, physics, input, world);
|
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-11 12:46:38 +08:00
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case TemplateState.Complete:
|
2026-04-12 18:46:42 +08:00
|
|
|
input.Reset();
|
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-11 12:46:38 +08:00
|
|
|
_debugLog?.Invoke($"[PathExec] Segment {_currentIndex} complete " +
|
|
|
|
|
$"({_segments[_currentIndex].MoveType}) at ({pos.X:F2},{pos.Y:F2},{pos.Z:F2})");
|
|
|
|
|
_currentIndex++;
|
|
|
|
|
if (_currentIndex >= _segments.Count)
|
|
|
|
|
{
|
|
|
|
|
_currentTemplate = null;
|
|
|
|
|
_debugLog?.Invoke("[PathExec] All segments complete!");
|
|
|
|
|
return PathExecutorState.Complete;
|
|
|
|
|
}
|
|
|
|
|
AdvanceToNextSegment();
|
|
|
|
|
return PathExecutorState.InProgress;
|
|
|
|
|
|
|
|
|
|
case TemplateState.Failed:
|
2026-04-12 18:46:42 +08:00
|
|
|
input.Reset();
|
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-11 12:46:38 +08:00
|
|
|
_debugLog?.Invoke($"[PathExec] Segment {_currentIndex} FAILED " +
|
|
|
|
|
$"({_segments[_currentIndex].MoveType}) at ({pos.X:F2},{pos.Y:F2},{pos.Z:F2}), " +
|
|
|
|
|
$"target was ({_currentTemplate.ExpectedEnd.X:F2},{_currentTemplate.ExpectedEnd.Y:F2},{_currentTemplate.ExpectedEnd.Z:F2})");
|
|
|
|
|
return PathExecutorState.Failed;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return PathExecutorState.InProgress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AdvanceToNextSegment()
|
|
|
|
|
{
|
|
|
|
|
if (_currentIndex < _segments.Count)
|
|
|
|
|
{
|
|
|
|
|
var seg = _segments[_currentIndex];
|
2026-04-12 18:46:42 +08:00
|
|
|
PathSegment? next = _currentIndex + 1 < _segments.Count ? _segments[_currentIndex + 1] : null;
|
|
|
|
|
_currentTemplate = ActionTemplateFactory.Create(seg, next);
|
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-11 12:46:38 +08:00
|
|
|
_debugLog?.Invoke($"[PathExec] Starting segment {_currentIndex}/{_segments.Count}: {seg}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_currentTemplate = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|