LocationBlacklistCollection
Allows you to "blacklist" (set as invalid) locations for a certain amount of times. Create with 'LocationBlacklistCollection.CreatePerBot(...)' or 'LocationBlacklistCollection.CreateGlobal(...)'.
Example usage
private static LocationBlacklistCollection blacklist =
LocationBlacklistCollection.CreateGlobal(3, // 3 bots need to blacklist to blacklist globally.
13600000, // 1 hour in milliseconds.
2); // block a 2x2 radius around a block as well.
public async Task OnTick() {
const ushort diamondOre = 56;
var block = Context.World.FindClosest(128, 64, // search a 256x128 area.
diamondOre, CpuMode.Medium_Usage, // search for diamond ore blocks.
block => !blacklist.IsBlocked(context, block.GetLocation())); // do not include blocks that are blacklisted.
if(block == null) {
Console.WriteLine("Could not find any reachable diamond ores");
return;
}
// Move to the closest diamond ore.
var moveTask = await block.MoveToInteractionRange().Task;
if(moveTask.Result != MoveResultType.Completed) {
Console.WriteLine($"Could not reach ore at {block.GetLocation()}, blacklisting it.");
blacklist.AddToBlockCounter(context, block.GetLocation());
return;
}
// Reached the block, mine it.
await block.Dig();
}Last updated