diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 09:45:06 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-09-02 09:50:23 +0200 |
commit | 49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch) | |
tree | b1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/BlockEntities/ChestEntity.cpp | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2 cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/ChestEntity.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 5e8b29a45..a8f5b7242 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -138,18 +138,33 @@ bool cChestEntity::UsedBy(cPlayer * a_Player) void cChestEntity::ScanNeighbours() { // Callback for finding neighbouring chest: - auto FindNeighbour = [this](cChestEntity & a_Chest) + class cFindNeighbour : + public cChestCallback { - if (a_Chest.GetBlockType() != m_BlockType) + public: + cChestEntity * m_Neighbour; + BLOCKTYPE m_ChestType; + + cFindNeighbour(BLOCKTYPE a_ChestType) : + m_Neighbour(nullptr), + m_ChestType(a_ChestType) { - // Neighboring block is not the same type of chest - return true; } - m_Neighbour = &a_Chest; - return false; + + virtual bool Item(cChestEntity * a_Chest) override + { + if (a_Chest->GetBlockType() != m_ChestType) + { + // Neighboring block is not the same type of chest + return true; + } + m_Neighbour = a_Chest; + return false; + } }; // Scan horizontally adjacent blocks for any neighbouring chest of the same type: + cFindNeighbour FindNeighbour(m_BlockType); if ( m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, FindNeighbour) || m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, FindNeighbour) || @@ -157,6 +172,7 @@ void cChestEntity::ScanNeighbours() m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, FindNeighbour) ) { + m_Neighbour = FindNeighbour.m_Neighbour; m_Neighbour->m_Neighbour = this; // Force neighbour's window shut. Does Mojang server do this or should a double window open? m_Neighbour->DestroyWindow(); |