Cuberite
A lightweight, fast and extensible game server for Minecraft
Villager.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "PassiveMonster.h"
5 #include "../Blocks/ChunkInterface.h"
6 
7 
8 
9 
10 class cVillager :
11  public cPassiveMonster
12 {
14 
15 public:
16 
18  {
19  vtFarmer = 0,
21  vtPriest = 2,
23  vtButcher = 4,
24  vtGeneric = 5,
26  } ;
27 
28  cVillager(eVillagerType VillagerType);
29 
31 
32  // cEntity overrides
33  virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
34  virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
35 
36  // cVillager functions
38  bool IsBlockFarmable(BLOCKTYPE a_BlockType);
39 
40  // Farmer functions
43 
46 
49 
50  // Get and set functions.
51  int GetVilType(void) const { return m_Type; }
52  Vector3i GetCropsPos(void) const { return m_CropsPos; }
53  bool DoesHaveActionActivated(void) const { return m_VillagerAction; }
54 
55 private:
56 
58  int m_Type;
61 
62 } ;
63 
64 
65 
66 
Vector3i GetCropsPos(void) const
Definition: Villager.h:52
Definition: FastNBT.h:131
int m_ActionCountDown
Definition: Villager.h:57
void HandleFarmerPrepareFarmCrops()
Searches in a 11x7x11 area for crops.
Definition: Villager.cpp:113
void HandleFarmerTryHarvestCrops()
Looks if the farmer has reached it's destination, and if it's still crops and the destination is clos...
Definition: Villager.cpp:163
bool IsBlockFarmable(BLOCKTYPE a_BlockType)
return true if the given blocktype are: crops, potatoes or carrots.
Definition: Villager.cpp:195
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
Definition: Chunk.h:49
cVillager(eVillagerType VillagerType)
Definition: Villager.cpp:14
int GetVilType(void) const
Definition: Villager.h:51
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
When hit by someone, run away.
Definition: Villager.cpp:26
void HandleFarmerPlaceCrops()
Replaces the crops he harvested.
Definition: Villager.cpp:182
bool m_VillagerAction
Definition: Villager.h:59
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Villager.cpp:54
eVillagerType
Definition: Villager.h:17
bool DoesHaveActionActivated(void) const
Definition: Villager.h:53
int m_Type
Definition: Villager.h:58
cPassiveMonster super
Definition: Villager.h:13
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
Vector3i m_CropsPos
Definition: Villager.h:60