mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
parent
e9d91ce572
commit
8e32c3747c
2 changed files with 14 additions and 14 deletions
|
|
@ -868,10 +868,5 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
return Handler.ChangeSlot(slot);
|
return Handler.ChangeSlot(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte GetCurrentSlot()
|
|
||||||
{
|
|
||||||
return Handler.GetCurrentSlot();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace MinecraftClient.ChatBots
|
||||||
class AutoEat : ChatBot
|
class AutoEat : ChatBot
|
||||||
{
|
{
|
||||||
byte LastSlot = 0;
|
byte LastSlot = 0;
|
||||||
|
byte CurrentSlot;
|
||||||
public static bool Eating = false;
|
public static bool Eating = false;
|
||||||
private int HungerThreshold = 6;
|
private int HungerThreshold = 6;
|
||||||
|
|
||||||
|
|
@ -19,11 +20,15 @@ namespace MinecraftClient.ChatBots
|
||||||
|
|
||||||
public override void OnHealthUpdate(float health, int food)
|
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();
|
Eating = true;
|
||||||
if (!Eating)
|
FindFoodAndEat();
|
||||||
ChangeSlot(LastSlot);
|
}
|
||||||
|
// keep eating until full
|
||||||
|
if (food < 20 && Eating)
|
||||||
|
{
|
||||||
|
FindFoodAndEat();
|
||||||
}
|
}
|
||||||
if (food >= 20 && Eating)
|
if (food >= 20 && Eating)
|
||||||
{
|
{
|
||||||
|
|
@ -32,6 +37,10 @@ namespace MinecraftClient.ChatBots
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnHeldItemChange(byte slot)
|
||||||
|
{
|
||||||
|
CurrentSlot = slot;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to find food in the hotbar and eat it
|
/// Try to find food in the hotbar and eat it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -40,11 +49,7 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
Container inventory = GetPlayerInventory();
|
Container inventory = GetPlayerInventory();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
byte CurrentSlot = GetCurrentSlot();
|
LastSlot = CurrentSlot;
|
||||||
if (!Eating)
|
|
||||||
{
|
|
||||||
LastSlot = CurrentSlot;
|
|
||||||
}
|
|
||||||
if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type.IsFood())
|
if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type.IsFood())
|
||||||
{
|
{
|
||||||
// no need to change slot
|
// no need to change slot
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue