summaryrefslogtreecommitdiffstats
path: root/src/SetChunkData.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-29 18:19:27 +0200
committerMattes D <github@xoft.cz>2014-08-29 18:19:47 +0200
commit22e3bbd0db71f9bd6d0a4306db1127f257bd24b1 (patch)
tree28c19677ac10421b48ae1a8905c37a05d6785c4f /src/SetChunkData.cpp
parentVanillaFluidSimulator: Fixed an invalid Y-coord query. (diff)
downloadcuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar.gz
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar.bz2
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar.lz
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar.xz
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.tar.zst
cuberite-22e3bbd0db71f9bd6d0a4306db1127f257bd24b1.zip
Diffstat (limited to 'src/SetChunkData.cpp')
-rw-r--r--src/SetChunkData.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp
index af6ad1251..97903074a 100644
--- a/src/SetChunkData.cpp
+++ b/src/SetChunkData.cpp
@@ -5,6 +5,7 @@
#include "Globals.h"
#include "SetChunkData.h"
+#include "BlockEntities/BlockEntity.h"
@@ -116,3 +117,35 @@ void cSetChunkData::CalculateHeightMap(void)
+
+void cSetChunkData::RemoveInvalidBlockEntities(void)
+{
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end();)
+ {
+ BLOCKTYPE EntityBlockType = (*itr)->GetBlockType();
+ BLOCKTYPE WorldBlockType = cChunkDef::GetBlock(m_BlockTypes, (*itr)->GetRelX(), (*itr)->GetPosY(), (*itr)->GetRelZ());
+ if (EntityBlockType != WorldBlockType)
+ {
+ // Bad blocktype, remove the block entity:
+ LOGD("Block entity blocktype mismatch at {%d, %d, %d}: entity for blocktype %s(%d) in block %s(%d). Deleting the block entity.",
+ (*itr)->GetPosX(), (*itr)->GetPosY(), (*itr)->GetPosZ(),
+ ItemTypeToString(EntityBlockType).c_str(), EntityBlockType,
+ ItemTypeToString(WorldBlockType).c_str(), WorldBlockType
+ );
+ cBlockEntityList::iterator itr2 = itr;
+ itr2++;
+ m_BlockEntities.erase(itr);
+ delete *itr;
+ itr = itr2;
+ }
+ else
+ {
+ // Good blocktype, keep the block entity:
+ ++itr;
+ }
+ } // for itr - m_BlockEntities[]
+}
+
+
+
+