summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2014-01-27 18:58:09 +0100
committerSTRWarrior <niels.breuker@hotmail.nl>2014-01-27 18:58:09 +0100
commit3dbe6c6de941873461951fc2fa8dc1be9d199768 (patch)
tree37f5d2290a2381259c82576a107ce328d31c4a17 /src/Mobs
parentAdded GetCropsPos and DidFindCrops functions. (diff)
downloadcuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar.gz
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar.bz2
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar.lz
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar.xz
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.tar.zst
cuberite-3dbe6c6de941873461951fc2fa8dc1be9d199768.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Villager.cpp37
1 files changed, 19 insertions, 18 deletions
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.
}