Improve pathfinding capabilities (#1999)

* Add `ClientIsMoving()` API to determine if currently walking/falling
* Improve `MoveToLocation()` performance and allow approaching location
Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
Daenges 2022-04-29 22:56:41 +00:00 committed by GitHub
parent aeca6a8f53
commit 708815fe61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 138 additions and 53 deletions

View file

@ -983,13 +983,26 @@ namespace MinecraftClient
/// </summary>
/// <param name="location">Location to reach</param>
/// <param name="allowUnsafe">Allow possible but unsafe locations thay may hurt the player: lava, cactus...</param>
/// <param name="allowDirectTeleport">Allow non-vanilla teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
/// <param name="allowDirectTeleport">Allow non-vanilla direct teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
/// <param name="maxOffset">If no valid path can be found, also allow locations within specified distance of destination</param>
/// <param name="minOffset">Do not get closer of destination than specified distance</param>
/// <param name="timeout">How long to wait before stopping computation (default: 5 seconds)</param>
/// <remarks>When location is unreachable, computation will reach timeout, then optionally fallback to a close location within maxOffset</remarks>
/// <returns>True if a path has been found</returns>
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowDirectTeleport = false)
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
{
return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport);
return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout);
}
/// <summary>
/// Check if the client is currently processing a Movement.
/// </summary>
/// <returns>true if a movement is currently handled</returns>
protected bool ClientIsMoving()
{
return Handler.ClientIsMoving();
}
/// <summary>
/// Look at the specified location
/// </summary>