Cuberite
A lightweight, fast and extensible game server for Minecraft
Horse.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "PassiveMonster.h"
5 #include "../UI/WindowOwner.h"
6 
7 
8 
9 
10 
11 class cHorse :
12  public cPassiveMonster,
13  public cEntityWindowOwner
14 {
16 
17 public:
18  cHorse(int Type, int Color, int Style, int TameTimes);
19  virtual ~cHorse() override;
20 
22 
23  virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
24  virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
25  virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
26  virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
27  virtual void OnRightClicked(cPlayer & a_Player) override;
28 
29  bool IsSaddled (void) const {return !m_Saddle.IsEmpty(); }
30  bool IsChested (void) const {return m_bHasChest; }
31  bool IsEating (void) const {return m_bIsEating; }
32  bool IsRearing (void) const {return m_bIsRearing; }
33  bool IsMthOpen (void) const {return m_bIsMouthOpen; }
34  bool IsTame (void) const override {return m_bIsTame; }
35  int GetHorseType (void) const {return m_Type; }
36  int GetHorseColor (void) const {return m_Color; }
37  int GetHorseStyle (void) const {return m_Style; }
38  int GetHorseArmour (void) const;
39 
42  void SetHorseSaddle(cItem a_SaddleItem);
43 
46  void SetHorseArmor(cItem a_ArmorItem);
47 
48  const cItem & GetHorseSaddle() const { return m_Saddle; }
49  const cItem & GetHorseArmorItem() const { return m_Armor; }
50 
51  virtual void GetBreedingItems(cItems & a_Items) override
52  {
53  a_Items.Add(E_ITEM_GOLDEN_CARROT);
54  a_Items.Add(E_ITEM_GOLDEN_APPLE);
55  }
56 
57  void PlayerOpenWindow(cPlayer & a_Player);
58 
59 private:
60 
63  float m_MaxSpeed;
66 
67 } ;
68 
69 
70 
71 
Definition: FastNBT.h:131
int m_TameAttemptTimes
Definition: Horse.h:62
virtual void GetBreedingItems(cItems &a_Items) override
Returns the items that make the animal breed - this is usually the same as the ones that make the ani...
Definition: Horse.h:51
Definition: Player.h:27
bool IsEmpty(void) const
Definition: Item.h:116
cHorse(int Type, int Color, int Style, int TameTimes)
Definition: Horse.cpp:13
bool IsTame(void) const override
Definition: Horse.h:34
bool IsRearing(void) const
Definition: Horse.h:32
bool m_bIsTame
Definition: Horse.h:61
Definition: Horse.h:11
void SetHorseSaddle(cItem a_SaddleItem)
Set the horse's saddle to the given item.
Definition: Horse.cpp:184
bool m_bIsMouthOpen
Definition: Horse.h:61
int GetHorseColor(void) const
Definition: Horse.h:36
bool IsEating(void) const
Definition: Horse.h:31
Definition: Chunk.h:49
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Horse.cpp:270
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
Definition: Horse.cpp:243
void SetHorseArmor(cItem a_ArmorItem)
Set the horse's armor slot to the given item.
Definition: Horse.cpp:203
bool IsSaddled(void) const
Definition: Horse.h:29
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override
Definition: Horse.cpp:283
int m_Type
Definition: Horse.h:62
void Add(const cItem &a_Item)
Definition: Item.h:254
cItem m_Saddle
Definition: Horse.h:64
int GetHorseArmour(void) const
Definition: Horse.cpp:222
int GetHorseStyle(void) const
Definition: Horse.h:37
int m_RearTickCount
Definition: Horse.h:62
int m_Style
Definition: Horse.h:62
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Definition: Horse.cpp:48
bool IsChested(void) const
Definition: Horse.h:30
const cItem & GetHorseSaddle() const
Definition: Horse.h:48
const cItem & GetHorseArmorItem() const
Definition: Horse.h:49
int m_Color
Definition: Horse.h:62
bool m_bIsEating
Definition: Horse.h:61
cPassiveMonster super
Definition: Horse.h:15
bool IsMthOpen(void) const
Definition: Horse.h:33
void PlayerOpenWindow(cPlayer &a_Player)
Definition: Horse.cpp:295
Definition: Entity.h:73
virtual ~cHorse() override
Definition: Horse.cpp:35
float m_MaxSpeed
Definition: Horse.h:63
int m_TimesToTame
Definition: Horse.h:62
bool m_bIsRearing
Definition: Horse.h:61
#define CLASS_PROTODEF(classname)
Definition: Entity.h:11
cItem m_Armor
Definition: Horse.h:65
int GetHorseType(void) const
Definition: Horse.h:35
Definition: Item.h:36
Window owner that is associated with an entity (chest minecart etc.)
Definition: WindowOwner.h:80
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
Definition: Horse.cpp:117
bool m_bHasChest
Definition: Horse.h:61