summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu22@users.noreply.github.com>2016-05-14 21:12:42 +0200
committerAlexander Harkness <me@bearbin.net>2016-05-14 21:12:42 +0200
commita4f327118b06ced1cd4510b7d20d34da83aa78a3 (patch)
treed6dbd41cfbec99f2598fb51907b86d9cbe0e8a05 /src/Entities/Entity.cpp
parentFixed death on teleportation or leaving Minecart (#3181) (diff)
downloadcuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar.gz
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar.bz2
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar.lz
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar.xz
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.tar.zst
cuberite-a4f327118b06ced1cd4510b7d20d34da83aa78a3.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 30aa87f37..6e1dec957 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1927,10 +1927,13 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
Detach();
}
- // Attach to the new entity:
+ // Update state information
m_AttachedTo = a_AttachTo;
a_AttachTo->m_Attachee = this;
- m_World->BroadcastAttachEntity(*this, a_AttachTo);
+ if (a_AttachTo != nullptr)
+ {
+ m_World->BroadcastAttachEntity(*this, *a_AttachTo);
+ }
}
@@ -1941,12 +1944,13 @@ void cEntity::Detach(void)
{
if (m_AttachedTo == nullptr)
{
- // Attached to no 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;
- m_World->BroadcastAttachEntity(*this, nullptr);
}