summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/ChestEntity.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-09-01 13:04:50 +0200
committerMattes D <github@xoft.cz>2017-09-01 13:04:50 +0200
commit496c337cdfa593654018c171f6a74c28272265b5 (patch)
treefab48316d8fd6de97500ca1b8c8c5792eb578acc /src/BlockEntities/ChestEntity.cpp
parentUpdate Core plugin (diff)
downloadcuberite-496c337cdfa593654018c171f6a74c28272265b5.tar
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.gz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.bz2
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.lz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.xz
cuberite-496c337cdfa593654018c171f6a74c28272265b5.tar.zst
cuberite-496c337cdfa593654018c171f6a74c28272265b5.zip
Diffstat (limited to 'src/BlockEntities/ChestEntity.cpp')
-rw-r--r--src/BlockEntities/ChestEntity.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index a8f5b7242..5e8b29a45 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -138,33 +138,18 @@ bool cChestEntity::UsedBy(cPlayer * a_Player)
void cChestEntity::ScanNeighbours()
{
// Callback for finding neighbouring chest:
- class cFindNeighbour :
- public cChestCallback
+ auto FindNeighbour = [this](cChestEntity & a_Chest)
{
- public:
- cChestEntity * m_Neighbour;
- BLOCKTYPE m_ChestType;
-
- cFindNeighbour(BLOCKTYPE a_ChestType) :
- m_Neighbour(nullptr),
- m_ChestType(a_ChestType)
+ if (a_Chest.GetBlockType() != m_BlockType)
{
+ // Neighboring block is not the same type of chest
+ return true;
}
-
- 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;
- }
+ 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) ||
@@ -172,7 +157,6 @@ 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();