mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added slab handling for 1.20/.1
Added Farm bot crops handling for 1.20/.1 Added utilities for Containers/Inventories Added bot movement lock to prevent multiple bots that use movements from running at the same time. General code improvements.
This commit is contained in:
parent
497a1174de
commit
272900d52e
11 changed files with 941 additions and 797 deletions
35
MinecraftClient/Scripting/BotMovementLock.cs
Normal file
35
MinecraftClient/Scripting/BotMovementLock.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
namespace MinecraftClient.Scripting;
|
||||
|
||||
public class BotMovementLock
|
||||
{
|
||||
private static BotMovementLock? InstancePrivate;
|
||||
private string _heldBy = string.Empty;
|
||||
|
||||
private BotMovementLock()
|
||||
{
|
||||
InstancePrivate = this;
|
||||
}
|
||||
|
||||
public static BotMovementLock? Instance => InstancePrivate ??= new BotMovementLock();
|
||||
|
||||
public bool Lock(string owner)
|
||||
{
|
||||
if (owner.Trim().Length == 0 || _heldBy.Length > 0)
|
||||
return false;
|
||||
|
||||
_heldBy = owner.Trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UnLock(string owner)
|
||||
{
|
||||
if (owner.Trim().Length == 0 || _heldBy.Length == 0 || !_heldBy.ToLower().Equals(owner.ToLower().Trim()))
|
||||
return false;
|
||||
|
||||
_heldBy = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsLocked => _heldBy.Length > 0;
|
||||
public string LockedBy => _heldBy;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue