1
0

Fixed double chests (#3741)

Normal and trapped chests next to each other don't open a double chest window.
Slot changes in the secondary chest are broadcast.
Placing a chest in +x of another updates the original chest's metadata.
This commit is contained in:
peterbell10
2017-06-03 20:17:53 +01:00
committed by Mattes D
parent 8f1e55611e
commit 36be4a89f8
3 changed files with 25 additions and 8 deletions

View File

@@ -127,21 +127,28 @@ void cChestEntity::ScanNeighbours()
{
public:
cChestEntity * m_Neighbour;
BLOCKTYPE m_ChestType;
cFindNeighbour() :
m_Neighbour(nullptr)
cFindNeighbour(BLOCKTYPE a_ChestType) :
m_Neighbour(nullptr),
m_ChestType(a_ChestType)
{
}
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:
cFindNeighbour FindNeighbour;
// 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) ||