mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Stage 1
This commit is contained in:
parent
1ca023be36
commit
3a4d8951d5
20 changed files with 1511 additions and 389 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue