Add inventory related ChatBot event

Added OnInventoryOpen and OnInventoryClose
Updated some method summary
This commit is contained in:
ReinforceZwei 2020-07-07 13:21:55 +08:00 committed by ORelio
parent 500e7f1bec
commit f2816c3fee
2 changed files with 31 additions and 10 deletions

View file

@ -222,7 +222,7 @@ namespace MinecraftClient
public virtual void OnLatencyUpdate(string playername, Guid uuid, int latency) { }
/// <summary>
/// Called map data
/// Called when a map was updated
/// </summary>
/// <param name="mapid"></param>
/// <param name="scale"></param>
@ -232,7 +232,7 @@ namespace MinecraftClient
public virtual void OnMapData(int mapid, byte scale, bool trackingposition, bool locked, int iconcount) { }
/// <summary>
/// Received some Title from the server
/// Called when received a title from the server
/// <param name="action"> 0 = set title, 1 = set subtitle, 3 = set action bar, 4 = set times and display, 4 = hide, 5 = reset</param>
/// <param name="titletext"> title text</param>
/// <param name="subtitletext"> suntitle text</param>
@ -244,7 +244,7 @@ namespace MinecraftClient
public virtual void OnTitle(int action, string titletext, string subtitletext, string actionbartext, int fadein, int stay, int fadeout, string json) { }
/// <summary>
/// Called on Entity Equipment
/// Called when an entity equipped
/// </summary>
/// <param name="entity"> Entity</param>
/// <param name="slot"> Equipment slot. 0: main hand, 1: off hand, 25: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)</param>
@ -252,7 +252,7 @@ namespace MinecraftClient
public virtual void OnEntityEquipment(Entity entity, int slot, Item item) { }
/// <summary>
/// Called when the Entity use effects
/// Called when an entity has effect applied
/// </summary>
/// <param name="entityid">entity ID</param>
/// <param name="effect">effect id</param>
@ -260,9 +260,9 @@ namespace MinecraftClient
/// <param name="duration">effect duration</param>
/// <param name="flags">effect flags</param>
public virtual void OnEntityEffect(Entity entity, Effects effect, int amplifier, int duration, byte flags) { }
/// <summary>
/// Called when coreboardObjective
/// Called when a scoreboard objective updated
/// </summary>
/// <param name="objectivename">objective name</param>
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
@ -271,16 +271,32 @@ namespace MinecraftClient
public virtual void OnScoreboardObjective(string objectivename, byte mode, string objectivevalue, int type, string json) { }
/// <summary>
/// Called when DisplayScoreboard
/// Called when a scoreboard updated
/// </summary>
/// <param name="entityname">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
/// <param name="objectivename">The name of the objective the score belongs to</param>
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
public virtual void OnUpdateScore(string entityname, byte action, string objectivename, int value) { }
/// <summary>
/// Called when an inventory/container was updated by server
/// </summary>
/// <param name="inventoryId"></param>
public virtual void OnInventoryUpdate(int inventoryId) { }
/// <summary>
/// Called when a container was opened
/// </summary>
/// <param name="inventoryId"></param>
public virtual void OnInventoryOpen(int inventoryId) { }
/// <summary>
/// Called when a container was closed
/// </summary>
/// <param name="inventoryId"></param>
public virtual void OnInventoryClose(int inventoryId) { }
/* =================================================================== */
/* ToolBox - Methods below might be useful while creating your bot. */
/* You should not need to interact with other classes of the program. */

View file

@ -1511,7 +1511,8 @@ namespace MinecraftClient
/// <summary>
/// When an inventory is opened
/// </summary>
/// <param name="inventory">Location to reach</param>
/// <param name="inventory">The inventory</param>
/// <param name="inventoryID">Inventory ID</param>
public void OnInventoryOpen(int inventoryID, Container inventory)
{
inventories[inventoryID] = inventory;
@ -1520,20 +1521,24 @@ namespace MinecraftClient
{
ConsoleIO.WriteLogLine("Inventory # " + inventoryID + " opened: " + inventory.Title);
ConsoleIO.WriteLogLine("Use /inventory to interact with it.");
DispatchBotEvent(bot => bot.OnInventoryOpen(inventoryID));
}
}
/// <summary>
/// When an inventory is close
/// </summary>
/// <param name="inventoryID">Location to reach</param>
/// <param name="inventoryID">Inventory ID</param>
public void OnInventoryClose(int inventoryID)
{
if (inventories.ContainsKey(inventoryID))
inventories.Remove(inventoryID);
if (inventoryID != 0)
{
ConsoleIO.WriteLogLine("Inventory # " + inventoryID + " closed.");
DispatchBotEvent(bot => bot.OnInventoryClose(inventoryID));
}
}
/// <summary>