diff options
author | 12xx12 <44411062+12xx12@users.noreply.github.com> | 2021-03-05 16:08:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-05 16:08:30 +0100 |
commit | 8405b8969f205ffae219361dfc03f3b4c680ce73 (patch) | |
tree | cc1aef4347d9e399b80a32afa16b657885fd3603 /src/Mobs/Wither.cpp | |
parent | Add Mushrooms to Generator and fixed up the roofed forest (#5134) (diff) | |
download | cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar.gz cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar.bz2 cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar.lz cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar.xz cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.tar.zst cuberite-8405b8969f205ffae219361dfc03f3b4c680ce73.zip |
Diffstat (limited to 'src/Mobs/Wither.cpp')
-rw-r--r-- | src/Mobs/Wither.cpp | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index fc02b2971..bdbbfcadb 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -5,6 +5,8 @@ #include "../World.h" #include "../Entities/Player.h" +#include "../ClientHandle.h" +#include "../CompositeChat.h" @@ -48,40 +50,13 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } - return Super::DoTakeDamage(a_TDI); -} - - - - - -void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) -{ - Super::Tick(a_Dt, a_Chunk); - if (!IsTicking()) - { - // The base class tick destroyed us - return; - } - - if (m_WitherInvulnerableTicks > 0) + if (!Super::DoTakeDamage(a_TDI)) { - unsigned int NewTicks = m_WitherInvulnerableTicks - 1; - - if (NewTicks == 0) - { - m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); - } - - m_WitherInvulnerableTicks = NewTicks; - - if ((NewTicks % 10) == 0) - { - Heal(10); - } + return false; } - m_World->BroadcastEntityMetadata(*this); + m_World->BroadcastBossBarUpdateHealth(*this, GetUniqueID(), GetHealth() / GetMaxHealth()); + return true; } @@ -119,3 +94,44 @@ void cWither::KilledBy(TakeDamageInfo & a_TDI) + +void cWither::SpawnOn(cClientHandle & a_Client) +{ + Super::SpawnOn(a_Client); + + // Purple boss bar with no divisions that darkens the sky: + a_Client.SendBossBarAdd(GetUniqueID(), cCompositeChat("Wither"), GetHealth() / GetMaxHealth(), BossBarColor::Purple, BossBarDivisionType::None, true, false, false); +} + + + + + +void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) +{ + Super::Tick(a_Dt, a_Chunk); + if (!IsTicking()) + { + // The base class tick destroyed us + return; + } + + if (m_WitherInvulnerableTicks > 0) + { + unsigned int NewTicks = m_WitherInvulnerableTicks - 1; + + if (NewTicks == 0) + { + m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this); + } + + m_WitherInvulnerableTicks = NewTicks; + + if ((NewTicks % 10) == 0) + { + Heal(10); + } + } + + m_World->BroadcastEntityMetadata(*this); +} |