diff options
author | madmaxoft <github@xoft.cz> | 2013-10-06 15:44:14 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-06 15:44:14 +0200 |
commit | dabbf24f587d6c946b84620fb6a86e9b587a23b8 (patch) | |
tree | 7615b6f1c6030b15a67528e84d9740639adbd344 /source/Blocks/BlockFarmland.h | |
parent | Removed remnants of the old webserver. (diff) | |
parent | APIDump: Brought cItem docs up-to-date. (diff) | |
download | cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar.gz cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar.bz2 cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar.lz cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar.xz cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.tar.zst cuberite-dabbf24f587d6c946b84620fb6a86e9b587a23b8.zip |
Diffstat (limited to 'source/Blocks/BlockFarmland.h')
-rw-r--r-- | source/Blocks/BlockFarmland.h | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/source/Blocks/BlockFarmland.h b/source/Blocks/BlockFarmland.h index 6cab1fa38..7bc71f7f3 100644 --- a/source/Blocks/BlockFarmland.h +++ b/source/Blocks/BlockFarmland.h @@ -30,30 +30,38 @@ public: virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override { - // TODO: Rain hydrates farmland, 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. + bool Found = false; - // Search for water in a close proximity: - // Ref.: http://www.minecraftwiki.net/wiki/Farmland#Hydrated_Farmland_Tiles - cBlockArea Area; - if (!Area.Read(a_World, a_BlockX - 4, a_BlockX + 4, a_BlockY, a_BlockY + 1, a_BlockZ - 4, a_BlockZ + 4)) + int Biome = a_World->GetBiomeAt(a_BlockX, a_BlockZ); + if (a_World->IsWeatherWet() && (Biome != biDesert) && (Biome != biDesertHills)) { - // Too close to the world edge, cannot check surroudnings; don't tick at all - return; + // Rain hydrates farmland, too, except in Desert biomes. + Found = true; } - bool Found = false; - int NumBlocks = Area.GetBlockCount(); - BLOCKTYPE * BlockTypes = Area.GetBlockTypes(); - for (int i = 0; i < NumBlocks; i++) + else { - if ( - (BlockTypes[i] == E_BLOCK_WATER) || - (BlockTypes[i] == E_BLOCK_STATIONARY_WATER) - ) + // Search for water in a close proximity: + // Ref.: http://www.minecraftwiki.net/wiki/Farmland#Hydrated_Farmland_Tiles + cBlockArea Area; + if (!Area.Read(a_World, a_BlockX - 4, a_BlockX + 4, a_BlockY, a_BlockY + 1, a_BlockZ - 4, a_BlockZ + 4)) { - Found = true; - break; + // Too close to the world edge, cannot check surroudnings; don't tick at all + return; } + + int NumBlocks = Area.GetBlockCount(); + BLOCKTYPE * BlockTypes = Area.GetBlockTypes(); + for (int i = 0; i < NumBlocks; i++) + { + if ( + (BlockTypes[i] == E_BLOCK_WATER) || + (BlockTypes[i] == E_BLOCK_STATIONARY_WATER) + ) + { + Found = true; + break; + } + } // for i - BlockTypes[] } NIBBLETYPE BlockMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); |