summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2014-01-27 21:39:00 +0100
committerSTRWarrior <niels.breuker@hotmail.nl>2014-01-27 21:39:00 +0100
commit8bf9043f98900a870c18389fe367e156da6b9f6c (patch)
treecb6d80f46cd79c19afccf73b2029642b53c361ee /src
parentCleanup (diff)
downloadcuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar.gz
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar.bz2
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar.lz
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar.xz
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.tar.zst
cuberite-8bf9043f98900a870c18389fe367e156da6b9f6c.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Villager.cpp11
-rw-r--r--src/Mobs/Villager.h2
2 files changed, 9 insertions, 4 deletions
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index e39d8bc1f..262f13a99 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -50,7 +50,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
{
case vtFarmer:
{
- HandleFarmerNoCountDown();
+ HandleFarmerEndCountDown();
}
}
}
@@ -93,6 +93,8 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
+////////////////////////////////////////////////////////////////////////////////
+// Farmer functions.
void cVillager::HandleFarmerAttemptSpecialAction()
{
cBlockArea Surrounding;
@@ -107,7 +109,6 @@ void cVillager::HandleFarmerAttemptSpecialAction()
(int) GetPosZ() + 5
);
-
for (int I = 0; I < 5; I++)
{
for (int Y = 0; Y < 6; Y++)
@@ -116,6 +117,7 @@ void cVillager::HandleFarmerAttemptSpecialAction()
int X = m_World->GetTickRandomNumber(11);
int Z = m_World->GetTickRandomNumber(11);
+ // A villager can't farm this.
if (!IsBlockFarmable(Surrounding.GetRelBlockType(X, Y, Z)))
{
continue;
@@ -139,8 +141,10 @@ void cVillager::HandleFarmerAttemptSpecialAction()
void cVillager::HandleFarmerAction()
{
+ // 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)
{
+ // Check if the blocks didn't change while the villager was walking to the coordinates.
BLOCKTYPE CropBlock = m_World->GetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z);
if (IsBlockFarmable(CropBlock) && m_World->GetBlockMeta(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z) == 0x7)
{
@@ -155,8 +159,9 @@ void cVillager::HandleFarmerAction()
-void cVillager::HandleFarmerNoCountDown()
+void cVillager::HandleFarmerEndCountDown()
{
+ // 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)
{
m_World->SetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z, E_BLOCK_CROPS, 0);
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index 20dbada61..979d2a3ac 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -39,7 +39,7 @@ public:
// Farmer functions
void HandleFarmerAttemptSpecialAction();
void HandleFarmerAction();
- void HandleFarmerNoCountDown();
+ void HandleFarmerEndCountDown();
// Get and set functions.
int GetVilType(void) const { return m_Type; }