summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-09-30 00:17:03 +0200
committerGitHub <noreply@github.com>2021-09-30 00:17:03 +0200
commit028a5735c5f98aa10718c94de07d2f4b4c1fa6b3 (patch)
tree53d4bdd7c5c3f9abd6416b27ba893341a042ffea /src/Entities/Entity.cpp
parentPermission-based player chat message formatting (#5304) (diff)
downloadcuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.gz
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.bz2
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.lz
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.xz
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.zst
cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index e9605fe5a..a5b1fae8f 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1994,26 +1994,25 @@ cEntity * cEntity::GetAttached()
-void cEntity::AttachTo(cEntity * a_AttachTo)
+void cEntity::AttachTo(cEntity & a_AttachTo)
{
- if (m_AttachedTo == a_AttachTo)
+ if (m_AttachedTo == &a_AttachTo)
{
- // Already attached to that entity, nothing to do here
+ // Already attached to that entity, nothing to do here:
return;
}
+
if (m_AttachedTo != nullptr)
{
// Detach from any previous entity:
Detach();
}
- // Update state information
- m_AttachedTo = a_AttachTo;
- a_AttachTo->m_Attachee = this;
- if (a_AttachTo != nullptr)
- {
- m_World->BroadcastAttachEntity(*this, *a_AttachTo);
- }
+ // Update state information:
+ m_AttachedTo = &a_AttachTo;
+ a_AttachTo.m_Attachee = this;
+
+ m_World->BroadcastAttachEntity(*this, a_AttachTo);
}
@@ -2024,13 +2023,16 @@ void cEntity::Detach(void)
{
if (m_AttachedTo == nullptr)
{
- // Already not attached to any entity, our work is done
+ // Already not attached to any entity, our work is done:
return;
}
+
m_World->BroadcastDetachEntity(*this, *m_AttachedTo);
m_AttachedTo->m_Attachee = nullptr;
m_AttachedTo = nullptr;
+
+ OnDetach();
}
@@ -2306,6 +2308,14 @@ void cEntity::BroadcastLeashedMobs()
+void cEntity::OnDetach()
+{
+}
+
+
+
+
+
void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI)
{
cPluginManager * PluginManager = cRoot::Get()->GetPluginManager();