mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add Mode switching command for AutoDrop (#1293)
* Add new command for AutoDrop * Minor imporvement for AutoDrop * Fix inventory update event passed a non-exist inventory ID * Minor improvement for AutoDrop
This commit is contained in:
parent
9169036893
commit
ec9f999857
3 changed files with 43 additions and 3 deletions
|
|
@ -27,7 +27,7 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
if (!Enum.TryParse(mode, true, out dropMode))
|
if (!Enum.TryParse(mode, true, out dropMode))
|
||||||
{
|
{
|
||||||
LogToConsole("Cannot read drop mode from config. Using include mode.");
|
LogToConsoleTranslated("bot.autoDrop.no_mode");
|
||||||
}
|
}
|
||||||
if (dropMode != Mode.Everything)
|
if (dropMode != Mode.Everything)
|
||||||
this.itemList = ItemListParser(itemList).ToList();
|
this.itemList = ItemListParser(itemList).ToList();
|
||||||
|
|
@ -120,6 +120,31 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
return Translations.Get("bot.autoDrop.no_item");
|
return Translations.Get("bot.autoDrop.no_item");
|
||||||
}
|
}
|
||||||
|
case "mode":
|
||||||
|
if (args.Length >= 2)
|
||||||
|
{
|
||||||
|
switch (args[1].ToLower())
|
||||||
|
{
|
||||||
|
case "include":
|
||||||
|
dropMode = Mode.Include;
|
||||||
|
break;
|
||||||
|
case "exclude":
|
||||||
|
dropMode = Mode.Exclude;
|
||||||
|
break;
|
||||||
|
case "everything":
|
||||||
|
dropMode = Mode.Everything;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Translations.Get("bot.autoDrop.unknown_mode"); // Unknwon mode. Available modes: Include, Exclude, Everything
|
||||||
|
}
|
||||||
|
inventoryUpdated = 0;
|
||||||
|
OnUpdateFinish();
|
||||||
|
return Translations.Get("bot.autoDrop.switched", dropMode.ToString()); // Switched to {0} mode.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Translations.Get("bot.autoDrop.unknown_mode");
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return GetHelp();
|
return GetHelp();
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +157,7 @@ namespace MinecraftClient.ChatBots
|
||||||
|
|
||||||
private string GetHelp()
|
private string GetHelp()
|
||||||
{
|
{
|
||||||
return Translations.Get("general.available_cmd", "on, off, add, remove, list");
|
return Translations.Get("general.available_cmd", "on, off, add, remove, list, mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|
@ -165,6 +190,8 @@ namespace MinecraftClient.ChatBots
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
updateDebounce = updateDebounceValue;
|
updateDebounce = updateDebounceValue;
|
||||||
|
// Always interact container if available (larger ID) because they included player inventory (ID 0)
|
||||||
|
if (inventoryId >= inventoryUpdated)
|
||||||
inventoryUpdated = inventoryId;
|
inventoryUpdated = inventoryId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -179,6 +206,9 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
|
// Ingore crafting result slot
|
||||||
|
if (item.Key == 0)
|
||||||
|
continue;
|
||||||
if (itemList.Contains(item.Value.Type))
|
if (itemList.Contains(item.Value.Type))
|
||||||
{
|
{
|
||||||
// Drop it !!
|
// Drop it !!
|
||||||
|
|
@ -190,6 +220,9 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
|
// Ingore crafting result slot
|
||||||
|
if (item.Key == 0)
|
||||||
|
continue;
|
||||||
if (!itemList.Contains(item.Value.Type))
|
if (!itemList.Contains(item.Value.Type))
|
||||||
{
|
{
|
||||||
// Drop it !!
|
// Drop it !!
|
||||||
|
|
@ -201,6 +234,9 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
|
// Ingore crafting result slot
|
||||||
|
if (item.Key == 0)
|
||||||
|
continue;
|
||||||
// Drop it !!
|
// Drop it !!
|
||||||
WindowAction(inventoryUpdated, item.Key, WindowActionType.DropItemStack);
|
WindowAction(inventoryUpdated, item.Key, WindowActionType.DropItemStack);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1770,6 +1770,7 @@ namespace MinecraftClient
|
||||||
// Handle cursor item
|
// Handle cursor item
|
||||||
if (inventoryID == 255 && slotID == -1)
|
if (inventoryID == 255 && slotID == -1)
|
||||||
{
|
{
|
||||||
|
inventoryID = 0; // Prevent key not found for some bots relied to this event
|
||||||
if (inventories.ContainsKey(0))
|
if (inventories.ContainsKey(0))
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
|
|
|
||||||
|
|
@ -385,6 +385,9 @@ bot.autoDrop.removed=Removed item {0}
|
||||||
bot.autoDrop.not_in_list=Item not in the list
|
bot.autoDrop.not_in_list=Item not in the list
|
||||||
bot.autoDrop.no_item=No item in the list
|
bot.autoDrop.no_item=No item in the list
|
||||||
bot.autoDrop.list=Total {0} in the list:\n {1}
|
bot.autoDrop.list=Total {0} in the list:\n {1}
|
||||||
|
bot.autoDrop.switched=Switched to {0} mode.
|
||||||
|
bot.autoDrop.unknown_mode=Unknwon mode. Available modes: Include, Exclude, Everything
|
||||||
|
bot.autoDrop.no_mode=Cannot read drop mode from config. Using include mode.
|
||||||
|
|
||||||
# AutoFish
|
# AutoFish
|
||||||
bot.autoFish.throw=Threw a fishing rod
|
bot.autoFish.throw=Threw a fishing rod
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue