Cuberite
A lightweight, fast and extensible game server for Minecraft
Rabbit.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
4 #include "Rabbit.h"
5 #include "../Entities/Player.h"
6 #include "../World.h"
7 
8 
9 
10 
11 
13  cRabbit(static_cast<eRabbitType>(GetRandomProvider().RandInt<UInt8>(
14  static_cast<UInt8>(eRabbitType::SaltAndPepper) // Max possible Rabbit-Type
15  )), 0)
16 {
17 }
18 
19 
20 
21 
22 
23 cRabbit::cRabbit(eRabbitType Type, int MoreCarrotTicks) :
24  Super("Rabbit", mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", "entity.rabbit.ambient", 0.4f, 0.5f),
25  m_Type(Type),
26  m_MoreCarrotTicks(MoreCarrotTicks)
27 {
28 }
29 
30 
31 
32 
33 
34 void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer)
35 {
36  if (IsBaby())
37  {
38  return; // Babies don't drop items
39  }
40 
41  unsigned int LootingLevel = 0;
42  if (a_Killer != nullptr)
43  {
45  }
46  AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_RABBIT : E_ITEM_RAW_RABBIT);
47  AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RABBIT_HIDE);
48  cItems RareDrops;
49  RareDrops.Add(cItem(E_ITEM_RABBITS_FOOT));
50  AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
51 }
52 
@ E_ITEM_RAW_RABBIT
Definition: BlockType.h:457
@ E_ITEM_COOKED_RABBIT
Definition: BlockType.h:458
@ E_ITEM_RABBITS_FOOT
Definition: BlockType.h:460
@ E_ITEM_RABBIT_HIDE
Definition: BlockType.h:461
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Definition: FastRandom.cpp:12
unsigned char UInt8
Definition: Globals.h:159
eMonsterType m_Type
Definition: Monster.cpp:35
@ mtRabbit
Definition: MonsterTypes.h:53
eRabbitType
Definition: Rabbit.h:11
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
Definition: Entity.h:76
virtual bool IsOnFire(void) const
Definition: Entity.h:489
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
Definition: Entity.h:333
Definition: Item.h:37
cEnchantments m_Enchantments
Definition: Item.h:166
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
void Add(const cItem &a_Item)
Definition: Item.h:233
void AddRandomRareDropItem(cItems &a_Drops, cItems &a_Items, unsigned int a_LootingLevel)
Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel...
Definition: Monster.cpp:1549
void AddRandomDropItem(cItems &a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth=0)
Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops.
Definition: Monster.cpp:1518
bool IsBaby(void) const
Definition: Monster.h:156
Definition: Rabbit.h:27
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
Definition: Rabbit.cpp:34
cRabbit()
Definition: Rabbit.cpp:12