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;
|
2026-04-13 00:11:12 +08:00
|
|
|
using MinecraftClient.Pathing.Execution;
|
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 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.
|
2026-04-12 01:38:17 +08:00
|
|
|
/// Sprints when the horizontal distance is large (> 1.5 blocks).
|
2026-04-12 00:49:09 +08:00
|
|
|
/// Supports solid landings, water landings, and mid-fall vine/ladder grabs.
|
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
|
|
|
/// </summary>
|
|
|
|
|
public sealed class DescendTemplate : IActionTemplate
|
|
|
|
|
{
|
2026-04-13 00:11:12 +08:00
|
|
|
private const float PreDropYawToleranceDeg = 12f;
|
|
|
|
|
|
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
|
|
|
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 bool _hasFallen;
|
2026-04-12 01:38:17 +08:00
|
|
|
private readonly bool _needsSprint;
|
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 DescendTemplate(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;
|
|
|
|
|
double hdx = segment.End.X - segment.Start.X;
|
|
|
|
|
double hdz = segment.End.Z - segment.Start.Z;
|
2026-04-12 01:38:17 +08:00
|
|
|
_needsSprint = (hdx * hdx + hdz * hdz) > 2.25;
|
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++;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
feat: add 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:
- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)
MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall
SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance
All movements verified on 1.21.11 local server.
Made-with: Cursor
2026-04-11 14:45:54 +08:00
|
|
|
// Completion: landed in water near destination
|
|
|
|
|
if (_hasFallen && physics.InWater && horizDistSq < 0.5 && Math.Abs(dy) < 2.0)
|
|
|
|
|
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 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:
- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)
MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall
SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance
All movements verified on 1.21.11 local server.
Made-with: Cursor
2026-04-11 14:45:54 +08:00
|
|
|
if (_tickCount > 200)
|
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;
|
|
|
|
|
|
2026-04-12 01:15:17 +08:00
|
|
|
float targetYaw = TemplateHelper.CalculateYaw(dx, dz);
|
|
|
|
|
float targetPitch = TemplateHelper.CalculatePitch(dx, dy, dz);
|
|
|
|
|
physics.Pitch = TemplateHelper.SmoothPitch(physics.Pitch, targetPitch);
|
2026-04-12 00:57:38 +08:00
|
|
|
|
2026-04-22 16:43:43 +00:00
|
|
|
// Snap yaw on the first tick to avoid a few ticks of sideways drift
|
|
|
|
|
// when the bot enters this segment with a stale orientation (e.g.
|
|
|
|
|
// just after a teleport or after a turn). Ledge-adjacent descends
|
|
|
|
|
// cannot tolerate drift without falling off the wrong side.
|
|
|
|
|
if (_tickCount == 1)
|
|
|
|
|
physics.Yaw = targetYaw;
|
|
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
if (physics.OnGround && Math.Abs(dy) < (_hasFallen ? 1.0 : 0.6))
|
2026-04-12 18:46:42 +08:00
|
|
|
{
|
2026-04-13 00:11:12 +08:00
|
|
|
TransitionBrakingDecision decision = TransitionBrakingPlanner.Plan(_segment, _nextSegment, pos, physics, world);
|
2026-04-22 16:43:43 +00:00
|
|
|
bool onOrPastTarget = TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, ExpectedEnd)
|
|
|
|
|
|| TemplateHelper.HasReachedSegmentEndPlane(pos, _segment);
|
|
|
|
|
|
|
|
|
|
// Fallback: after a diagonal descend landing the bot can end
|
|
|
|
|
// up on a support block that is not yet the target block
|
|
|
|
|
// (footprint still off the landing column). The braking
|
|
|
|
|
// planner reads "remaining <= coastStop + lead" and returns
|
|
|
|
|
// Coast, which zeroes every input - if the bot has already
|
|
|
|
|
// come to rest this means the segment hangs forever and the
|
|
|
|
|
// pathing manager replans. When we are stopped, not inside
|
|
|
|
|
// the target block, and not being asked to brake, walk
|
|
|
|
|
// toward the target instead of coasting so the landing
|
|
|
|
|
// resolves in one tick-window.
|
|
|
|
|
if (!decision.HoldBack
|
|
|
|
|
&& !TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, ExpectedEnd)
|
|
|
|
|
&& horizDistSq > 0.01
|
|
|
|
|
&& TemplateHelper.GetHorizontalSpeed(physics) < 0.03)
|
|
|
|
|
{
|
|
|
|
|
float walkYaw = TemplateHelper.CalculateYaw(dx, dz);
|
|
|
|
|
physics.Yaw = TemplateHelper.SmoothYaw(physics.Yaw, walkYaw);
|
|
|
|
|
input.Forward = true;
|
|
|
|
|
input.Sprint = _needsSprint;
|
|
|
|
|
|
|
|
|
|
if (GroundedSegmentController.ShouldComplete(_segment, pos, physics))
|
|
|
|
|
return TemplateState.Complete;
|
|
|
|
|
return TemplateState.InProgress;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 00:11:12 +08:00
|
|
|
if (horizDistSq > 0.01 && !decision.HoldBack)
|
2026-04-13 15:35:43 +00:00
|
|
|
{
|
2026-04-18 06:14:45 +00:00
|
|
|
float groundedYaw = onOrPastTarget
|
|
|
|
|
? TemplateHelper.GetExitHeadingYaw(_segment)
|
|
|
|
|
: TemplateHelper.ShouldBiasTowardExitHeading(pos, _segment)
|
2026-04-13 15:35:43 +00:00
|
|
|
? TemplateHelper.GetExitHeadingYaw(_segment)
|
|
|
|
|
: targetYaw;
|
|
|
|
|
physics.Yaw = TemplateHelper.SmoothYaw(physics.Yaw, groundedYaw);
|
|
|
|
|
}
|
2026-04-12 18:46:42 +08:00
|
|
|
|
2026-04-13 00:11:12 +08:00
|
|
|
TemplateHelper.ApplyDecision(input, decision);
|
|
|
|
|
if (decision.HoldBack)
|
|
|
|
|
TemplateHelper.FaceSegmentHeading(physics, _segment);
|
|
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
if (GroundedSegmentController.ShouldComplete(_segment, pos, physics))
|
2026-04-12 18:46:42 +08:00
|
|
|
return TemplateState.Complete;
|
|
|
|
|
}
|
|
|
|
|
else if (physics.OnClimbable)
|
2026-04-12 00:49:09 +08:00
|
|
|
{
|
|
|
|
|
if (horizDistSq > 0.25)
|
|
|
|
|
{
|
2026-04-12 01:15:17 +08:00
|
|
|
physics.Yaw = TemplateHelper.SmoothYaw(physics.Yaw, targetYaw);
|
2026-04-12 00:49:09 +08:00
|
|
|
input.Forward = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (horizDistSq > 0.01)
|
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-18 06:14:45 +00:00
|
|
|
bool onOrPastTarget = TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, ExpectedEnd)
|
|
|
|
|
|| TemplateHelper.HasReachedSegmentEndPlane(pos, _segment);
|
2026-04-22 16:43:43 +00:00
|
|
|
// Airborne bias toward the exit heading is only safe when
|
|
|
|
|
// the bot has effectively finished the current segment's
|
|
|
|
|
// horizontal travel: either the footprint is inside the
|
|
|
|
|
// landing block, or the vertical drop is small enough that
|
|
|
|
|
// lateral drift cannot miss the 1x1 landing column. For
|
|
|
|
|
// multi-block drops the bot is in the air for 8+ ticks;
|
|
|
|
|
// rotating yaw mid-fall (e.g. after crossing the end plane
|
|
|
|
|
// but still 1-2 blocks above landing) pushes sprint/walk
|
|
|
|
|
// momentum perpendicular to the segment and drifts the bot
|
|
|
|
|
// off the landing column into the void. Keep yaw pointed
|
|
|
|
|
// at the landing center through the whole fall on multi-Y
|
|
|
|
|
// descends; GroundedSegmentController rotates yaw once the
|
|
|
|
|
// bot is actually standing on the landing column.
|
|
|
|
|
double segmentYDrop = _segment.Start.Y - _segment.End.Y;
|
|
|
|
|
bool isSingleStepDescend = segmentYDrop <= 1.0;
|
|
|
|
|
bool footInsideTarget = TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, ExpectedEnd);
|
|
|
|
|
bool biasTowardExitInAir = footInsideTarget
|
|
|
|
|
|| (isSingleStepDescend
|
|
|
|
|
&& (onOrPastTarget
|
|
|
|
|
|| (_hasFallen
|
|
|
|
|
&& TemplateHelper.ShouldBiasTowardExitHeading(pos, _segment, distanceThreshold: 1.5))));
|
2026-04-18 06:14:45 +00:00
|
|
|
float airborneYaw = biasTowardExitInAir
|
|
|
|
|
? TemplateHelper.GetExitHeadingYaw(_segment)
|
|
|
|
|
: targetYaw;
|
|
|
|
|
|
|
|
|
|
physics.Yaw = TemplateHelper.SmoothYaw(physics.Yaw, airborneYaw);
|
|
|
|
|
if (_hasFallen || YawDifference(physics.Yaw, airborneYaw) <= PreDropYawToleranceDeg)
|
2026-04-13 00:11:12 +08:00
|
|
|
{
|
|
|
|
|
if (!_hasFallen && !_needsSprint && ShouldCoastOffLedge(pos))
|
|
|
|
|
{
|
|
|
|
|
// For short descends into a stop or turn, release forward near the lip
|
|
|
|
|
// so the landing stays on the intended support instead of overshooting it.
|
|
|
|
|
}
|
|
|
|
|
else if (!_hasFallen && !_needsSprint)
|
|
|
|
|
{
|
|
|
|
|
GroundedSegmentController.Apply(_segment, _nextSegment, pos, physics, input, world);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-04-13 15:35:43 +00:00
|
|
|
TransitionBrakingDecision decision = TransitionBrakingPlanner.Plan(_segment, _nextSegment, pos, physics, world);
|
2026-04-22 16:43:43 +00:00
|
|
|
// Multi-block descend overshoot guard: when the
|
|
|
|
|
// fall spans 2+ Y blocks, sprint momentum will
|
|
|
|
|
// carry the bot roughly one extra horizontal
|
|
|
|
|
// block past the planned landing. If the next
|
|
|
|
|
// segment prepares a jump (PrepareJump exit) the
|
|
|
|
|
// bot MUST land inside the planned 1x1 landing
|
|
|
|
|
// column so the jump takeoff has a valid footing;
|
|
|
|
|
// overshooting drops into the void or onto a
|
|
|
|
|
// block 1-2 tiers below, breaking the jump.
|
|
|
|
|
// Once airborne and past the landing end-plane,
|
|
|
|
|
// release forward input so sprint momentum decays
|
|
|
|
|
// via air drag over the final 1-2 ticks of fall,
|
|
|
|
|
// pulling the bot back into the landing column.
|
|
|
|
|
bool riskyOvershoot = _hasFallen
|
|
|
|
|
&& segmentYDrop >= 2.0
|
|
|
|
|
&& onOrPastTarget
|
|
|
|
|
&& _segment.ExitTransition == PathTransitionType.PrepareJump;
|
|
|
|
|
if (riskyOvershoot)
|
|
|
|
|
{
|
|
|
|
|
input.Forward = false;
|
|
|
|
|
input.Sprint = false;
|
|
|
|
|
input.Back = true;
|
|
|
|
|
}
|
|
|
|
|
else if (_segment.ExitHints.AllowAirBrake)
|
2026-04-13 15:35:43 +00:00
|
|
|
{
|
|
|
|
|
TemplateHelper.ApplyDecision(input, decision);
|
|
|
|
|
if (decision.HoldForward && _needsSprint)
|
|
|
|
|
input.Sprint = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
input.Forward = true;
|
|
|
|
|
if (_needsSprint)
|
|
|
|
|
input.Sprint = true;
|
|
|
|
|
}
|
2026-04-13 00:11:12 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TemplateState.InProgress;
|
|
|
|
|
}
|
2026-04-13 00:11:12 +08:00
|
|
|
|
|
|
|
|
private bool ShouldCoastOffLedge(Location pos)
|
|
|
|
|
{
|
|
|
|
|
if (_segment.ExitTransition == PathTransitionType.ContinueStraight)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
double remaining = (_segment.End.X - pos.X) * _segment.HeadingX
|
|
|
|
|
+ (_segment.End.Z - pos.Z) * _segment.HeadingZ;
|
2026-04-13 15:35:43 +00:00
|
|
|
return remaining <= 0.55
|
|
|
|
|
&& TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, _segment.End);
|
2026-04-13 00:11:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static float YawDifference(float current, float target)
|
|
|
|
|
{
|
|
|
|
|
float delta = target - current;
|
|
|
|
|
while (delta > 180f) delta -= 360f;
|
|
|
|
|
while (delta < -180f) delta += 360f;
|
|
|
|
|
return Math.Abs(delta);
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|