summaryrefslogtreecommitdiffstats
path: root/source/Generating/ChunkDesc.cpp
diff options
context:
space:
mode:
authorDaniel O'Brien <marmot.daniel@gmail.com>2013-11-15 08:25:20 +0100
committerDaniel O'Brien <marmot.daniel@gmail.com>2013-11-15 08:25:20 +0100
commitaf17faac45f8ecbfc3af64231b65d66872af3301 (patch)
treea8864aef4d4a9036249170602164927b9ca99d58 /source/Generating/ChunkDesc.cpp
parentcProtocol add SendExperience() and debugging (diff)
parentMerge pull request #349 from SamJBarney/master (diff)
downloadcuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.gz
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.bz2
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.lz
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.xz
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.zst
cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.zip
Diffstat (limited to 'source/Generating/ChunkDesc.cpp')
-rw-r--r--source/Generating/ChunkDesc.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index dc6c74a3c..039f30d9c 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -8,6 +8,7 @@
#include "../BlockArea.h"
#include "../Cuboid.h"
#include "../Noise.h"
+#include "../BlockEntities/BlockEntity.h"
@@ -526,9 +527,28 @@ void cChunkDesc::RandomFillRelCuboid(
-void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
+cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
{
- m_BlockEntities.push_back(a_BlockEntity);
+ int AbsX = a_RelX + m_ChunkX * cChunkDef::Width;
+ int AbsZ = a_RelZ + m_ChunkZ * cChunkDef::Width;
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr)
+ {
+ if (((*itr)->GetPosX() == AbsX) && ((*itr)->GetPosY() == a_RelY) && ((*itr)->GetPosZ() == AbsZ))
+ {
+ // Already in the list, return it:
+ return *itr;
+ }
+ } // for itr - m_BlockEntities[]
+
+ // The block entity is not created yet, try to create it and add to list:
+ cBlockEntity * be = cBlockEntity::CreateByBlockType(GetBlockType(a_RelX, a_RelY, a_RelZ), GetBlockMeta(a_RelX, a_RelY, a_RelZ), AbsX, a_RelY, AbsZ);
+ if (be == NULL)
+ {
+ // No block entity for this block type
+ return NULL;
+ }
+ m_BlockEntities.push_back(be);
+ return be;
}