From ccb861002095419e12e891fe00ea97c44b9cddc7 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 12 Sep 2022 02:19:20 +0800 Subject: [PATCH] Support use left hand --- MinecraftClient/ChatBots/AutoFishing.cs | 5 ++++- MinecraftClient/McClient.cs | 9 +++++++++ MinecraftClient/Resources/config/MinecraftClient.ini | 1 + MinecraftClient/Scripting/ChatBot.cs | 9 +++++++++ MinecraftClient/Settings.cs | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 507a736d..d92d07ab 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -188,7 +188,10 @@ namespace MinecraftClient.ChatBots private void UseFishRod() { - UseItemInHand(); + if (Settings.AutoFishing_Mainhand) + UseItemInHand(); + else + UseItemInLeftHand(); } /// diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 3ef7fbf1..8ba106fa 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1277,6 +1277,15 @@ namespace MinecraftClient return InvokeOnMainThread(() => handler.SendUseItem(0, this.sequenceId)); } + /// + /// Use the item currently in the player's left hand + /// + /// TRUE if the item was successfully used + public bool UseItemOnLeftHand() + { + return InvokeOnMainThread(() => handler.SendUseItem(1, this.sequenceId)); + } + /// /// Try to merge a slot /// diff --git a/MinecraftClient/Resources/config/MinecraftClient.ini b/MinecraftClient/Resources/config/MinecraftClient.ini index bc43d351..2a9d7436 100644 --- a/MinecraftClient/Resources/config/MinecraftClient.ini +++ b/MinecraftClient/Resources/config/MinecraftClient.ini @@ -207,6 +207,7 @@ interaction=Attack # Possible values: Interact, Attack (default) # /!\ Make sure server rules allow automated farming before using this bot enabled=false antidespawn=false +main_hand=true # Use the main hand or the second hand to hold the rod fishing_delay=3.0 # How long after entering the game to start fishing (seconds). fishing_timeout=600.0 # Fishing timeout (seconds). Timeout will re-cast the rod fishing_hook_threshold=0.2 # Fish hooks moving on the Y-axis above this threshold will be considered to have caught a fish. diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs index 2fccd721..3e5515e9 100644 --- a/MinecraftClient/Scripting/ChatBot.cs +++ b/MinecraftClient/Scripting/ChatBot.cs @@ -1262,6 +1262,15 @@ namespace MinecraftClient return Handler.UseItemOnHand(); } + /// + /// Use item currently in the player's hand (active inventory bar slot) + /// + /// TRUE if successful + protected bool UseItemInLeftHand() + { + return Handler.UseItemOnLeftHand(); + } + /// /// Check inventory handling enable status /// diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 7f8c71b2..380f7154 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -203,6 +203,7 @@ namespace MinecraftClient //Auto Fishing public static bool AutoFishing_Enabled = false; public static bool AutoFishing_Antidespawn = false; + public static bool AutoFishing_Mainhand = true; public static double AutoFishing_FishingDelay = 3.0; public static double AutoFishing_FishingTimeout = 600.0; public static double AutoFishing_FishingHookThreshold = 0.2;