mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add code documentation, move and rename a few methods
This commit is contained in:
parent
90c6e776e1
commit
195e162c7d
10 changed files with 286 additions and 96 deletions
|
|
@ -6,6 +6,9 @@ using System.Text;
|
|||
|
||||
namespace MinecraftClient.ChatBots
|
||||
{
|
||||
/// <summary>
|
||||
/// The AutoAttack bot will automatically attack any hostile mob close to the player
|
||||
/// </summary>
|
||||
class AutoAttack : ChatBot
|
||||
{
|
||||
private Dictionary<int, Entity> entitiesToAttack = new Dictionary<int, Entity>(); // mobs within attack range
|
||||
|
|
@ -48,7 +51,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public override void OnEntitySpawn(Entity entity)
|
||||
{
|
||||
if (entity.GetMobName() != "")
|
||||
if (entity.IsHostile())
|
||||
{
|
||||
entitiesToTrack.Add(entity.ID, entity);
|
||||
}
|
||||
|
|
@ -64,10 +67,9 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
if (entitiesToTrack.ContainsKey(entity.ID))
|
||||
{
|
||||
Double distance = Entity.CalculateDistance(GetCurrentLocation(), entity.Location);
|
||||
if(distance < attackRange)
|
||||
if (GetCurrentLocation().Distance(entity.Location) < attackRange)
|
||||
{
|
||||
if(!entitiesToAttack.ContainsKey(entity.ID))
|
||||
if (!entitiesToAttack.ContainsKey(entity.ID))
|
||||
entitiesToAttack.Add(entity.ID, entity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ using MinecraftClient.Mapping;
|
|||
|
||||
namespace MinecraftClient.ChatBots
|
||||
{
|
||||
/// <summary>
|
||||
/// The AutoFishing bot semi-automates fishing.
|
||||
/// The player needs to have a fishing rod in hand, then manually send it using the UseItem command.
|
||||
/// </summary>
|
||||
class AutoFishing : ChatBot
|
||||
{
|
||||
private Entity fishingRod;
|
||||
|
|
@ -32,7 +36,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
if (entity.TypeID == 102)
|
||||
{
|
||||
if (Entity.CalculateDistance(GetCurrentLocation(), entity.Location) < 2 && !isFishing)
|
||||
if (GetCurrentLocation().Distance(entity.Location) < 2 && !isFishing)
|
||||
{
|
||||
ConsoleIO.WriteLine("Threw a fishing rod");
|
||||
fishingRod = entity;
|
||||
|
|
@ -41,6 +45,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEntityDespawn(Entity entity)
|
||||
{
|
||||
if(entity.TypeID == 102)
|
||||
|
|
@ -51,6 +56,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEntityMove(Entity entity)
|
||||
{
|
||||
if (isFishing)
|
||||
|
|
@ -107,9 +113,14 @@ namespace MinecraftClient.ChatBots
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the player has a fishing rod in inventory
|
||||
/// </summary>
|
||||
/// <returns>TRUE if the player has a fishing rod</returns>
|
||||
public bool hasFishingRod()
|
||||
{
|
||||
if (!inventoryEnabled) return false;
|
||||
if (!inventoryEnabled)
|
||||
return false;
|
||||
int start = 36;
|
||||
int end = 44;
|
||||
Inventory.Container container = GetPlayerInventory();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue