2026-04-12 21:33:24 +08:00
|
|
|
using MinecraftClient.Mapping;
|
2026-04-15 16:37:12 +00:00
|
|
|
using MinecraftClient.Pathing.Core;
|
2026-04-12 21:33:24 +08:00
|
|
|
using MinecraftClient.Physics;
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Pathing.Execution.Templates
|
|
|
|
|
{
|
|
|
|
|
internal static class GroundedSegmentController
|
|
|
|
|
{
|
2026-04-13 15:35:43 +00:00
|
|
|
private const double FinalStopFastCompleteSpeed = 0.08;
|
2026-04-17 20:09:56 +00:00
|
|
|
private const double PrepareJumpHandoffDistance = 0.40;
|
2026-04-13 15:35:43 +00:00
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
internal static void Apply(PathSegment segment, PathSegment? nextSegment, Location pos, PlayerPhysics physics, MovementInput input, World world)
|
|
|
|
|
{
|
2026-04-15 16:37:12 +00:00
|
|
|
if (segment.ExitTransition == PathTransitionType.PrepareJump
|
|
|
|
|
&& segment.ExitHints.RequireJumpReady
|
|
|
|
|
&& physics.OnGround
|
|
|
|
|
&& TemplateFootingHelper.IsCenterInsideTargetBlock(pos, segment.End)
|
|
|
|
|
&& IsReadyToFreezeForTurn(segment, pos)
|
|
|
|
|
&& TemplateHelper.HeadingPenaltyDegrees(physics.Yaw, segment) > 8.0)
|
|
|
|
|
{
|
|
|
|
|
input.Forward = false;
|
|
|
|
|
input.Sprint = false;
|
|
|
|
|
input.Back = false;
|
pathing: add side-wall theory, full-coverage parkour test suite, and live test fixes
Theory simulator:
- Add 2D side-wall jump physics with yaw sweep for worst-case margin
- Generate sidewall theory cases (flat/ascend/descend, wall_offset 0/1)
- Add momentum-capabilities.json with band compression and max_reach
- Extend models, capabilities, canonical, and renderers for sidewall
Full-coverage parkour test suite (tools/test-parkour.py):
- Derive test matrix from momentum-capabilities.json
- Build linear/neo/ceiling courses via RCON with 7-block clear margin
- Use /goto for pathfinding, parse A* and PathMgr log output
- Stop-at-first-failure per (family, subfamily, dy, ceil, wo) group
- Hierarchical --filter (e.g. linear/flat, ceiling/headhitter/ceil2.5)
- Exclude sidewall from default matrix (identical max_reach to linear)
Pathing execution fixes:
- Align parkour contracts and timing budgets with live test results
- Fix jump-entry yaw snapping for grounded handoffs
- Template helper and sprint jump template refinements
Made-with: Cursor
2026-04-15 17:52:47 +00:00
|
|
|
TemplateHelper.FaceExitHeading(physics, segment);
|
2026-04-15 16:37:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 16:43:43 +00:00
|
|
|
// Compute the braking decision first so rotation and input stay
|
|
|
|
|
// consistent. Applying the exit-heading bias while we are still
|
|
|
|
|
// braking causes the Back input (which acts opposite to yaw) to
|
|
|
|
|
// push the bot perpendicular to the segment line, which on narrow
|
|
|
|
|
// 1-block walkways turns into a side-off-the-edge step. Stay on
|
|
|
|
|
// the segment heading for as long as we are braking and only let
|
|
|
|
|
// the bias rotate us once the brake has released.
|
2026-04-12 21:33:24 +08:00
|
|
|
TransitionBrakingDecision decision = TransitionBrakingPlanner.Plan(segment, nextSegment, pos, physics, world);
|
|
|
|
|
TemplateHelper.ApplyDecision(input, decision);
|
|
|
|
|
if (decision.HoldBack)
|
2026-04-22 16:43:43 +00:00
|
|
|
{
|
2026-04-12 21:33:24 +08:00
|
|
|
TemplateHelper.FaceSegmentHeading(physics, segment);
|
2026-04-22 16:43:43 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// On stable-footing Turn exits (the next segment is a walk-like
|
|
|
|
|
// move, not a jump) the next template snaps yaw instantly on
|
|
|
|
|
// its first tick, so pre-rotating here is unnecessary. On
|
|
|
|
|
// narrow 1-block walkways the bias combined with along-segment
|
|
|
|
|
// momentum pushes the bot perpendicular to the walkway and
|
|
|
|
|
// walks it off the edge (the bot sprint-drifts diagonally
|
|
|
|
|
// while yaw rotates ~45 deg mid-stride). For Turn exits into
|
|
|
|
|
// a jump (RequireJumpReady) we still need to align yaw before
|
|
|
|
|
// takeoff, so keep the bias there.
|
|
|
|
|
bool suppressBiasForSafeTurn = segment.ExitTransition == PathTransitionType.Turn
|
|
|
|
|
&& segment.ExitHints.RequireStableFooting
|
|
|
|
|
&& !segment.ExitHints.RequireJumpReady;
|
|
|
|
|
if (!suppressBiasForSafeTurn
|
|
|
|
|
&& TemplateHelper.ShouldBiasTowardExitHeading(pos, segment))
|
|
|
|
|
TemplateHelper.FaceExitHeading(physics, segment);
|
2026-04-12 21:33:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static bool ShouldComplete(PathSegment segment, Location pos, PlayerPhysics physics)
|
|
|
|
|
{
|
2026-04-13 15:35:43 +00:00
|
|
|
if (segment.ExitHints.RequireGrounded && !physics.OnGround)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (segment.ExitTransition == PathTransitionType.ContinueStraight
|
2026-04-17 20:09:56 +00:00
|
|
|
&& physics.OnGround)
|
2026-04-13 15:35:43 +00:00
|
|
|
{
|
2026-04-17 20:09:56 +00:00
|
|
|
if (TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, segment.End)
|
|
|
|
|
&& !TemplateFootingHelper.WillLeaveTargetBlockNextTick(pos, physics, segment.End))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TemplateHelper.IsSettledAtEnd(pos, segment.End, physics))
|
|
|
|
|
return true;
|
2026-04-13 15:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (segment.ExitTransition == PathTransitionType.FinalStop
|
|
|
|
|
&& physics.OnGround
|
|
|
|
|
&& TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, segment.End)
|
|
|
|
|
&& !TemplateFootingHelper.WillLeaveTargetBlockNextTick(pos, physics, segment.End))
|
|
|
|
|
{
|
|
|
|
|
return TemplateHelper.GetHorizontalSpeed(physics) <= FinalStopFastCompleteSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double exitSpeed = TemplateHelper.ProjectHorizontalSpeedAlongHint(physics, segment);
|
2026-04-22 16:43:43 +00:00
|
|
|
// On Turn exits we deliberately do NOT pre-rotate yaw toward the
|
|
|
|
|
// next segment's heading (see Apply() above). The next segment's
|
|
|
|
|
// template snaps yaw on its first tick, so measuring heading
|
|
|
|
|
// readiness against the exit heading here would deadlock the
|
|
|
|
|
// handoff (bot is still facing segment heading, would never pass
|
|
|
|
|
// the 15 deg gate). Measure against segment heading for Turn
|
|
|
|
|
// exits with stable footing where yaw will be snapped anyway.
|
|
|
|
|
bool headingReady;
|
|
|
|
|
if (segment.ExitTransition == PathTransitionType.Turn
|
|
|
|
|
&& segment.ExitHints.RequireStableFooting
|
|
|
|
|
&& !segment.ExitHints.RequireJumpReady)
|
|
|
|
|
{
|
|
|
|
|
headingReady = TemplateHelper.HeadingPenaltyDegrees(physics.Yaw, segment.HeadingX, segment.HeadingZ) <= 25.0
|
|
|
|
|
|| TemplateHelper.HeadingPenaltyDegrees(physics.Yaw, segment) <= 15.0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
headingReady = TemplateHelper.HeadingPenaltyDegrees(physics.Yaw, segment)
|
|
|
|
|
<= (segment.ExitHints.RequireJumpReady ? 8.0 : 15.0);
|
|
|
|
|
}
|
2026-04-13 15:35:43 +00:00
|
|
|
|
|
|
|
|
if (!headingReady)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (segment.ExitTransition == PathTransitionType.PrepareJump
|
|
|
|
|
&& physics.OnGround
|
|
|
|
|
&& segment.ExitHints.RequireJumpReady
|
2026-04-15 16:37:12 +00:00
|
|
|
&& TemplateFootingHelper.IsCenterInsideTargetBlock(pos, segment.End))
|
2026-04-13 15:35:43 +00:00
|
|
|
{
|
2026-04-15 16:37:12 +00:00
|
|
|
if (segment.MoveType == MoveType.Ascend)
|
|
|
|
|
return true;
|
|
|
|
|
|
2026-04-17 20:09:56 +00:00
|
|
|
double handoffDistance = segment.MoveType == MoveType.Parkour
|
|
|
|
|
? 0.55
|
|
|
|
|
: PrepareJumpHandoffDistance;
|
2026-04-15 16:37:12 +00:00
|
|
|
|
2026-04-17 20:09:56 +00:00
|
|
|
return TemplateHelper.RemainingDistanceAlongSegment(pos, segment) <= handoffDistance;
|
2026-04-13 15:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
pathing: 0-replan on long Descend->Traverse + cold-start 5 c2c
Two complementary fixes for live-server "stuck on a step then replan"
on the 252.5,138,220.5 -> 244.5,122,188.5 route.
Search layer (ParkourFeasibility.HasRunUp): a long flat sprint parkour
(5 c2c, horiz~5) cannot launch from a cold start. Vanilla physics show
that gap=4 dy=0 reaches 5.1075m only with 12 momentum ticks of straight
sprint windup; a 0t standing jump tops out at gap=3 (=4 c2c). When the
previous move type is not Parkour/Descend (i.e. no carried airborne
momentum) we now require two aligned back-runway blocks instead of one
so the executor actually has room to spin sprint up.
Execution layer (GroundedSegmentController.ShouldComplete): the
LandingRecovery early-out used to live below the MinExitSpeed gate. A
Descend that landed inside the destination block but naturally settled
to zero speed (e.g. when the next segment is a fresh Traverse rather
than a chained Parkour) would fail the 0.03 MinExitSpeed check and idle
inside the target block until the per-segment timeout fired, triggering
an unnecessary replan. Move the LandingRecovery footprint check above
the speed gate so a fully-decelerated handoff is accepted.
Verified live on 1.21.11-Vanilla:
- 252.5,138,220.5 -> 244.5,122,188.5: 24 segments, 0 replans (was: 1)
- 244.5,122,188.5 -> 252.5,138,220.5: 48 segments, 0 replans
- 251.5,141,210.5 -> 252.5,138,220.5: 34 segments, 0 replans
- 252.5,138,220.5 -> 251.5,141,210.5: 24 segments, 0 replans
Test suite: 297 passed / 22 known pre-existing failures, no new
regressions vs 5de169db.
Made-with: Cursor
2026-04-25 18:08:08 +00:00
|
|
|
// LandingRecovery accepts a fully-decelerated handoff: once the bot
|
|
|
|
|
// has reached the target block on the ground, the segment has done
|
|
|
|
|
// its job. Apply this before the MinExitSpeed gate so a Descend
|
|
|
|
|
// that lands and naturally settles to zero speed (e.g. when the
|
|
|
|
|
// following segment is a fresh Traverse rather than a chained
|
|
|
|
|
// Parkour) can hand off cleanly. Without this early-out the bot
|
|
|
|
|
// would idle inside the destination block until the segment timed
|
|
|
|
|
// out, triggering an unnecessary replan.
|
2026-04-17 20:09:56 +00:00
|
|
|
if (segment.ExitTransition == PathTransitionType.LandingRecovery
|
|
|
|
|
&& physics.OnGround
|
|
|
|
|
&& !segment.ExitHints.RequireStableFooting
|
|
|
|
|
&& TemplateFootingHelper.IsFootprintInsideTargetBlock(pos, segment.End))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
pathing: 0-replan on long Descend->Traverse + cold-start 5 c2c
Two complementary fixes for live-server "stuck on a step then replan"
on the 252.5,138,220.5 -> 244.5,122,188.5 route.
Search layer (ParkourFeasibility.HasRunUp): a long flat sprint parkour
(5 c2c, horiz~5) cannot launch from a cold start. Vanilla physics show
that gap=4 dy=0 reaches 5.1075m only with 12 momentum ticks of straight
sprint windup; a 0t standing jump tops out at gap=3 (=4 c2c). When the
previous move type is not Parkour/Descend (i.e. no carried airborne
momentum) we now require two aligned back-runway blocks instead of one
so the executor actually has room to spin sprint up.
Execution layer (GroundedSegmentController.ShouldComplete): the
LandingRecovery early-out used to live below the MinExitSpeed gate. A
Descend that landed inside the destination block but naturally settled
to zero speed (e.g. when the next segment is a fresh Traverse rather
than a chained Parkour) would fail the 0.03 MinExitSpeed check and idle
inside the target block until the per-segment timeout fired, triggering
an unnecessary replan. Move the LandingRecovery footprint check above
the speed gate so a fully-decelerated handoff is accepted.
Verified live on 1.21.11-Vanilla:
- 252.5,138,220.5 -> 244.5,122,188.5: 24 segments, 0 replans (was: 1)
- 244.5,122,188.5 -> 252.5,138,220.5: 48 segments, 0 replans
- 251.5,141,210.5 -> 252.5,138,220.5: 34 segments, 0 replans
- 252.5,138,220.5 -> 251.5,141,210.5: 24 segments, 0 replans
Test suite: 297 passed / 22 known pre-existing failures, no new
regressions vs 5de169db.
Made-with: Cursor
2026-04-25 18:08:08 +00:00
|
|
|
if (exitSpeed < segment.ExitHints.MinExitSpeed)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (exitSpeed > segment.ExitHints.MaxExitSpeed)
|
|
|
|
|
return false;
|
|
|
|
|
|
2026-04-13 15:35:43 +00:00
|
|
|
if (segment.ExitHints.RequireStableFooting)
|
|
|
|
|
{
|
|
|
|
|
return physics.OnGround
|
|
|
|
|
&& (segment.ExitTransition == PathTransitionType.FinalStop
|
|
|
|
|
? TemplateHelper.IsSettledAtEnd(pos, segment.End, physics)
|
|
|
|
|
: TemplateHelper.IsSettledOnTargetBlock(pos, segment.End, physics));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (segment.ExitHints.RequireJumpReady)
|
|
|
|
|
{
|
|
|
|
|
return physics.OnGround
|
|
|
|
|
&& TemplateHelper.HasReachedSegmentEndPlane(pos, segment)
|
|
|
|
|
&& exitSpeed >= segment.ExitHints.MinExitSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 21:33:24 +08:00
|
|
|
return segment.ExitTransition switch
|
|
|
|
|
{
|
|
|
|
|
PathTransitionType.ContinueStraight => TemplateHelper.IsNear(pos, segment.End, horizThresholdSq: 0.09),
|
|
|
|
|
PathTransitionType.PrepareJump => TemplateHelper.HasReachedSegmentEndPlane(pos, segment)
|
2026-04-13 15:35:43 +00:00
|
|
|
&& exitSpeed > 0.02,
|
|
|
|
|
PathTransitionType.FinalStop => physics.OnGround && TemplateHelper.IsSettledAtEnd(pos, segment.End, physics),
|
2026-04-12 21:33:24 +08:00
|
|
|
_ => physics.OnGround && TemplateHelper.IsSettledOnTargetBlock(pos, segment.End, physics)
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-04-15 16:37:12 +00:00
|
|
|
|
|
|
|
|
private static bool IsReadyToFreezeForTurn(PathSegment segment, Location pos)
|
|
|
|
|
{
|
|
|
|
|
if (segment.MoveType == MoveType.Ascend)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (segment.MoveType == MoveType.Parkour
|
|
|
|
|
|| (segment.HeadingX != 0 && segment.HeadingZ != 0))
|
|
|
|
|
{
|
2026-04-17 20:09:56 +00:00
|
|
|
return TemplateHelper.RemainingDistanceAlongSegment(pos, segment) <= PrepareJumpHandoffDistance;
|
2026-04-15 16:37:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2026-04-12 21:33:24 +08:00
|
|
|
}
|
|
|
|
|
}
|