mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Update AutoAttack (#1204)
Move animation packet out of the loop to reduce the packet sent per second
This commit is contained in:
parent
c3ace103c6
commit
dbffe98cd0
1 changed files with 2 additions and 2 deletions
|
|
@ -40,13 +40,13 @@ namespace MinecraftClient.ChatBots
|
||||||
attackCooldownCounter = attackCooldown;
|
attackCooldownCounter = attackCooldown;
|
||||||
if (entitiesToAttack.Count > 0)
|
if (entitiesToAttack.Count > 0)
|
||||||
{
|
{
|
||||||
|
SendAnimation(Inventory.Hand.MainHand); // Arm animation
|
||||||
foreach (KeyValuePair<int, Entity> entity in entitiesToAttack)
|
foreach (KeyValuePair<int, Entity> entity in entitiesToAttack)
|
||||||
{
|
{
|
||||||
// check that we are in range once again.
|
// check that we are in range once again.
|
||||||
bool shouldAttack = handleEntity(entity.Value);
|
bool shouldAttack = handleEntity(entity.Value);
|
||||||
if (shouldAttack)
|
if (shouldAttack)
|
||||||
{
|
{
|
||||||
SendAnimation(Inventory.Hand.MainHand); // Hit Animation
|
|
||||||
InteractEntity(entity.Key, 1); // hit the entity!
|
InteractEntity(entity.Key, 1); // hit the entity!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ namespace MinecraftClient.ChatBots
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isBeingAttacked = entitiesToAttack.ContainsKey(entity.ID);
|
bool isBeingAttacked = entitiesToAttack.ContainsKey(entity.ID);
|
||||||
if (GetCurrentLocation().Distance(entity.Location) < attackRange)
|
if (GetCurrentLocation().Distance(entity.Location) <= attackRange)
|
||||||
{
|
{
|
||||||
// check to see if entity has not been marked as tracked, and if not, track it.
|
// check to see if entity has not been marked as tracked, and if not, track it.
|
||||||
if (!isBeingAttacked)
|
if (!isBeingAttacked)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue