Minecraft-Console-Client/MinecraftClient/Pathing/Moves/Impl/MoveClimb.cs
BruceChen 1abab20f17 feat: add Phase 1 core pathfinding architecture
Implements the new Baritone-inspired A* pathfinding system:
- Core types: PathNode, PathResult, MoveResult, MoveType, ActionCosts
- BinaryHeapOpenSet min-heap for A* open set
- AStarPathFinder with timeout, cancellation, partial path support
- CalculationContext for thread-safe world state snapshots
- MoveHelper for block passability checks
- IGoal interface + GoalBlock, GoalXZ, GoalNear, GoalComposite
- IMove interface + MoveTraverse, MoveDiagonal, MoveAscend, MoveDescend, MoveClimb
- /pathfind command for testing the new pathfinder

Made-with: Cursor
2026-04-12 18:43:32 +00:00

64 lines
1.8 KiB
C#

using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Moves.Impl
{
/// <summary>
/// Climb up or down a ladder/vine at the current X,Z position.
/// </summary>
public sealed class MoveClimb : IMove
{
public MoveType Type => MoveType.Climb;
public int XOffset => 0;
public int ZOffset => 0;
public bool DynamicY => false;
private readonly bool _up;
public MoveClimb(bool up)
{
_up = up;
}
public void Calculate(CalculationContext ctx, int x, int y, int z, ref MoveResult result)
{
var currentMat = ctx.GetMaterial(x, y, z);
if (!MoveHelper.IsClimbable(currentMat))
{
result.SetImpossible();
return;
}
if (_up)
{
int destY = y + 1;
if (!ctx.CanWalkThrough(x, destY + 1, z))
{
result.SetImpossible();
return;
}
var aboveMat = ctx.GetMaterial(x, destY, z);
if (MoveHelper.IsClimbable(aboveMat) || !ctx.GetMaterial(x, destY, z).IsSolid())
{
result.Set(x, destY, z, ActionCosts.LadderUpOne);
return;
}
result.SetImpossible();
}
else
{
int destY = y - 1;
var belowMat = ctx.GetMaterial(x, destY, z);
if (MoveHelper.IsClimbable(belowMat) || !belowMat.IsSolid())
{
result.Set(x, destY, z, ActionCosts.LadderDownOne);
return;
}
result.SetImpossible();
}
}
}
}