This commit is contained in:
Reinforce Zwei 2020-05-22 08:58:30 +08:00 committed by ORelio
parent a018304f99
commit 06ed5c0a45
2 changed files with 22 additions and 8 deletions

View file

@ -21,6 +21,7 @@ namespace MinecraftClient.ChatBots
private DateTime CaughtTime = DateTime.Now; private DateTime CaughtTime = DateTime.Now;
private bool inventoryEnabled; private bool inventoryEnabled;
private bool isFishing = false; private bool isFishing = false;
private int useItemCounter = 0;
public override void Initialize() public override void Initialize()
{ {
@ -33,6 +34,18 @@ namespace MinecraftClient.ChatBots
inventoryEnabled = GetInventoryEnabled(); inventoryEnabled = GetInventoryEnabled();
} }
public override void Update()
{
if (useItemCounter > 0)
{
useItemCounter--;
if (useItemCounter <= 0)
{
UseItemInHand();
}
}
}
public override void OnEntitySpawn(Entity entity) public override void OnEntitySpawn(Entity entity)
{ {
if (entity.TypeID == 102) if (entity.TypeID == 102)
@ -54,6 +67,10 @@ namespace MinecraftClient.ChatBots
if(entity.ID == fishingRod.ID) if(entity.ID == fishingRod.ID)
{ {
isFishing = false; isFishing = false;
if (Settings.AutoFishing_Antidespawn)
{
useItemCounter = 5; // 500ms
}
} }
} }
} }
@ -104,14 +121,8 @@ namespace MinecraftClient.ChatBots
return; return;
} }
} }
// non-blocking delay // thread-safe
Task.Factory.StartNew(delegate useItemCounter = 8; // 800ms
{
// retract fishing rod need some time
Thread.Sleep(800);
// throw again
UseItemInHand();
});
} }
/// <summary> /// <summary>

View file

@ -157,6 +157,7 @@ namespace MinecraftClient
//Auto Fishing //Auto Fishing
public static bool AutoFishing_Enabled = false; public static bool AutoFishing_Enabled = false;
public static bool AutoFishing_Antidespawn = false;
//Auto Eating //Auto Eating
public static bool AutoEat_Enabled = false; public static bool AutoEat_Enabled = false;
@ -477,6 +478,7 @@ namespace MinecraftClient
switch (argName.ToLower()) switch (argName.ToLower())
{ {
case "enabled": AutoFishing_Enabled = str2bool(argValue); break; case "enabled": AutoFishing_Enabled = str2bool(argValue); break;
case "antidespawn": AutoFishing_Antidespawn = str2bool(argValue); break;
} }
break; break;
@ -689,6 +691,7 @@ namespace MinecraftClient
+ "[AutoFishing]\r\n" + "[AutoFishing]\r\n"
+ "# Entity Handling NEED to be enabled first\r\n" + "# Entity Handling NEED to be enabled first\r\n"
+ "enabled=false\r\n" + "enabled=false\r\n"
+ "antidespawn=false\r\n"
+ "\r\n" + "\r\n"
+ "[AutoEat]\r\n" + "[AutoEat]\r\n"
+ "# Inventory Handling NEED to be enabled first\r\n" + "# Inventory Handling NEED to be enabled first\r\n"