summaryrefslogtreecommitdiffstats
path: root/source/Chunk.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-03 16:33:55 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-03 16:33:55 +0100
commit55326ee2a72aea190ba9ccc7b04969742fc7ce5f (patch)
tree9361d4cfe6cb50f753ef78629bd602d8afe05bb8 /source/Chunk.cpp
parentRedstone simulator: adding a block now checks if the neighbors are redstone-related; if not, the block is ignored. (diff)
downloadcuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar.gz
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar.bz2
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar.lz
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar.xz
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.tar.zst
cuberite-55326ee2a72aea190ba9ccc7b04969742fc7ce5f.zip
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r--source/Chunk.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index a013554db..cfe6ad22d 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -308,6 +308,9 @@ void cChunk::SetAllData(
// Create block entities that the loader didn't load; fill them with defaults
CreateBlockEntities();
+
+ // Wake up all simulators for their respective blocks:
+ WakeUpSimulators();
m_HasLoadFailed = false;
}
@@ -1052,6 +1055,42 @@ void cChunk::CreateBlockEntities(void)
+void cChunk::WakeUpSimulators(void)
+{
+ cSimulator * WaterSimulator = m_World->GetWaterSimulator();
+ cSimulator * LavaSimulator = m_World->GetLavaSimulator();
+ int BaseX = m_PosX * cChunkDef::Width;
+ int BaseZ = m_PosZ * cChunkDef::Width;
+ for (int x = 0; x < Width; x++)
+ {
+ int BlockX = x + BaseX;
+ for (int z = 0; z < Width; z++)
+ {
+ int BlockZ = z + BaseZ;
+ for (int y = GetHeight(x, z); y >= 0; y--)
+ {
+ switch (cChunkDef::GetBlock(m_BlockTypes, x, y, z))
+ {
+ case E_BLOCK_WATER:
+ {
+ WaterSimulator->AddBlock(BlockX, y, BlockZ, this);
+ break;
+ }
+ case E_BLOCK_LAVA:
+ {
+ LavaSimulator->AddBlock(BlockX, y, BlockZ, this);
+ break;
+ }
+ } // switch (BlockType)
+ } // for y
+ } // for z
+ } // for x
+}
+
+
+
+
+
void cChunk::CalculateHeightmap()
{
for (int x = 0; x < Width; x++)