From 0e1e76fa7717a73268cec2534a6dc5c5ff24dc11 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 3 Oct 2013 21:35:17 -0600 Subject: Rain now waters farmland. --- source/Blocks/BlockFarmland.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/Blocks/BlockFarmland.h') diff --git a/source/Blocks/BlockFarmland.h b/source/Blocks/BlockFarmland.h index 6cab1fa38..16d94d435 100644 --- a/source/Blocks/BlockFarmland.h +++ b/source/Blocks/BlockFarmland.h @@ -42,6 +42,9 @@ public: return; } bool Found = false; + + if (a_World->GetWeather() != eWeather_Rain || a_World->GetBiomeAt(a_BlockX, a_BlockZ) == 1) + { int NumBlocks = Area.GetBlockCount(); BLOCKTYPE * BlockTypes = Area.GetBlockTypes(); for (int i = 0; i < NumBlocks; i++) @@ -55,6 +58,11 @@ public: break; } } + } + else + { + Found = true; + } NIBBLETYPE BlockMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); -- cgit v1.2.3 From d1448d12a052b1ab9edf22447cff621c7e171593 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 3 Oct 2013 21:39:07 -0600 Subject: Added comparison for desert biomes. --- source/Blocks/BlockFarmland.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Blocks/BlockFarmland.h') diff --git a/source/Blocks/BlockFarmland.h b/source/Blocks/BlockFarmland.h index 16d94d435..5aef10556 100644 --- a/source/Blocks/BlockFarmland.h +++ b/source/Blocks/BlockFarmland.h @@ -43,7 +43,8 @@ public: } bool Found = false; - if (a_World->GetWeather() != eWeather_Rain || a_World->GetBiomeAt(a_BlockX, a_BlockZ) == 1) + 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(); -- cgit v1.2.3 From 8fb80b636984d20327e0bf043e451f4ecbb3e582 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Oct 2013 08:39:59 +0200 Subject: Optimized cBlockFarmlandHandler in wet weather. The area isn't read at all when the weather is wet, since it isn't needed. --- source/Blocks/BlockFarmland.h | 53 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'source/Blocks/BlockFarmland.h') 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); -- cgit v1.2.3