diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index dc2d7432..759e3e55 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -21,6 +21,7 @@ namespace MinecraftClient.ChatBots private DateTime CaughtTime = DateTime.Now; private bool inventoryEnabled; private bool isFishing = false; + private int useItemCounter = 0; public override void Initialize() { @@ -33,6 +34,18 @@ namespace MinecraftClient.ChatBots inventoryEnabled = GetInventoryEnabled(); } + public override void Update() + { + if (useItemCounter > 0) + { + useItemCounter--; + if (useItemCounter <= 0) + { + UseItemInHand(); + } + } + } + public override void OnEntitySpawn(Entity entity) { if (entity.TypeID == 102) @@ -54,6 +67,10 @@ namespace MinecraftClient.ChatBots if(entity.ID == fishingRod.ID) { isFishing = false; + if (Settings.AutoFishing_Antidespawn) + { + useItemCounter = 5; // 500ms + } } } } @@ -104,14 +121,8 @@ namespace MinecraftClient.ChatBots return; } } - // non-blocking delay - Task.Factory.StartNew(delegate - { - // retract fishing rod need some time - Thread.Sleep(800); - // throw again - UseItemInHand(); - }); + // thread-safe + useItemCounter = 8; // 800ms } /// diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 2afcafd9..53f8bdc1 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -157,6 +157,7 @@ namespace MinecraftClient //Auto Fishing public static bool AutoFishing_Enabled = false; + public static bool AutoFishing_Antidespawn = false; //Auto Eating public static bool AutoEat_Enabled = false; @@ -477,6 +478,7 @@ namespace MinecraftClient switch (argName.ToLower()) { case "enabled": AutoFishing_Enabled = str2bool(argValue); break; + case "antidespawn": AutoFishing_Antidespawn = str2bool(argValue); break; } break; @@ -689,6 +691,7 @@ namespace MinecraftClient + "[AutoFishing]\r\n" + "# Entity Handling NEED to be enabled first\r\n" + "enabled=false\r\n" + + "antidespawn=false\r\n" + "\r\n" + "[AutoEat]\r\n" + "# Inventory Handling NEED to be enabled first\r\n"