summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-09-03 17:00:26 +0200
committermadmaxoft <github@xoft.cz>2014-09-03 17:00:26 +0200
commita51c1e0b73a83cddcce865671ca30240393e458f (patch)
tree688e63c296f02e327b4ee2f9e117a172a6e2d85b /src/Chunk.cpp
parentcBoundingBox: Added accessors. (diff)
downloadcuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar.gz
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar.bz2
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar.lz
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar.xz
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.tar.zst
cuberite-a51c1e0b73a83cddcce865671ca30240393e458f.zip
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r--src/Chunk.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 40ffff834..20e943d9a 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -37,6 +37,7 @@
#include "MobSpawner.h"
#include "BlockInServerPluginInterface.h"
#include "SetChunkData.h"
+#include "BoundingBox.h"
#include "json/json.h"
@@ -1960,6 +1961,30 @@ bool cChunk::ForEachEntity(cEntityCallback & a_Callback)
+bool cChunk::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback)
+{
+ // The entity list is locked by the parent chunkmap's CS
+ for (cEntityList::iterator itr = m_Entities.begin(), itr2 = itr; itr != m_Entities.end(); itr = itr2)
+ {
+ ++itr2;
+ cBoundingBox EntBox((*itr)->GetPosition(), (*itr)->GetWidth() / 2, (*itr)->GetHeight());
+ if (!EntBox.DoesIntersect(a_Box))
+ {
+ // The entity is not in the specified box
+ continue;
+ }
+ if (a_Callback.Item(*itr))
+ {
+ return false;
+ }
+ } // for itr - m_Entitites[]
+ return true;
+}
+
+
+
+
+
bool cChunk::DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackResult)
{
// The entity list is locked by the parent chunkmap's CS