From babc80ed777f2ee74ce770d95bd3ec5743370570 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 27 Jan 2014 22:02:19 +0100 Subject: [PATCH] The world can now be configured wether farmers should be able to harvest crops. --- src/Mobs/Villager.cpp | 10 ++++++++++ src/World.cpp | 1 + src/World.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 262f13a99..74a2a6d99 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -141,6 +141,11 @@ void cVillager::HandleFarmerAttemptSpecialAction() void cVillager::HandleFarmerAction() { + if (!m_World->VillagersShouldHarvestCrops()) + { + return; + } + // Harvest the crops if the villager isn't moving and if the crops are closer then 2 blocks. if (!m_bMovingToDestination && (GetPosition() - m_CropsPos).Length() < 2) { @@ -161,6 +166,11 @@ void cVillager::HandleFarmerAction() void cVillager::HandleFarmerEndCountDown() { + if (!m_World->VillagersShouldHarvestCrops()) + { + return; + } + // Check if there is still farmland at the spot where the crops were. if (m_World->GetBlock(m_CropsPos.x, m_CropsPos.y - 1, m_CropsPos.z) == E_BLOCK_FARMLAND) { diff --git a/src/World.cpp b/src/World.cpp index 5205c2616..88bbf5f8a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -547,6 +547,7 @@ void cWorld::Start(void) m_IsDeepSnowEnabled = IniFile.GetValueSetB("Physics", "DeepSnow", false); m_ShouldLavaSpawnFire = IniFile.GetValueSetB("Physics", "ShouldLavaSpawnFire", true); m_bCommandBlocksEnabled = IniFile.GetValueSetB("Mechanics", "CommandBlocksEnabled", false); + m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true); m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode); diff --git a/src/World.h b/src/World.h index d7a7241d1..4d5659ee6 100644 --- a/src/World.h +++ b/src/World.h @@ -138,6 +138,8 @@ public: bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; } + bool VillagersShouldHarvestCrops(void) const { return m_VillagersShouldHarvestCrops; } + eDimension GetDimension(void) const { return m_Dimension; } /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */ @@ -743,6 +745,7 @@ private: bool m_bEnabledPVP; bool m_IsDeepSnowEnabled; bool m_ShouldLavaSpawnFire; + bool m_VillagersShouldHarvestCrops; std::vector m_BlockTickQueue; std::vector m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue