This commit is contained in:
Anon 2026-04-04 00:32:07 +02:00
parent 1ca023be36
commit 3a4d8951d5
20 changed files with 1511 additions and 389 deletions

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MinecraftClient.Mapping
{
@ -150,17 +149,8 @@ namespace MinecraftClient.Mapping
public static Queue<Location>? CalculatePath(World world, Location start, Location goal, bool allowUnsafe,
int maxOffset, int minOffset, TimeSpan timeout)
{
CancellationTokenSource cts = new();
Task<Queue<Location>?> pathfindingTask = Task.Factory.StartNew(() =>
CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token));
pathfindingTask.Wait(timeout);
if (!pathfindingTask.IsCompleted)
{
cts.Cancel();
pathfindingTask.Wait();
}
return pathfindingTask.Result;
using CancellationTokenSource cts = new(timeout);
return CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token);
}
/// <summary>
@ -713,4 +703,4 @@ namespace MinecraftClient.Mapping
return true;
}
}
}
}