summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Chunk.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index fa7faf1f0..35d8a8819 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -370,15 +370,25 @@ void cChunk::SetAllData(SetChunkData && a_SetChunkData)
m_BlockEntities = std::move(a_SetChunkData.BlockEntities);
// Check that all block entities have a valid blocktype at their respective coords (DEBUG-mode only):
-#ifndef NDEBUG
+
for (auto & KeyPair : m_BlockEntities)
{
+#ifndef NDEBUG
cBlockEntity * Block = KeyPair.second.get();
BLOCKTYPE EntityBlockType = Block->GetBlockType();
BLOCKTYPE WorldBlockType = GetBlock(Block->GetRelX(), Block->GetPosY(), Block->GetRelZ());
ASSERT(WorldBlockType == EntityBlockType);
- }
#endif
+ // Reset Pointer
+ KeyPair.second->SetWorld(nullptr);
+
+ auto Pos = cChunkDef::RelativeToAbsolute({KeyPair.second->GetRelX(), 0, KeyPair.second->GetRelZ()}, {m_PosX, m_PosZ});
+ if ((Pos.x != KeyPair.second->GetPosX()) || (Pos.z != KeyPair.second->GetPosZ()))
+ {
+ KeyPair.second->SetPos(Pos.addedY(KeyPair.second->GetPosY()));
+ }
+ KeyPair.second->SetWorld(m_World);
+ }
// Set the chunk data as valid.
// This may be needed for some simulators that perform actions upon block adding (Vaporize),