From 3dbe6c6de941873461951fc2fa8dc1be9d199768 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 27 Jan 2014 18:58:09 +0100 Subject: Villager: Farmer: Crops finding is more random. --- src/Mobs/Villager.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/Mobs/Villager.cpp') diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index f52d60ffa..31e6e87a0 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -101,29 +101,30 @@ void cVillager::HandleFarmer() (int) GetPosZ() - 5, (int) GetPosZ() + 5); - // Check for crops in a 10x6x10 area. - for (int X = 0; X < 10; X++) + + for (int I = 0; I < 5; I++) { for (int Y = 0; Y < 6; Y++) { - for (int Z = 0; Z < 10; Z++) + // Pick random coordinates and check for crops. + int X = m_World->GetTickRandomNumber(11); + int Z = m_World->GetTickRandomNumber(11); + + if (!IsBlockFarmable(Surrounding.GetRelBlockType(X, Y, Z))) { - if (!IsBlockFarmable(Surrounding.GetRelBlockType(X, Y, Z))) - { - continue; - } - if (Surrounding.GetRelBlockMeta(X, Y, Z) != 0x7) - { - continue; - } - - m_DidFindCrops = true; - m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5); - MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5))); - return; + continue; } - } - } + if (Surrounding.GetRelBlockMeta(X, Y, Z) != 0x7) + { + continue; + } + + m_DidFindCrops = true; + m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5); + MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5))); + return; + } // for Y loop. + } // Repeat the procces 5 times. } -- cgit v1.2.3