Implemented "Click Window" for 1.18 (now sending the new required fields), formated few files with Visual Studio formatting. PS: left debug for people to see, I'll remove it once everything is working

This commit is contained in:
Dušan Milutinović 2022-07-01 18:59:58 +02:00
parent b5c4cd7566
commit 3d8c112159
7 changed files with 94 additions and 29 deletions

View file

@ -1066,7 +1066,7 @@ namespace MinecraftClient
/// <param name="timeout">How long to wait until the path is evaluated (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>
public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout=null)
public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
{
lock (locationLock)
{
@ -1244,7 +1244,7 @@ namespace MinecraftClient
item = inventories[windowId].Items[slotId];
// Inventory update must be after sending packet
bool result = handler.SendWindowAction(windowId, slotId, action, item);
bool result = handler.SendWindowAction(windowId, slotId, action, item, inventories[windowId].Items, inventories[windowId].StateID);
// Update our inventory base on action type
var inventory = GetInventory(windowId);
@ -1707,7 +1707,7 @@ namespace MinecraftClient
/// Teleporting to other entityies is NOT implemented yet
public bool Spectate(Entity entity)
{
if(entity.Type == EntityType.Player)
if (entity.Type == EntityType.Player)
{
return SpectateByUUID(entity.UUID);
}
@ -1723,9 +1723,9 @@ namespace MinecraftClient
/// <param name="UUID">UUID of player/entity to teleport to</param>
public bool SpectateByUUID(Guid UUID)
{
if(GetGamemode() == 3)
if (GetGamemode() == 3)
{
if(InvokeRequired)
if (InvokeRequired)
return InvokeOnMainThread(() => SpectateByUUID(UUID));
return handler.SendSpectate(UUID);
}
@ -1855,7 +1855,7 @@ namespace MinecraftClient
/// Check if the client is currently processing a Movement.
/// </summary>
/// <returns>true if a movement is currently handled</returns>
public bool ClientIsMoving()
public bool ClientIsMoving()
{
return terrainAndMovementsEnabled && locationReceived && ((steps != null && steps.Count > 0) || (path != null && path.Count > 0));
}
@ -2030,11 +2030,12 @@ namespace MinecraftClient
/// </summary>
/// <param name="inventoryID">Inventory ID</param>
/// <param name="itemList">Item list, key = slot ID, value = Item information</param>
public void OnWindowItems(byte inventoryID, Dictionary<int, Inventory.Item> itemList)
public void OnWindowItems(byte inventoryID, Dictionary<int, Inventory.Item> itemList, int stateId)
{
if (inventories.ContainsKey(inventoryID))
{
inventories[inventoryID].Items = itemList;
inventories[inventoryID].StateID = stateId;
DispatchBotEvent(bot => bot.OnInventoryUpdate(inventoryID));
}
}