Minecraft-Console-Client/MinecraftClient/Pathing/Core/CalculationContext.cs
BruceChen da52aa5c3c pathing: sidewall runup precondition via EntryPreparation
Introduce an EntryPreparationState carried on PathNode + A* context so
sidewall parkour can explicitly request one or more runway traverses
before takeoff instead of silently dropping the move. ParkourFeasibility
gains TryGetRequiredStaticEntryRunupSteps + HasPreparedRunup helpers so
long descends (major=5, dy=-1) only remain feasible when the preceding
node proved the runup.

Widen HasDominantAxisRunUp to accept cold-start sprint-jumps within
~3.1-3.5 blocks horizontally so lone overhang / staircase takeoffs stay
feasible without a 2-block runway (matches Baritone's MomentumBehavior
.ALLOWED contract).

Add a runtime SidewallParkourController that implements the corner
commitment + wall-hug chain during execution.

Extend pathing test fixtures with InitialMomentumTicks, add sidewall
accepted/rejected scenarios, and refresh timing + contract baselines to
reflect the new planner shapes. Document the design in
docs/superpowers/specs and plans.

Made-with: Cursor
2026-04-19 17:03:03 +00:00

75 lines
2.8 KiB
C#

using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Moves;
namespace MinecraftClient.Pathing.Core
{
/// <summary>
/// Thread-safe snapshot of world state and player capabilities for path planning.
/// Created once at the start of a search; all move calculations read from this.
/// </summary>
public sealed class CalculationContext
{
public World World { get; }
public bool CanSprint { get; }
public bool AllowParkour { get; }
public bool AllowParkourAscend { get; }
public bool AllowDiagonalDescend { get; }
public int MaxFallHeight { get; }
public int MaxFallHeightWater { get; }
public bool AllowLadderGrabDuringFall { get; }
public double JumpPenalty { get; }
public double WalkCost { get; }
public double SprintCost { get; }
public double SneakCost { get; }
public MoveType PreviousMoveType { get; internal set; }
public EntryPreparationState CurrentEntryPreparation { get; internal set; }
public CalculationContext(
World world,
bool canSprint = true,
bool allowParkour = false,
bool allowParkourAscend = false,
bool allowDiagonalDescend = true,
int maxFallHeight = 3,
int maxFallHeightWater = 256,
bool allowLadderGrabDuringFall = true,
double jumpPenalty = ActionCosts.JumpPenalty)
{
World = world;
CanSprint = canSprint;
AllowParkour = allowParkour;
AllowParkourAscend = allowParkourAscend;
AllowDiagonalDescend = allowDiagonalDescend;
MaxFallHeight = maxFallHeight;
MaxFallHeightWater = maxFallHeightWater;
AllowLadderGrabDuringFall = allowLadderGrabDuringFall;
JumpPenalty = jumpPenalty;
WalkCost = ActionCosts.WalkOneBlock;
SprintCost = CanSprint ? ActionCosts.SprintOneBlock : ActionCosts.WalkOneBlock;
SneakCost = ActionCosts.SneakOneBlock;
}
public Block GetBlock(int x, int y, int z)
=> World.GetBlock(new Location(x, y, z));
public Material GetMaterial(int x, int y, int z)
=> GetBlock(x, y, z).Type;
public bool CanWalkThrough(int x, int y, int z)
=> MoveHelper.CanWalkThrough(this, x, y, z);
public bool CanWalkOn(int x, int y, int z)
=> MoveHelper.CanWalkOn(this, x, y, z);
public bool IsFullyPassable(int x, int y, int z)
=> MoveHelper.IsFullyPassable(this, x, y, z);
public bool IsChunkLoaded(int x, int z)
{
int cx = x >> 4;
int cz = z >> 4;
var col = World[cx, cz];
return col is not null && col.FullyLoaded;
}
}
}