feat: add transition-aware path execution braking

This commit is contained in:
BruceChen 2026-04-12 18:46:42 +08:00
parent 945eae958a
commit 3b4e552d70
23 changed files with 837 additions and 108 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System;
using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
@ -9,25 +9,13 @@ namespace MinecraftClient.Pathing.Execution
public required Location Start { get; init; }
public required Location End { get; init; }
public required MoveType MoveType { get; init; }
public PathTransitionType ExitTransition { get; init; } = PathTransitionType.FinalStop;
public bool PreserveSprint { get; init; }
public static List<PathSegment> FromPath(IReadOnlyList<PathNode> nodes)
{
var segments = new List<PathSegment>(nodes.Count - 1);
for (int i = 1; i < nodes.Count; i++)
{
var prev = nodes[i - 1];
var curr = nodes[i];
segments.Add(new PathSegment
{
Start = new Location(prev.X + 0.5, prev.Y, prev.Z + 0.5),
End = new Location(curr.X + 0.5, curr.Y, curr.Z + 0.5),
MoveType = curr.MoveUsed
});
}
return segments;
}
public int HeadingX => Math.Sign(End.X - Start.X);
public int HeadingZ => Math.Sign(End.Z - Start.Z);
public override string ToString() =>
$"{MoveType}: ({Start.X:F1},{Start.Y:F1},{Start.Z:F1})->({End.X:F1},{End.Y:F1},{End.Z:F1})";
$"{MoveType}: ({Start.X:F1},{Start.Y:F1},{Start.Z:F1})->({End.X:F1},{End.Y:F1},{End.Z:F1}), transition={ExitTransition}, preserveSprint={PreserveSprint}";
}
}