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

Method SimulateChunk

src/Simulator/SandSimulator.cpp:26–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
27{
28 cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData();
29 if (ChunkData.empty())
30 {
31 return;
32 }
33
34 int BaseX = a_Chunk->GetPosX() * cChunkDef::Width;
35 int BaseZ = a_Chunk->GetPosZ() * cChunkDef::Width;
36 for (cSandSimulatorChunkData::const_iterator itr = ChunkData.begin(), end = ChunkData.end(); itr != end; ++itr)
37 {
38 BLOCKTYPE BlockType = a_Chunk->GetBlock(itr->x, itr->y, itr->z);
39 if (!IsAllowedBlock(BlockType) || (itr->y <= 0))
40 {
41 continue;
42 }
43
44 BLOCKTYPE BlockBelow = (itr->y > 0) ? a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z) : E_BLOCK_AIR;
45 if (CanStartFallingThrough(BlockBelow))
46 {
47 if (m_IsInstantFall)
48 {
49 DoInstantFall(a_Chunk, itr->x, itr->y, itr->z);
50 continue;
51 }
52 Vector3i Pos;
53 Pos.x = itr->x + BaseX;
54 Pos.y = itr->y;
55 Pos.z = itr->z + BaseZ;
56 /*
57 LOGD(
58 "Creating a falling block at {%d, %d, %d} of type %s, block below: %s",
59 Pos.x, Pos.y, Pos.z, ItemTypeToString(BlockType).c_str(), ItemTypeToString(BlockBelow).c_str()
60 );
61 */
62 cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
63 FallingBlock->Initialize(&m_World);
64 a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);
65 }
66 }
67 m_TotalBlocks -= ChunkData.size();
68 ChunkData.clear();
69}
70
71
72

Callers 1

TickMethod · 0.45

Calls 11

emptyMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
GetMetaMethod · 0.80
sizeMethod · 0.80
clearMethod · 0.80
GetPosXMethod · 0.45
GetPosZMethod · 0.45
GetBlockMethod · 0.45
InitializeMethod · 0.45
SetBlockMethod · 0.45

Tested by

no test coverage detected