summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-29 02:18:59 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-08-02 16:52:06 +0200
commit225c2fa9f6bc2ebffcc9160090482e6833a220ce (patch)
treeb72a5b27b49e38fe160da580a6f659a1a9d93308 /src/BlockEntities
parentAdd WakeUp/AddBlock distinction (diff)
downloadcuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.gz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.bz2
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.lz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.xz
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.tar.zst
cuberite-225c2fa9f6bc2ebffcc9160090482e6833a220ce.zip
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/BlockEntityWithItems.cpp8
-rw-r--r--src/BlockEntities/ChestEntity.cpp39
-rw-r--r--src/BlockEntities/ChestEntity.h39
3 files changed, 44 insertions, 42 deletions
diff --git a/src/BlockEntities/BlockEntityWithItems.cpp b/src/BlockEntities/BlockEntityWithItems.cpp
index 1a8ae4342..b2f225aa7 100644
--- a/src/BlockEntities/BlockEntityWithItems.cpp
+++ b/src/BlockEntities/BlockEntityWithItems.cpp
@@ -58,10 +58,10 @@ void cBlockEntityWithItems::OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum)
auto & Simulator = *m_World->GetRedstoneSimulator();
// Notify comparators:
- Simulator.WakeUp(m_Pos + Vector3i(1, 0, 0), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(-1, 0, 0), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(0, 0, 1), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(0, 0, -1), &a_Chunk);
+ m_World->WakeUpSimulators(m_Pos + Vector3i(1, 0, 0));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(-1, 0, 0));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(0, 0, 1));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(0, 0, -1));
return true;
});
}
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index d9648df18..cb26f4d08 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -216,3 +216,42 @@ bool cChestEntity::IsBlocked()
+
+void cChestEntity::OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum)
+{
+ ASSERT(a_Grid == &m_Contents);
+
+ if (m_World == nullptr)
+ {
+ return;
+ }
+
+ // Have cBlockEntityWithItems update redstone and try to broadcast our window:
+ Super::OnSlotChanged(a_Grid, a_SlotNum);
+
+ cWindow * Window = GetWindow();
+ if ((Window == nullptr) && (m_Neighbour != nullptr))
+ {
+ // Window was null, Super will have failed.
+ // Neighbour might own the window:
+ Window = m_Neighbour->GetWindow();
+ }
+
+ if (Window != nullptr)
+ {
+ Window->BroadcastWholeWindow();
+ }
+
+ m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
+ m_World->DoWithChunkAt(m_Pos, [&](cChunk & a_Chunk)
+ {
+ auto & Simulator = *m_World->GetRedstoneSimulator();
+
+ // Notify comparators:
+ m_World->WakeUpSimulators(m_Pos + Vector3i(1, 0, 0));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(-1, 0, 0));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(0, 0, 1));
+ m_World->WakeUpSimulators(m_Pos + Vector3i(0, 0, -1));
+ return true;
+ });
+}
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index c6d13fa38..84b6eef0c 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -74,44 +74,7 @@ private:
cChestEntity * m_Neighbour;
/** cItemGrid::cListener overrides: */
- virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override
- {
- ASSERT(a_Grid == &m_Contents);
-
- if (m_World == nullptr)
- {
- return;
- }
-
- // Have cBlockEntityWithItems update redstone and try to broadcast our window:
- Super::OnSlotChanged(a_Grid, a_SlotNum);
-
- cWindow * Window = GetWindow();
- if ((Window == nullptr) && (m_Neighbour != nullptr))
- {
- // Window was null, Super will have failed.
- // Neighbour might own the window:
- Window = m_Neighbour->GetWindow();
- }
-
- if (Window != nullptr)
- {
- Window->BroadcastWholeWindow();
- }
-
- m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
- m_World->DoWithChunkAt(m_Pos, [&](cChunk & a_Chunk)
- {
- auto & Simulator = *m_World->GetRedstoneSimulator();
-
- // Notify comparators:
- Simulator.WakeUp(m_Pos + Vector3i(1, 0, 0), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(-1, 0, 0), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(0, 0, 1), &a_Chunk);
- Simulator.WakeUp(m_Pos + Vector3i(0, 0, -1), &a_Chunk);
- return true;
- });
- }
+ virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override;
} ; // tolua_export