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 MinecraftClient.Mapping;
|
|
|
|
|
using MinecraftClient.Physics;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Pathing.Execution.Templates
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Walk off a ledge and drop 1-N blocks to a landing spot.
|
|
|
|
|
/// Walks toward the destination; gravity handles the fall.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class DescendTemplate : IActionTemplate
|
|
|
|
|
{
|
|
|
|
|
public Location ExpectedStart { get; }
|
|
|
|
|
public Location ExpectedEnd { get; }
|
|
|
|
|
|
|
|
|
|
private int _tickCount;
|
|
|
|
|
private bool _hasFallen;
|
|
|
|
|
|
|
|
|
|
public DescendTemplate(Location start, Location end)
|
|
|
|
|
{
|
|
|
|
|
ExpectedStart = start;
|
|
|
|
|
ExpectedEnd = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TemplateState Tick(Location pos, PlayerPhysics physics, MovementInput input)
|
|
|
|
|
{
|
|
|
|
|
_tickCount++;
|
|
|
|
|
|
|
|
|
|
double dx = ExpectedEnd.X - pos.X;
|
|
|
|
|
double dz = ExpectedEnd.Z - pos.Z;
|
|
|
|
|
double dy = ExpectedEnd.Y - pos.Y;
|
|
|
|
|
double horizDistSq = dx * dx + dz * dz;
|
|
|
|
|
|
|
|
|
|
if (!physics.OnGround)
|
|
|
|
|
_hasFallen = true;
|
|
|
|
|
|
|
|
|
|
if (_hasFallen && physics.OnGround && horizDistSq < 0.5 && Math.Abs(dy) < 0.8)
|
|
|
|
|
return TemplateState.Complete;
|
|
|
|
|
|
|
|
|
|
if (horizDistSq < 0.25 && Math.Abs(dy) < 0.5 && physics.OnGround)
|
|
|
|
|
return TemplateState.Complete;
|
|
|
|
|
|
2026-04-11 13:22:23 +08:00
|
|
|
// Fail if climbing up instead of descending
|
|
|
|
|
if (pos.Y > ExpectedStart.Y + 2.0)
|
|
|
|
|
return TemplateState.Failed;
|
|
|
|
|
|
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 (_tickCount > 120)
|
|
|
|
|
return TemplateState.Failed;
|
|
|
|
|
|
|
|
|
|
if (horizDistSq > 0.01)
|
|
|
|
|
{
|
|
|
|
|
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
|
|
|
|
|
input.Forward = true;
|
2026-04-11 13:22:23 +08:00
|
|
|
// Don't push into climbable blocks during descent
|
|
|
|
|
if (physics.OnClimbable)
|
|
|
|
|
input.Forward = false;
|
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 TemplateState.InProgress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|