summaryrefslogtreecommitdiffstats
path: root/source/Blocks/BlockFarmland.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-04 08:39:59 +0200
committermadmaxoft <github@xoft.cz>2013-10-04 08:39:59 +0200
commit8fb80b636984d20327e0bf043e451f4ecbb3e582 (patch)
treeb8ac0b13eddcd0588ee79acb7871a0ac22b00a59 /source/Blocks/BlockFarmland.h
parentAdded cWorld::IsWeatherXXX() functions (diff)
downloadcuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar.gz
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar.bz2
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar.lz
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar.xz
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.tar.zst
cuberite-8fb80b636984d20327e0bf043e451f4ecbb3e582.zip
Diffstat (limited to 'source/Blocks/BlockFarmland.h')
-rw-r--r--source/Blocks/BlockFarmland.h53
1 files changed, 26 insertions, 27 deletions
diff --git a/source/Blocks/BlockFarmland.h b/source/Blocks/BlockFarmland.h
index 5aef10556..7bc71f7f3 100644
--- a/source/Blocks/BlockFarmland.h
+++ b/source/Blocks/BlockFarmland.h
@@ -30,39 +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.
-
- // 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))
- {
- // Too close to the world edge, cannot check surroudnings; don't tick at all
- return;
- }
bool Found = false;
-
+
int Biome = a_World->GetBiomeAt(a_BlockX, a_BlockZ);
- if (a_World->GetWeather() != eWeather_Rain || Biome == biDesert || Biome == biDesertHills)
- {
- int NumBlocks = Area.GetBlockCount();
- BLOCKTYPE * BlockTypes = Area.GetBlockTypes();
- for (int i = 0; i < NumBlocks; i++)
+ if (a_World->IsWeatherWet() && (Biome != biDesert) && (Biome != biDesertHills))
{
- if (
- (BlockTypes[i] == E_BLOCK_WATER) ||
- (BlockTypes[i] == E_BLOCK_STATIONARY_WATER)
- )
- {
- Found = true;
- break;
- }
- }
+ // Rain hydrates farmland, too, except in Desert biomes.
+ Found = true;
}
else
{
- Found = true;
+ // 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))
+ {
+ // 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);