summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-02 14:50:34 +0100
committerGitHub <noreply@github.com>2021-01-02 14:50:34 +0100
commit16aeb84cd35996a6b41f10cbc48a677eeccc911c (patch)
treeae877926559d59a534bbf3c22651e6df7ffe8d71 /src/Entities/Entity.cpp
parentFix version typo in CMakeLists.txt (#5098) (diff)
downloadcuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.gz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.bz2
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.lz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.xz
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.tar.zst
cuberite-16aeb84cd35996a6b41f10cbc48a677eeccc911c.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp71
1 files changed, 27 insertions, 44 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 579541dd3..438117650 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -80,32 +80,6 @@ cEntity::cEntity(eEntityType a_EntityType, Vector3d a_Pos, double a_Width, doubl
-cEntity::~cEntity()
-{
- /*
- // DEBUG:
- FLOGD("Deleting entity {0} at pos {1:.2f} ~ [{2}, {3}]; ptr {4}",
- m_UniqueID,
- m_Pos,
- GetChunkX(), GetChunkZ(),
- static_cast<void *>(this)
- );
- */
-
- if (m_AttachedTo != nullptr)
- {
- Detach();
- }
- if (m_Attachee != nullptr)
- {
- m_Attachee->Detach();
- }
-}
-
-
-
-
-
const char * cEntity::GetClass(void) const
{
return "cEntity";
@@ -174,7 +148,22 @@ void cEntity::OnAddToWorld(cWorld & a_World)
void cEntity::OnRemoveFromWorld(cWorld & a_World)
{
- RemoveAllLeashedMobs();
+ // Remove all mobs from the leashed list of mobs:
+ while (!m_LeashedMobs.empty())
+ {
+ m_LeashedMobs.front()->Unleash(false, true);
+ }
+
+ if (m_AttachedTo != nullptr)
+ {
+ Detach();
+ }
+
+ if (m_Attachee != nullptr)
+ {
+ m_Attachee->Detach();
+ }
+
a_World.BroadcastDestroyEntity(*this);
}
@@ -244,7 +233,6 @@ void cEntity::Destroy()
// Also, not storing the returned pointer means automatic destruction
VERIFY(a_World.RemoveEntity(*this));
});
- Destroyed();
}
@@ -813,10 +801,17 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI)
cRoot::Get()->GetPluginManager()->CallHookKilled(*this, a_TDI, emptystring);
}
- // Drop loot:
- cItems Drops;
- GetDrops(Drops, a_TDI.Attacker);
- m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
+ // Drop loot, unless the attacker was a creative mode player:
+ if (
+ (a_TDI.Attacker == nullptr) ||
+ !a_TDI.Attacker->IsPlayer() ||
+ !static_cast<cPlayer *>(a_TDI.Attacker)->IsGameModeCreative()
+ )
+ {
+ cItems Drops;
+ GetDrops(Drops, a_TDI.Attacker);
+ m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
+ }
m_World->BroadcastEntityStatus(*this, esGenericDead);
}
@@ -2328,18 +2323,6 @@ void cEntity::RemoveLeashedMob(cMonster * a_Monster)
-void cEntity::RemoveAllLeashedMobs()
-{
- while (!m_LeashedMobs.empty())
- {
- m_LeashedMobs.front()->Unleash(false, true);
- }
-}
-
-
-
-
-
void cEntity::BroadcastLeashedMobs()
{
// If has any mob leashed broadcast every leashed entity to this