diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-07 12:08:57 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-07 12:08:57 +0200 |
commit | 7b42204b245e558c0f0d330acd5a642582dd7991 (patch) | |
tree | 486bf642c5c2ec077f58e22a9ac8398e6b12c3bf /source/Chunk.cpp | |
parent | CryptoPP compilation fixes for gcc 4.7 (diff) | |
download | cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar.gz cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar.bz2 cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar.lz cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar.xz cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.tar.zst cuberite-7b42204b245e558c0f0d330acd5a642582dd7991.zip |
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r-- | source/Chunk.cpp | 100 |
1 files changed, 5 insertions, 95 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 50bba66cf..0dec50230 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -530,107 +530,17 @@ void cChunk::TickBlocks(MTRand & a_TickRandom) continue; // It's all air up here } - unsigned int Index = MakeIndexNoCheck( m_BlockTickX, m_BlockTickY, m_BlockTickZ ); - BLOCKTYPE BlockType = m_BlockTypes[Index]; - switch (BlockType) - { - case E_BLOCK_FARMLAND: TickFarmland (m_BlockTickX, m_BlockTickY, m_BlockTickZ); break; - - default: - { - cBlockHandler * Handler = BlockHandler(BlockType); - ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(m_World, m_BlockTickX + m_PosX * Width, m_BlockTickY, m_BlockTickZ + m_PosZ * Width); - break; - } - } - } -} - - - - - -void cChunk::TickFarmland(int a_RelX, int a_RelY, int a_RelZ) -{ - // TODO: Rain hydrates blocks, too. Check world weather, don't search for water if raining. - // NOTE: The desert biomes do not get precipitation, so another check needs to be made. - - // Search for water in a close proximity: - // Ref.: http://www.minecraftwiki.net/wiki/Farmland#Hydrated_Farmland_Tiles - bool Found = false; - for (int y = a_RelY; y <= a_RelY + 1; y++) - { - for (int z = a_RelZ - 4; z <= a_RelZ + 4; z++) - { - for (int x = a_RelX - 4; x <= a_RelX + 4; x++) - { - BLOCKTYPE BlockType; - NIBBLETYPE Meta; // unused - - if (!UnboundedRelGetBlock(x, y, z, BlockType, Meta)) - { - // Too close to an unloaded chunk, we might miss a water block there, so don't tick at all - return; - } - if ( - (BlockType == E_BLOCK_WATER) || - (BlockType == E_BLOCK_STATIONARY_WATER) - ) - { - Found = true; - break; - } - } // for x - if (Found) - { - break; - } - } // for z - if (Found) - { - break; - } - } // for y - - NIBBLETYPE BlockMeta = GetMeta(a_RelX, a_RelY, a_RelZ); - - if (Found) - { - // Water was found, hydrate the block until hydration reaches 7: - if (BlockMeta < 7) - { - FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_FARMLAND, ++BlockMeta); - } - return; - } - - // Water wasn't found, de-hydrate block: - if (BlockMeta > 0) - { - FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_FARMLAND, --BlockMeta); - return; - } - - // Farmland too dry. If nothing is growing on top, turn back to dirt: - - switch (GetBlock(a_RelX, a_RelY + 1, a_RelZ)) - { - case E_BLOCK_CROPS: - case E_BLOCK_MELON_STEM: - case E_BLOCK_PUMPKIN_STEM: - break; - default: - FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, 0); - break; - } + unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); + cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); + ASSERT(Handler != NULL); // Happenned on server restart, FS #243 + Handler->OnUpdate(m_World, m_BlockTickX + m_PosX * Width, m_BlockTickY, m_BlockTickZ + m_PosZ * Width); + } // for i - tickblocks } - void cChunk::GrowMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, MTRand & a_TickRandom) { // Convert the stem BlockType into produce BlockType |