From 3ff2a18b60f4b578cde9f61f0892aaba3389c409 Mon Sep 17 00:00:00 2001
From: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com>
Date: Wed, 22 Jul 2020 19:01:43 +0800
Subject: [PATCH] Add more method comment
---
MinecraftClient/ChatBots/AutoCarft.cs | 41 ++++++++++++++++++++-------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/MinecraftClient/ChatBots/AutoCarft.cs b/MinecraftClient/ChatBots/AutoCarft.cs
index ca795efe..71cc9c7a 100644
--- a/MinecraftClient/ChatBots/AutoCarft.cs
+++ b/MinecraftClient/ChatBots/AutoCarft.cs
@@ -498,23 +498,21 @@ namespace MinecraftClient.ChatBots
SendPlaceBlock(location, Direction.Up);
}
+ ///
+ /// Prepare the crafting action steps by the given recipe name and start crafting
+ ///
+ /// Name of the recipe to craft
private void PrepareCrafting(string name)
{
PrepareCrafting(recipes[name]);
}
+
+ ///
+ /// Prepare the crafting action steps by the given recipe and start crafting
+ ///
+ /// Recipe to craft
private void PrepareCrafting(Recipe recipe)
{
- /* Define crafting recipe */
- // TODO: make a dedicated config file for user to set their own recipe
- //Dictionary materials = new Dictionary
- //{
- // { 1, ItemType.OakPlanks }, { 2, ItemType.OakPlanks }, { 3, ItemType.OakPlanks },
- // { 4, ItemType.Cobblestone }, { 5, ItemType.IronIngot }, { 6, ItemType.Cobblestone },
- // { 7, ItemType.Cobblestone }, { 8, ItemType.Redstone }, { 9, ItemType.Cobblestone }
- //};
- //Recipe recipe = new Recipe(materials, ItemType.StoneButton, ContainerType.Crafting);
- //inventoryInUse = 1;
-
recipeInUse = recipe;
if (recipeInUse.CraftingAreaType == ContainerType.PlayerInventory)
inventoryInUse = 0;
@@ -557,6 +555,9 @@ namespace MinecraftClient.ChatBots
else ConsoleIO.WriteLogLine("AutoCraft cannot be started. Check your available materials");
}
+ ///
+ /// Stop the crafting process by clearing crafting action steps and close the inventory
+ ///
private void StopCrafting()
{
actionSteps.Clear();
@@ -571,6 +572,9 @@ namespace MinecraftClient.ChatBots
}
}
+ ///
+ /// Handle next crafting action step
+ ///
private void HandleNextStep()
{
while (actionSteps.Count > 0)
@@ -637,6 +641,9 @@ namespace MinecraftClient.ChatBots
}
+ ///
+ /// Handle any crafting error after a step was processed
+ ///
private void HandleError()
{
if (craftingFailed)
@@ -654,6 +661,11 @@ namespace MinecraftClient.ChatBots
index--;
ConsoleIO.WriteLogLine("Crafting failed! Waiting for more materials");
}
+ if (actionSteps[index - 1].ActionType == ActionType.LeftClick && actionSteps[index - 1].ItemType != ItemType.Air)
+ {
+ // Inform user the missing meterial name
+ ConsoleIO.WriteLogLine("Missing material: " + actionSteps[index - 1].ItemType.ToString());
+ }
}
}
@@ -662,12 +674,19 @@ namespace MinecraftClient.ChatBots
ConsoleIO.WriteLogLine("Action timeout! Reason: " + timeoutAction);
}
+ ///
+ /// Set the timeout. Used to detect the failure of open crafting table
+ ///
+ /// The reason to display if timeout
private void SetTimeout(string reason = "unspecified")
{
updateTimeout = updateTimeoutValue;
timeoutAction = reason;
}
+ ///
+ /// Clear the timeout
+ ///
private void ClearTimeout()
{
updateTimeout = 0;