summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-06-03 21:17:53 +0200
committerMattes D <github@xoft.cz>2017-06-03 21:17:53 +0200
commit36be4a89f8bedca7a7b369289562cf71041a3db6 (patch)
treefab8f27bb0c0abdb2e16508c6180c38988ac6af1 /src
parentFixed exp orb (#3744) (diff)
downloadcuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar.gz
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar.bz2
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar.lz
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar.xz
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.tar.zst
cuberite-36be4a89f8bedca7a7b369289562cf71041a3db6.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/ChestEntity.cpp15
-rw-r--r--src/BlockEntities/ChestEntity.h16
-rw-r--r--src/Items/ItemChest.h2
3 files changed, 25 insertions, 8 deletions
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index 3fcf1b386..a47593108 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -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) ||
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index dfd5ca0d0..96d904248 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -39,7 +39,7 @@ public:
virtual void SendTo(cClientHandle & a_Client) override;
virtual bool UsedBy(cPlayer * a_Player) override;
- /** Search horizontally adjacent blocks for neighbouring chests and links them together. */
+ /** Search horizontally adjacent blocks for neighbouring chests of the same type and links them together. */
void ScanNeighbours();
/** Opens a new chest window where this is the primary chest and any neighbour is the secondary. */
@@ -72,9 +72,19 @@ private:
ASSERT(a_Grid == &m_Contents);
if (m_World != nullptr)
{
- if (GetWindow() != nullptr)
+ cWindow * Window = GetWindow();
+ if (
+ (Window == nullptr) &&
+ (m_Neighbour != nullptr)
+ )
{
- GetWindow()->BroadcastWholeWindow();
+ // Neighbour might own the window
+ Window = m_Neighbour->GetWindow();
+ }
+
+ if (Window != nullptr)
+ {
+ Window->BroadcastWholeWindow();
}
m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
diff --git a/src/Items/ItemChest.h b/src/Items/ItemChest.h
index a714e5c96..d8cde2ae2 100644
--- a/src/Items/ItemChest.h
+++ b/src/Items/ItemChest.h
@@ -154,7 +154,7 @@ public:
}
// Adjust the existing chest, if any:
- if (NeighborIdx > 0)
+ if (NeighborIdx != -1)
{
a_World.FastSetBlock(a_BlockX + CrossCoords[NeighborIdx].x, a_BlockY, a_BlockZ + CrossCoords[NeighborIdx].z, ChestBlockType, Meta);
}