fix: correct collision axis ordering and step-up threshold to match vanilla

Two bugs in CollisionDetector caused persistent Y-axis bouncing (0.6 block
oscillation) while walking on flat ground:

1. GetAxisStepOrder used a complex 6-branch sorting that often placed
   horizontal axes before Y. Vanilla's Direction.Axis.axisStepOrder always
   resolves Y first, then the larger horizontal axis. Replaced with the
   simple two-case vanilla logic.

2. The horizontal-blocked checks (blockedX/blockedZ) used exact != which
   triggered on floating-point noise (~1e-15) from sin/cos in movement
   input. Vanilla uses Mth.equal (1e-5 threshold). This false positive
   caused step-up to fire every few ticks on flat terrain.

Also includes DescendTemplate robustness fixes from the previous session
(fail on unintended climbing, suppress forward input on climbable blocks).

Made-with: Cursor
This commit is contained in:
BruceChen 2026-04-11 13:22:23 +08:00
parent 4b49135107
commit 034c5d0cab
2 changed files with 15 additions and 25 deletions

View file

@ -40,6 +40,10 @@ namespace MinecraftClient.Pathing.Execution.Templates
if (horizDistSq < 0.25 && Math.Abs(dy) < 0.5 && physics.OnGround)
return TemplateState.Complete;
// Fail if climbing up instead of descending
if (pos.Y > ExpectedStart.Y + 2.0)
return TemplateState.Failed;
if (_tickCount > 120)
return TemplateState.Failed;
@ -47,6 +51,9 @@ namespace MinecraftClient.Pathing.Execution.Templates
{
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
input.Forward = true;
// Don't push into climbable blocks during descent
if (physics.OnClimbable)
input.Forward = false;
}
return TemplateState.InProgress;