Configurable to start fishing automatically or not

This commit is contained in:
BruceChen 2022-09-12 23:15:57 +08:00
parent 99ea0d8997
commit dac60200e0
3 changed files with 30 additions and 8 deletions

View file

@ -58,12 +58,22 @@ namespace MinecraftClient.ChatBots
private void StartFishing() private void StartFishing()
{ {
isFishing = false; isFishing = false;
double delay = Settings.AutoFishing_FishingDelay; if (Settings.AutoFishing_AutoStart)
LogToConsole(Translations.Get("bot.autoFish.start", delay));
lock (stateLock)
{ {
counter = (int)(delay * 10); double delay = Settings.AutoFishing_FishingDelay;
state = FishingState.StartMove; LogToConsole(Translations.Get("bot.autoFish.start", delay));
lock (stateLock)
{
counter = (int)(delay * 10);
state = FishingState.StartMove;
}
}
else
{
lock (stateLock)
{
state = FishingState.WaitJoinGame;
}
} }
} }
@ -129,8 +139,16 @@ namespace MinecraftClient.ChatBots
double[,]? locationList = Settings.AutoFishing_Location; double[,]? locationList = Settings.AutoFishing_Location;
if (locationList != null) if (locationList != null)
{ {
UpdateLocation(locationList); if (GetTerrainEnabled())
state = FishingState.WaitingMovement; {
UpdateLocation(locationList);
state = FishingState.WaitingMovement;
}
else
{
LogToConsole(Translations.Get("extra.terrainandmovement_required"));
state = FishingState.WaitJoinGame;
}
} }
else else
{ {
@ -274,6 +292,7 @@ namespace MinecraftClient.ChatBots
state = FishingState.StartMove; state = FishingState.StartMove;
} }
} }
private void UpdateLocation(double[,] locationList) private void UpdateLocation(double[,] locationList)
{ {
if (curLocationIdx >= locationList.GetLength(0)) if (curLocationIdx >= locationList.GetLength(0))
@ -336,7 +355,6 @@ namespace MinecraftClient.ChatBots
curLocationIdx += moveDir; curLocationIdx += moveDir;
} }
private bool DurabilityCheck() private bool DurabilityCheck()
{ {
if (!inventoryEnabled) if (!inventoryEnabled)

View file

@ -208,6 +208,7 @@ interaction=Attack # Possible values: Interact, Attack (default)
enabled=false enabled=false
antidespawn=false antidespawn=false
main_hand=true # Use the main hand or the second hand to hold the rod. main_hand=true # Use the main hand or the second hand to hold the rod.
auto_start=true # Whether to start fishing automatically after entering a world.
fishing_delay=3.0 # How long after entering the game to start fishing (seconds). fishing_delay=3.0 # How long after entering the game to start fishing (seconds).
fishing_timeout=300.0 # Fishing timeout (seconds). Timeout will trigger a re-cast. fishing_timeout=300.0 # Fishing timeout (seconds). Timeout will trigger a re-cast.
fishing_hook_threshold=0.2 # Fish hooks moving on the Y-axis above this threshold will be considered to have caught a fish. fishing_hook_threshold=0.2 # Fish hooks moving on the Y-axis above this threshold will be considered to have caught a fish.

View file

@ -204,6 +204,7 @@ namespace MinecraftClient
public static bool AutoFishing_Enabled = false; public static bool AutoFishing_Enabled = false;
public static bool AutoFishing_Antidespawn = false; public static bool AutoFishing_Antidespawn = false;
public static bool AutoFishing_Mainhand = true; public static bool AutoFishing_Mainhand = true;
public static bool AutoFishing_AutoStart = true;
public static double AutoFishing_FishingDelay = 3.0; public static double AutoFishing_FishingDelay = 3.0;
public static double AutoFishing_FishingTimeout = 600.0; public static double AutoFishing_FishingTimeout = 600.0;
public static double AutoFishing_FishingHookThreshold = 0.2; public static double AutoFishing_FishingHookThreshold = 0.2;
@ -719,6 +720,8 @@ namespace MinecraftClient
{ {
case "enabled": AutoFishing_Enabled = str2bool(argValue); return true; case "enabled": AutoFishing_Enabled = str2bool(argValue); return true;
case "antidespawn": AutoFishing_Antidespawn = str2bool(argValue); return true; case "antidespawn": AutoFishing_Antidespawn = str2bool(argValue); return true;
case "main_hand": AutoFishing_Mainhand = str2bool(argValue); return true;
case "auto_start": AutoFishing_AutoStart = str2bool(argValue); return true;
case "fishing_delay": AutoFishing_FishingDelay = str2double(argValue); return true; case "fishing_delay": AutoFishing_FishingDelay = str2double(argValue); return true;
case "fishing_timeout": AutoFishing_FishingTimeout = str2double(argValue); return true; case "fishing_timeout": AutoFishing_FishingTimeout = str2double(argValue); return true;
case "fishing_hook_threshold": AutoFishing_FishingHookThreshold = str2double(argValue); return true; case "fishing_hook_threshold": AutoFishing_FishingHookThreshold = str2double(argValue); return true;