mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using System;
|
|
using MinecraftClient.Mapping;
|
|
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.
|
|
/// </summary>
|
|
public sealed class DescendTemplate : IActionTemplate
|
|
{
|
|
public Location ExpectedStart { get; }
|
|
public Location ExpectedEnd { get; }
|
|
|
|
private int _tickCount;
|
|
private bool _hasFallen;
|
|
|
|
public DescendTemplate(Location start, Location end)
|
|
{
|
|
ExpectedStart = start;
|
|
ExpectedEnd = end;
|
|
}
|
|
|
|
public TemplateState Tick(Location pos, PlayerPhysics physics, MovementInput input)
|
|
{
|
|
_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;
|
|
|
|
if (_hasFallen && physics.OnGround && horizDistSq < 0.5 && Math.Abs(dy) < 0.8)
|
|
return TemplateState.Complete;
|
|
|
|
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;
|
|
|
|
if (horizDistSq > 0.01)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|