fix: handle climbable blocks in WalkTemplate to prevent stuck on ladders

WalkTemplate now detects when physics.OnClimbable is true (player entering
a ladder/vine block) and switches from Sprint to Jump input, with extended
stuck detection thresholds. This prevents the template from failing when
the path walks through climbable blocks.

Tested on 1.21.11: all movement types pass (walk, diagonal, ascend, descend,
climb, parkour 2-4 gap, mixed courses with direction changes).

Made-with: Cursor
This commit is contained in:
BruceChen 2026-04-12 00:23:01 +08:00
parent 8ece75acc3
commit fb30886756

View file

@ -32,16 +32,27 @@ namespace MinecraftClient.Pathing.Execution.Templates
double dz = ExpectedEnd.Z - pos.Z;
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
input.Forward = true;
input.Sprint = true;
if (physics.OnClimbable)
{
input.Jump = true;
input.Sprint = false;
}
else
{
input.Sprint = true;
}
if (TemplateHelper.IsNear(pos, ExpectedEnd, horizThresholdSq: 0.20))
return TemplateState.Complete;
double movedSq = TemplateHelper.HorizontalDistanceSq(pos, _lastPos);
int stuckThreshold = physics.OnClimbable ? 80 : 40;
_stuckTicks = movedSq < 0.0005 ? _stuckTicks + 1 : 0;
_lastPos = pos;
if (_stuckTicks > 40 || _tickCount > 100)
int tickLimit = physics.OnClimbable ? 160 : 100;
if (_stuckTicks > stuckThreshold || _tickCount > tickLimit)
return TemplateState.Failed;
return TemplateState.InProgress;