mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add sneak switch for AntiAFK
This commit is contained in:
parent
2e18317f3f
commit
77d858dc35
5 changed files with 19 additions and 9 deletions
|
|
@ -26,6 +26,9 @@ namespace MinecraftClient.ChatBots
|
||||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Command$")]
|
[TomlInlineComment("$config.ChatBot.AntiAfk.Command$")]
|
||||||
public string Command = "/ping";
|
public string Command = "/ping";
|
||||||
|
|
||||||
|
[TomlInlineComment("$config.ChatBot.AntiAfk.Use_Sneak$")]
|
||||||
|
public bool Use_Sneak = false;
|
||||||
|
|
||||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Use_Terrain_Handling$")]
|
[TomlInlineComment("$config.ChatBot.AntiAfk.Use_Terrain_Handling$")]
|
||||||
public bool Use_Terrain_Handling = false;
|
public bool Use_Terrain_Handling = false;
|
||||||
|
|
||||||
|
|
@ -81,7 +84,7 @@ namespace MinecraftClient.ChatBots
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int count;
|
private int count, nextrun = 50;
|
||||||
private bool previousSneakState = false;
|
private bool previousSneakState = false;
|
||||||
private readonly Random random = new();
|
private readonly Random random = new();
|
||||||
|
|
||||||
|
|
@ -108,10 +111,11 @@ namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count == random.Next(Config._DelayMin, Config._DelayMax))
|
if (count >= nextrun)
|
||||||
{
|
{
|
||||||
DoAntiAfkStuff();
|
DoAntiAfkStuff();
|
||||||
count = 0;
|
count = 0;
|
||||||
|
nextrun = random.Next(Config._DelayMin, Config._DelayMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -149,22 +153,27 @@ namespace MinecraftClient.ChatBots
|
||||||
useAlternativeMethod = true;
|
useAlternativeMethod = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else moved = MoveToLocation(goal, allowUnsafe: false, allowDirectTeleport: false);
|
else
|
||||||
|
{
|
||||||
|
moved = MoveToLocation(goal, allowUnsafe: false, allowDirectTeleport: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useAlternativeMethod)
|
if (!useAlternativeMethod && Config.Use_Sneak)
|
||||||
{
|
{
|
||||||
// Solve the case when the bot was closed in 1x2, was sneaking, but then he was freed, this will make him not sneak anymore
|
// Solve the case when the bot was closed in 1x2, was sneaking, but then he was freed, this will make him not sneak anymore
|
||||||
previousSneakState = false;
|
previousSneakState = false;
|
||||||
Sneak(false);
|
Sneak(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendText(Config.Command);
|
SendText(Config.Command);
|
||||||
|
if (Config.Use_Sneak)
|
||||||
|
{
|
||||||
Sneak(previousSneakState);
|
Sneak(previousSneakState);
|
||||||
previousSneakState = !previousSneakState;
|
previousSneakState = !previousSneakState;
|
||||||
|
}
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=The name of a file where alers logs will be writt
|
||||||
config.ChatBot.AntiAfk=Send a command on a regular or random basis or make the bot walk around randomly to avoid automatic AFK disconnection\n# /!\ Make sure your server rules do not forbid anti-AFK mechanisms!\n# /!\ Make sure you keep the bot in an enclosure to prevent it wandering off if you're using terrain handling! (Recommended size 5x5x5)
|
config.ChatBot.AntiAfk=Send a command on a regular or random basis or make the bot walk around randomly to avoid automatic AFK disconnection\n# /!\ Make sure your server rules do not forbid anti-AFK mechanisms!\n# /!\ Make sure you keep the bot in an enclosure to prevent it wandering off if you're using terrain handling! (Recommended size 5x5x5)
|
||||||
config.ChatBot.AntiAfk.Delay=The time interval for execution. (in seconds)
|
config.ChatBot.AntiAfk.Delay=The time interval for execution. (in seconds)
|
||||||
config.ChatBot.AntiAfk.Command=Command to send to the server.
|
config.ChatBot.AntiAfk.Command=Command to send to the server.
|
||||||
|
config.ChatBot.AntiAfk.Use_Sneak=Whether to sneak when sending the command.
|
||||||
config.ChatBot.AntiAfk.Use_Terrain_Handling=Use terrain handling to enable the bot to move around.
|
config.ChatBot.AntiAfk.Use_Terrain_Handling=Use terrain handling to enable the bot to move around.
|
||||||
config.ChatBot.AntiAfk.Walk_Range=The range the bot can move around randomly (Note: the bigger the range, the slower the bot will be)
|
config.ChatBot.AntiAfk.Walk_Range=The range the bot can move around randomly (Note: the bigger the range, the slower the bot will be)
|
||||||
config.ChatBot.AntiAfk.Walk_Retries=How many times can the bot fail trying to move before using the command method.
|
config.ChatBot.AntiAfk.Walk_Retries=How many times can the bot fail trying to move before using the command method.
|
||||||
|
|
|
||||||
|
|
@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=日志文件的路径。
|
||||||
config.ChatBot.AntiAfk=定期发送命令,或让机器人随机走动,以避免检测到挂机后被踢出服务器\n # /!\启用前请确保你的服务器规则不禁止反AFK机制!\n# /!\如果启用随机移动,请将机器人围在围栏里,以防走失!(建议尺寸5x5x5)
|
config.ChatBot.AntiAfk=定期发送命令,或让机器人随机走动,以避免检测到挂机后被踢出服务器\n # /!\启用前请确保你的服务器规则不禁止反AFK机制!\n# /!\如果启用随机移动,请将机器人围在围栏里,以防走失!(建议尺寸5x5x5)
|
||||||
config.ChatBot.AntiAfk.Delay=执行操作的间隔时间。(秒)
|
config.ChatBot.AntiAfk.Delay=执行操作的间隔时间。(秒)
|
||||||
config.ChatBot.AntiAfk.Command=发送给服务器的指令。
|
config.ChatBot.AntiAfk.Command=发送给服务器的指令。
|
||||||
|
config.ChatBot.AntiAfk.Use_Sneak=在发送命令时是否蹲下。
|
||||||
config.ChatBot.AntiAfk.Use_Terrain_Handling=启用地形处理,以使机器人能够四处移动。
|
config.ChatBot.AntiAfk.Use_Terrain_Handling=启用地形处理,以使机器人能够四处移动。
|
||||||
config.ChatBot.AntiAfk.Walk_Range=机器人可以随机移动的范围(注意:范围越大,速度越慢)
|
config.ChatBot.AntiAfk.Walk_Range=机器人可以随机移动的范围(注意:范围越大,速度越慢)
|
||||||
config.ChatBot.AntiAfk.Walk_Retries=尝试移动失败几次后在改为发送命令模式。
|
config.ChatBot.AntiAfk.Walk_Retries=尝试移动失败几次后在改为发送命令模式。
|
||||||
|
|
|
||||||
|
|
@ -756,6 +756,7 @@ config.ChatBot.Alerts.Log_File=日誌檔案的路徑。
|
||||||
config.ChatBot.AntiAfk=定期傳送命令,或讓機器人隨機走動,以避免檢測到掛機後被踢出伺服器\n # /!\啟用前請確保你的伺服器規則不禁止反AFK機制!\n# /!\如果啟用隨機移動,請將機器人圍在圍欄裡,以防走失!(建議尺寸5x5x5)
|
config.ChatBot.AntiAfk=定期傳送命令,或讓機器人隨機走動,以避免檢測到掛機後被踢出伺服器\n # /!\啟用前請確保你的伺服器規則不禁止反AFK機制!\n# /!\如果啟用隨機移動,請將機器人圍在圍欄裡,以防走失!(建議尺寸5x5x5)
|
||||||
config.ChatBot.AntiAfk.Delay=執行操作的間隔時間。(秒)
|
config.ChatBot.AntiAfk.Delay=執行操作的間隔時間。(秒)
|
||||||
config.ChatBot.AntiAfk.Command=傳送給伺服器的指令。
|
config.ChatBot.AntiAfk.Command=傳送給伺服器的指令。
|
||||||
|
config.ChatBot.AntiAfk.Use_Sneak=在傳送指令時是否蹲下。
|
||||||
config.ChatBot.AntiAfk.Use_Terrain_Handling=啟用地形處理,以使機器人能夠四處移動。
|
config.ChatBot.AntiAfk.Use_Terrain_Handling=啟用地形處理,以使機器人能夠四處移動。
|
||||||
config.ChatBot.AntiAfk.Walk_Range=機器人可以隨機移動的範圍(注意:範圍越大,速度越慢)
|
config.ChatBot.AntiAfk.Walk_Range=機器人可以隨機移動的範圍(注意:範圍越大,速度越慢)
|
||||||
config.ChatBot.AntiAfk.Walk_Retries=嘗試移動失敗幾次後在改為傳送命令模式。
|
config.ChatBot.AntiAfk.Walk_Retries=嘗試移動失敗幾次後在改為傳送命令模式。
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,6 @@ namespace MinecraftClient.WinAPI
|
||||||
{
|
{
|
||||||
if (ex is HttpRequestException) //Skin not found? Reset to default icon
|
if (ex is HttpRequestException) //Skin not found? Reset to default icon
|
||||||
RevertToMCCIcon();
|
RevertToMCCIcon();
|
||||||
else
|
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (HttpRequestException) //Skin not found? Reset to default icon
|
catch (HttpRequestException) //Skin not found? Reset to default icon
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue