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

View file

@ -208,6 +208,7 @@ interaction=Attack # Possible values: Interact, Attack (default)
enabled=false
antidespawn=false
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_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.

View file

@ -204,6 +204,7 @@ namespace MinecraftClient
public static bool AutoFishing_Enabled = false;
public static bool AutoFishing_Antidespawn = false;
public static bool AutoFishing_Mainhand = true;
public static bool AutoFishing_AutoStart = true;
public static double AutoFishing_FishingDelay = 3.0;
public static double AutoFishing_FishingTimeout = 600.0;
public static double AutoFishing_FishingHookThreshold = 0.2;
@ -719,6 +720,8 @@ namespace MinecraftClient
{
case "enabled": AutoFishing_Enabled = 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_timeout": AutoFishing_FishingTimeout = str2double(argValue); return true;
case "fishing_hook_threshold": AutoFishing_FishingHookThreshold = str2double(argValue); return true;