diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-28 15:40:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 15:40:57 +0200 |
commit | 748b121703fa28b10933f4432c09391e66179118 (patch) | |
tree | 58a39b6a75c3e9127507bf3c185a99e546147276 /src/BlockEntities/ChestEntity.cpp | |
parent | Fix Windows XP to 7 compatibility (#5167) (diff) | |
download | cuberite-748b121703fa28b10933f4432c09391e66179118.tar cuberite-748b121703fa28b10933f4432c09391e66179118.tar.gz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.bz2 cuberite-748b121703fa28b10933f4432c09391e66179118.tar.lz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.xz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.zst cuberite-748b121703fa28b10933f4432c09391e66179118.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/ChestEntity.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 039d62287..9ede18759 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -146,24 +146,25 @@ bool cChestEntity::UsedBy(cPlayer * a_Player) void cChestEntity::ScanNeighbours() { - // Callback for finding neighbouring chest: - auto FindNeighbour = [this](cChestEntity & a_Chest) + // Callback for finding neighbouring chest. + auto FindNeighbour = [this](cBlockEntity & a_BlockEntity) { - if (a_Chest.GetBlockType() != m_BlockType) + if (a_BlockEntity.GetBlockType() != m_BlockType) { // Neighboring block is not the same type of chest - return true; + return false; } - m_Neighbour = &a_Chest; - return false; + + m_Neighbour = static_cast<cChestEntity *>(&a_BlockEntity); + return true; }; // Scan horizontally adjacent blocks for any neighbouring chest of the same type: if ( - m_World->DoWithChestAt(m_Pos.x - 1, m_Pos.y, m_Pos.z, FindNeighbour) || - m_World->DoWithChestAt(m_Pos.x + 1, m_Pos.y, m_Pos.z, FindNeighbour) || - m_World->DoWithChestAt(m_Pos.x, m_Pos.y, m_Pos.z - 1, FindNeighbour) || - m_World->DoWithChestAt(m_Pos.x, m_Pos.y, m_Pos.z + 1, FindNeighbour) + m_World->DoWithBlockEntityAt(m_Pos.addedX(-1), FindNeighbour) || + m_World->DoWithBlockEntityAt(m_Pos.addedX(+1), FindNeighbour) || + m_World->DoWithBlockEntityAt(m_Pos.addedZ(-1), FindNeighbour) || + m_World->DoWithBlockEntityAt(m_Pos.addedX(+1), FindNeighbour) ) { m_Neighbour->m_Neighbour = this; |