diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-07-30 22:19:51 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-07-30 22:19:51 +0200 |
commit | 81e095adda62e4067ab4c07b0e4c7ce0f3dbce39 (patch) | |
tree | 09687befe7c3a3e9b6eb6abf97455743c254d0c0 /src/Chunk.cpp | |
parent | Added beacon. (diff) | |
download | cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar.gz cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar.bz2 cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar.lz cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar.xz cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.tar.zst cuberite-81e095adda62e4067ab4c07b0e4c7ce0f3dbce39.zip |
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r-- | src/Chunk.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index b83036b6d..cd7dc698c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -11,6 +11,7 @@ #include "Server.h" #include "zlib/zlib.h" #include "Defines.h" +#include "BlockEntities/BeaconEntity.h" #include "BlockEntities/ChestEntity.h" #include "BlockEntities/DispenserEntity.h" #include "BlockEntities/DropperEntity.h" @@ -2126,6 +2127,38 @@ bool cChunk::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBloc +bool cChunk::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback) +{ + // The blockentity list is locked by the parent chunkmap's CS + for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), itr2 = itr; itr != m_BlockEntities.end(); itr = itr2) + { + ++itr2; + if (((*itr)->GetPosX() != a_BlockX) || ((*itr)->GetPosY() != a_BlockY) || ((*itr)->GetPosZ() != a_BlockZ)) + { + continue; + } + if ((*itr)->GetBlockType() != E_BLOCK_BEACON) + { + // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out + return false; + } + + // The correct block entity is here + if (a_Callback.Item((cBeaconEntity *)*itr)) + { + return false; + } + return true; + } // for itr - m_BlockEntitites[] + + // Not found: + return false; +} + + + + + bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback) { // The blockentity list is locked by the parent chunkmap's CS |