summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
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/Chunk.cpp
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/Chunk.cpp')
-rw-r--r--src/Chunk.cpp40
1 files changed, 6 insertions, 34 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index cb14b36a0..1c06ed3b3 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1241,40 +1241,12 @@ void cChunk::WakeUpSimulators(void)
for (size_t BlockIdx = 0; BlockIdx != cChunkData::SectionBlockCount; ++BlockIdx)
{
- auto BlockType = Section->m_BlockTypes[BlockIdx];
-
- // Defer calculation until it's actually needed
- auto WorldPos = [&]
- {
- auto RelPos = IndexToCoordinate(BlockIdx);
- RelPos.y += static_cast<int>(SectionIdx * cChunkData::SectionHeight);
- return RelativeToAbsolute(RelPos);
- };
+ const auto BlockType = Section->m_BlockTypes[BlockIdx];
+ const auto Position = IndexToCoordinate(BlockIdx);
- // The redstone sim takes multiple blocks, use the inbuilt checker
- if (RedstoneSimulator->IsAllowedBlock(BlockType))
- {
- RedstoneSimulator->AddBlock(WorldPos(), this);
- continue;
- }
-
- switch (BlockType)
- {
- case E_BLOCK_WATER:
- {
- WaterSimulator->AddBlock(WorldPos(), this);
- break;
- }
- case E_BLOCK_LAVA:
- {
- LavaSimulator->AddBlock(WorldPos(), this);
- break;
- }
- default:
- {
- break;
- }
- } // switch (BlockType)
+ RedstoneSimulator->AddBlock(*this, Position, BlockType);
+ WaterSimulator->AddBlock(*this, Position, BlockType);
+ LavaSimulator->AddBlock(*this, Position, BlockType);
}
}
}
@@ -1316,7 +1288,7 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
// TODO: use relative coordinates, cChunk reference
// Wake up the simulators for this block:
- GetWorld()->GetSimulatorManager()->WakeUp(RelativeToAbsolute(a_RelPos), this);
+ GetWorld()->GetSimulatorManager()->WakeUp(*this, a_RelPos);
// If there was a block entity, remove it:
cBlockEntity * BlockEntity = GetBlockEntityRel(a_RelPos);