summaryrefslogtreecommitdiffstats
path: root/src/Simulator/SandSimulator.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/Simulator/SandSimulator.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/Simulator/SandSimulator.cpp')
-rw-r--r--src/Simulator/SandSimulator.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index ef02339bc..95f514cc9 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -99,29 +99,23 @@ bool cSandSimulator::IsAllowedBlock(BLOCKTYPE a_BlockType)
void cSandSimulator::AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
{
- if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
- {
- return;
- }
- int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
- if (!IsAllowedBlock(a_Chunk->GetBlock(RelX, a_Block.y, RelZ)))
+ if (!IsAllowedBlock(a_Block))
{
return;
}
// Check for duplicates:
- cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData();
+ cSandSimulatorChunkData & ChunkData = a_Chunk.GetSandSimulatorData();
for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr)
{
- if ((itr->x == RelX) && (itr->y == a_Block.y) && (itr->z == RelZ))
+ if ((itr->x == a_Position.x) && (itr->y == a_Position.y) && (itr->z == a_Position.z))
{
return;
}
}
m_TotalBlocks += 1;
- ChunkData.push_back(cCoordWithInt(RelX, a_Block.y, RelZ));
+ ChunkData.push_back(cCoordWithInt(a_Position.x, a_Position.y, a_Position.z));
}