summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2021-03-05 16:08:30 +0100
committerGitHub <noreply@github.com>2021-03-05 16:08:30 +0100
commit8405b8969f205ffae219361dfc03f3b4c680ce73 (patch)
treecc1aef4347d9e399b80a32afa16b657885fd3603 /src/Mobs
parentAdd Mushrooms to Generator and fixed up the roofed forest (#5134) (diff)
downloadcuberite-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')
-rw-r--r--src/Mobs/EnderDragon.cpp25
-rw-r--r--src/Mobs/EnderDragon.h6
-rw-r--r--src/Mobs/Wither.cpp78
-rw-r--r--src/Mobs/Wither.h12
4 files changed, 78 insertions, 43 deletions
diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp
index a3ba5f937..e33fb21f1 100644
--- a/src/Mobs/EnderDragon.cpp
+++ b/src/Mobs/EnderDragon.cpp
@@ -2,6 +2,8 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "EnderDragon.h"
+#include "../ClientHandle.h"
+#include "../CompositeChat.h"
@@ -17,6 +19,21 @@ cEnderDragon::cEnderDragon(void) :
+bool cEnderDragon::DoTakeDamage(TakeDamageInfo & a_TDI)
+{
+ if (!Super::DoTakeDamage(a_TDI))
+ {
+ return false;
+ }
+
+ m_World->BroadcastBossBarUpdateHealth(*this, GetUniqueID(), GetHealth() / GetMaxHealth());
+ return true;
+}
+
+
+
+
+
void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
// No drops
@@ -25,3 +42,11 @@ void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cEnderDragon::SpawnOn(cClientHandle & a_Client)
+{
+ Super::SpawnOn(a_Client);
+
+ // Red boss bar with no divisions that plays boss music and creates fog:
+ a_Client.SendBossBarAdd(GetUniqueID(), cCompositeChat("Ender Dragon"), GetHealth() / GetMaxHealth(), BossBarColor::Red, BossBarDivisionType::None, false, true, true);
+}
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 1856d165c..ffc39218c 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -18,9 +18,7 @@ public:
CLASS_PROTODEF(cEnderDragon)
+ virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+ virtual void SpawnOn(cClientHandle & a_Client) override;
} ;
-
-
-
-
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);
+}
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 21e6aecf8..f6afb1e6d 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -26,12 +26,12 @@ public:
bool IsArmored(void) const;
// cEntity overrides
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
- virtual void KilledBy(TakeDamageInfo & a_TDI) override;
-
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool IsUndead(void) override { return true; }
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
+ virtual void SpawnOn(cClientHandle & a_Client) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
@@ -39,7 +39,3 @@ private:
unsigned int m_WitherInvulnerableTicks;
} ;
-
-
-
-