mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using MinecraftClient.Pathing.Core;
|
|
|
|
namespace MinecraftClient.Pathing.Moves.Impl
|
|
{
|
|
/// <summary>
|
|
/// Jump up 1 block in a cardinal direction.
|
|
/// Requires: headroom at (x, y+2, z), body space at dest (y+1, y+2), ground at dest (y).
|
|
/// </summary>
|
|
public sealed class MoveAscend : IMove
|
|
{
|
|
public MoveType Type => MoveType.Ascend;
|
|
public int XOffset { get; }
|
|
public int ZOffset { get; }
|
|
public bool DynamicY => false;
|
|
|
|
public MoveAscend(int xOffset, int zOffset)
|
|
{
|
|
XOffset = xOffset;
|
|
ZOffset = zOffset;
|
|
}
|
|
|
|
public void Calculate(CalculationContext ctx, int x, int y, int z, ref MoveResult result)
|
|
{
|
|
int destX = x + XOffset;
|
|
int destZ = z + ZOffset;
|
|
int destY = y + 1;
|
|
|
|
if (!ctx.CanWalkThrough(x, y + 2, z))
|
|
{
|
|
result.SetImpossible();
|
|
return;
|
|
}
|
|
|
|
if (!ctx.CanWalkThrough(destX, destY, destZ) || !ctx.CanWalkThrough(destX, destY + 1, destZ))
|
|
{
|
|
result.SetImpossible();
|
|
return;
|
|
}
|
|
|
|
if (!ctx.CanWalkOn(destX, y, destZ))
|
|
{
|
|
result.SetImpossible();
|
|
return;
|
|
}
|
|
|
|
double cost = ctx.SprintCost + ctx.JumpPenalty;
|
|
result.Set(destX, destY, destZ, cost);
|
|
}
|
|
}
|
|
}
|