summaryrefslogtreecommitdiffstats
path: root/src/Chunk.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/Chunk.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 '')
-rw-r--r--src/Chunk.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 0d0b0896a..ff5757703 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -220,6 +220,12 @@ void cChunk::OnUnload()
// Notify the entity:
Entity->OnRemoveFromWorld(*Entity->GetWorld());
}
+
+ // Notify all block entities of imminent unload:
+ for (auto & BlockEntity : m_BlockEntities)
+ {
+ BlockEntity.second->OnRemoveFromWorld();
+ }
}
@@ -452,6 +458,7 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
if (affectedArea.IsInside(itr->second->GetPos()))
{
itr->second->Destroy();
+ itr->second->OnRemoveFromWorld();
itr = m_BlockEntities.erase(itr);
}
else
@@ -760,6 +767,7 @@ void cChunk::MoveEntityToNewChunk(OwnedEntity a_Entity)
if (Neighbor == nullptr)
{
LOGWARNING("%s: Failed to move entity, destination chunk unreachable. Entity lost", __FUNCTION__);
+ a_Entity->OnRemoveFromWorld(*m_World);
return;
}
@@ -1267,6 +1275,7 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
if (BlockEntity != nullptr)
{
BlockEntity->Destroy();
+ BlockEntity->OnRemoveFromWorld();
RemoveBlockEntity(BlockEntity);
}