From 83852511bc7d4c279a73e27438d259cda5c81990 Mon Sep 17 00:00:00 2001 From: OverHash <46231745+OverHash@users.noreply.github.com> Date: Fri, 24 Apr 2020 09:02:51 +1200 Subject: [PATCH] Don't attack entities whilst dead MCC will now not attempt to attack entities if the client is dead --- MinecraftClient/ChatBots/AutoAttack.cs | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index d3564a64..20bcf299 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -18,6 +18,7 @@ namespace MinecraftClient.ChatBots private Double attackCooldownSecond; private int attackRange = 4; private Double serverTPS; + private float health = 100; public override void Initialize() { @@ -31,23 +32,22 @@ namespace MinecraftClient.ChatBots public override void Update() { - if (!AutoEat.Eating) + if (AutoEat.Eating | health == 0) return; + + if (attackCooldownCounter == 0) { - if (attackCooldownCounter == 0) + attackCooldownCounter = attackCooldown; + if (entitiesToAttack.Count > 0) { - attackCooldownCounter = attackCooldown; - if (entitiesToAttack.Count > 0) + foreach (KeyValuePair a in entitiesToAttack) { - foreach (KeyValuePair a in entitiesToAttack) - { - InteractEntity(a.Key, 1); - } + InteractEntity(a.Key, 1); } } - else - { - attackCooldownCounter--; - } + } + else + { + attackCooldownCounter--; } } @@ -67,6 +67,11 @@ namespace MinecraftClient.ChatBots handleEntity(entity); } + public override void OnHealthUpdate(float health, int food) + { + this.health = health; + } + public override void OnPlayerProperty(Dictionary prop) { // adjust auto attack cooldown for maximum attack damage