feat: add pose system, slime block bounce, and crawling to physics engine

Implement the three Phase 0 prerequisites for the pathfinding rewrite:

- Pose system (vanilla Player.updatePlayerPose): dynamic AABB height based
  on current pose -- Standing (1.8), Sneaking (1.5), Swimming/Crawling (0.6).
  Automatically downgrades pose when headroom is insufficient (Standing ->
  Sneaking -> Swimming), matching vanilla 1.14+ forced-crawl behavior.

- Slime block bounce (vanilla SlimeBlock.bounceUp / stepOn): reverses
  downward velocity on landing, with sneaking suppression via
  isSuppressingBounce(). Also applies the horizontal slowdown effect
  from SlimeBlock.stepOn when walking on slime with low vertical velocity.

- Per-pose dimension constants in PhysicsConsts with eye heights for each
  pose, sourced from vanilla Avatar.POSES (26.1 decompiled).

- Debug logging for pose transitions, slime bounces, and periodic physics
  state dumps routed through McClient's ILogger.

Tested on a real 1.21.11 server: crawling triggers correctly under 1-block
ceilings, sneaking under 1.5-block ceilings, slime bounce produces correct
decaying oscillation, and pose recovery works when obstacles are removed.

Made-with: Cursor
This commit is contained in:
BruceChen 2026-04-11 01:35:58 +08:00
parent 4013d39068
commit 3efe63c54d
3 changed files with 186 additions and 17 deletions

View file

@ -1,3 +1,5 @@
using System;
namespace MinecraftClient.Physics
{
/// <summary>
@ -6,12 +8,19 @@ namespace MinecraftClient.Physics
/// </summary>
public static class PhysicsConsts
{
// --- Player dimensions ---
// --- Player dimensions per pose (vanilla Avatar.POSES, 26.1) ---
public const double PlayerWidth = 0.6;
public const double PlayerHeight = 1.8;
public const double PlayerSneakHeight = 1.5;
public const double PlayerSwimHeight = 0.6;
public const double PlayerEyeHeight = 1.62;
public const double PlayerStandingHeight = 1.8;
public const double PlayerStandingEyeHeight = 1.62;
public const double PlayerCrouchingHeight = 1.5;
public const double PlayerCrouchingEyeHeight = 1.27;
public const double PlayerSwimmingHeight = 0.6;
public const double PlayerSwimmingEyeHeight = 0.4;
[Obsolete("Use PlayerStandingHeight instead")]
public const double PlayerHeight = PlayerStandingHeight;
[Obsolete("Use PlayerStandingEyeHeight instead")]
public const double PlayerEyeHeight = PlayerStandingEyeHeight;
// --- Gravity ---
public const double DefaultGravity = 0.08;