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/sprint toward a destination on the same Y level.
|
|
|
|
|
/// Used for Traverse and Diagonal moves.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class WalkTemplate : IActionTemplate
|
|
|
|
|
{
|
|
|
|
|
public Location ExpectedStart { get; }
|
|
|
|
|
public Location ExpectedEnd { get; }
|
|
|
|
|
|
2026-04-12 18:46:42 +08:00
|
|
|
private readonly PathSegment _segment;
|
|
|
|
|
private readonly PathSegment? _nextSegment;
|
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
|
|
|
private int _tickCount;
|
|
|
|
|
private Location _lastPos;
|
|
|
|
|
private int _stuckTicks;
|
|
|
|
|
|
2026-04-12 18:46:42 +08:00
|
|
|
public WalkTemplate(PathSegment segment, PathSegment? nextSegment)
|
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
|
|
|
_segment = segment;
|
|
|
|
|
_nextSegment = nextSegment;
|
|
|
|
|
ExpectedStart = segment.Start;
|
|
|
|
|
ExpectedEnd = segment.End;
|
|
|
|
|
_lastPos = segment.Start;
|
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
|
|
|
public TemplateState 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
|
|
|
{
|
|
|
|
|
_tickCount++;
|
|
|
|
|
|
2026-04-11 14:03:50 +08:00
|
|
|
double dx = ExpectedEnd.X - pos.X;
|
|
|
|
|
double dz = ExpectedEnd.Z - pos.Z;
|
2026-04-12 00:57:38 +08:00
|
|
|
double dy = ExpectedEnd.Y - pos.Y;
|
2026-04-12 01:15:17 +08:00
|
|
|
float targetYaw = TemplateHelper.CalculateYaw(dx, dz);
|
|
|
|
|
float targetPitch = TemplateHelper.CalculatePitch(dx, dy, dz);
|
|
|
|
|
physics.Yaw = TemplateHelper.SmoothYaw(physics.Yaw, targetYaw);
|
|
|
|
|
physics.Pitch = TemplateHelper.SmoothPitch(physics.Pitch, targetPitch);
|
2026-04-11 14:03:50 +08:00
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
GroundedSegmentController.Apply(_segment, _nextSegment, pos, physics, input, world);
|
2026-04-12 18:46:42 +08:00
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
if (GroundedSegmentController.ShouldComplete(_segment, pos, physics))
|
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.Complete;
|
|
|
|
|
|
|
|
|
|
double movedSq = TemplateHelper.HorizontalDistanceSq(pos, _lastPos);
|
|
|
|
|
_stuckTicks = movedSq < 0.0005 ? _stuckTicks + 1 : 0;
|
|
|
|
|
_lastPos = pos;
|
|
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
int maxTicks = _segment.ExitTransition switch
|
|
|
|
|
{
|
|
|
|
|
PathTransitionType.ContinueStraight => 100,
|
|
|
|
|
PathTransitionType.PrepareJump => 80,
|
|
|
|
|
_ => 140
|
|
|
|
|
};
|
2026-04-12 18:46:42 +08:00
|
|
|
if (_stuckTicks > 40 || _tickCount > maxTicks)
|
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.Failed;
|
|
|
|
|
|
|
|
|
|
return TemplateState.InProgress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|