Always use relative coordinates in AddBlock
+ Pass block, use relatives * Fixes everything immediately converting abs back to rel and getting block, when these data were already available
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user