diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index fbb35bf2..48ce77c0 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -868,10 +868,5 @@ namespace MinecraftClient { return Handler.ChangeSlot(slot); } - - protected byte GetCurrentSlot() - { - return Handler.GetCurrentSlot(); - } } } diff --git a/MinecraftClient/ChatBots/AutoEat.cs b/MinecraftClient/ChatBots/AutoEat.cs index 146f819c..8c7c58f5 100644 --- a/MinecraftClient/ChatBots/AutoEat.cs +++ b/MinecraftClient/ChatBots/AutoEat.cs @@ -9,6 +9,7 @@ namespace MinecraftClient.ChatBots class AutoEat : ChatBot { byte LastSlot = 0; + byte CurrentSlot; public static bool Eating = false; private int HungerThreshold = 6; @@ -19,11 +20,15 @@ namespace MinecraftClient.ChatBots public override void OnHealthUpdate(float health, int food) { - if ((food <= HungerThreshold) || (food < 20 && health < 20) || (food < 20 && Eating)) + if (food <= HungerThreshold || (food < 20 && health < 20)) { - Eating = FindFoodAndEat(); - if (!Eating) - ChangeSlot(LastSlot); + Eating = true; + FindFoodAndEat(); + } + // keep eating until full + if (food < 20 && Eating) + { + FindFoodAndEat(); } if (food >= 20 && Eating) { @@ -32,6 +37,10 @@ namespace MinecraftClient.ChatBots } } + public override void OnHeldItemChange(byte slot) + { + CurrentSlot = slot; + } /// /// Try to find food in the hotbar and eat it /// @@ -40,11 +49,7 @@ namespace MinecraftClient.ChatBots { Container inventory = GetPlayerInventory(); bool found = false; - byte CurrentSlot = GetCurrentSlot(); - if (!Eating) - { - LastSlot = CurrentSlot; - } + LastSlot = CurrentSlot; if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type.IsFood()) { // no need to change slot