diff options
author | Mattes D <github@xoft.cz> | 2014-09-04 22:25:19 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-09-04 22:25:19 +0200 |
commit | e9dda864eae043da5664a683ab08910c3081e571 (patch) | |
tree | 040923a3d26266e1ccbce3f3ee44079c511702b9 /src/Chunk.cpp | |
parent | Merge pull request #1371 from DayBr3ak/master (diff) | |
parent | Fixed compilation after chunk Y removal. (diff) | |
download | cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.gz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.bz2 cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.lz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.xz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.zst cuberite-e9dda864eae043da5664a683ab08910c3081e571.zip |
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r-- | src/Chunk.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 95b8c8e5e..9fb178bc3 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" @@ -1959,6 +1960,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 |