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
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
|
|
namespace MinecraftClient.Pathing.Goals
|
|
{
|
|
public sealed class GoalNear : IGoal
|
|
{
|
|
public int X { get; }
|
|
public int Y { get; }
|
|
public int Z { get; }
|
|
public int Range { get; }
|
|
private readonly int _rangeSq;
|
|
|
|
public GoalNear(int x, int y, int z, int range)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
Z = z;
|
|
Range = range;
|
|
_rangeSq = range * range;
|
|
}
|
|
|
|
public bool IsInGoal(int x, int y, int z)
|
|
{
|
|
int dx = x - X;
|
|
int dy = y - Y;
|
|
int dz = z - Z;
|
|
return dx * dx + dy * dy + dz * dz <= _rangeSq;
|
|
}
|
|
|
|
public double Heuristic(int x, int y, int z)
|
|
{
|
|
int dx = Math.Abs(x - X);
|
|
int dy = Math.Abs(y - Y);
|
|
int dz = Math.Abs(z - Z);
|
|
double h = GoalBlock.DistanceHeuristic(dx, dy, dz);
|
|
double reduction = Range * Core.ActionCosts.SprintOneBlock;
|
|
return Math.Max(0, h - reduction);
|
|
}
|
|
|
|
public override string ToString() => $"GoalNear({X}, {Y}, {Z}, range={Range})";
|
|
}
|
|
}
|