MCPcopy Create free account
hub / github.com/cuberite/cuberite / AddBlock

Method AddBlock

src/Simulator/SandSimulator.cpp:94–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94void cSandSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
95{
96 if ((a_Chunk == NULL) || !a_Chunk->IsValid())
97 {
98 return;
99 }
100 int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
101 int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
102 if (!IsAllowedBlock(a_Chunk->GetBlock(RelX, a_BlockY, RelZ)))
103 {
104 return;
105 }
106
107 // Check for duplicates:
108 cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData();
109 for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr)
110 {
111 if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ))
112 {
113 return;
114 }
115 }
116
117 m_TotalBlocks += 1;
118 ChunkData.push_back(cCoordWithInt(RelX, a_BlockY, RelZ));
119}
120
121
122

Callers 1

WakeUpSimulatorsMethod · 0.45

Calls 6

beginMethod · 0.80
endMethod · 0.80
IsValidMethod · 0.45
GetPosXMethod · 0.45
GetPosZMethod · 0.45
GetBlockMethod · 0.45

Tested by

no test coverage detected