Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemGoldenApple.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemFood.h"
5 
6 
7 
8 
9 
11  public cItemFoodHandler
12 {
14 
15 public:
16 
17  constexpr cItemGoldenAppleHandler(int a_ItemType):
18  Super(a_ItemType, FoodInfo(4, 9.6))
19  {
20  }
21 
22  virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override
23  {
24  cItemHandler::EatItem(a_Player, a_Item);
25 
26  if (!a_Player->IsGameModeCreative())
27  {
28  a_Player->GetInventory().RemoveOneEquippedItem();
29  }
30 
31  // Enchanted golden apples have stronger effects:
33  {
38  return true;
39  }
40 
43 
44  return true;
45  }
46 
47 };
@ E_META_GOLDEN_APPLE_ENCHANTED
Definition: BlockType.h:1064
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
Applies an entity effect.
Definition: Pawn.cpp:186
Definition: Player.h:29
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
Definition: Player.cpp:1025
cInventory & GetInventory(void)
Definition: Player.h:156
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
Definition: Inventory.cpp:232
Definition: Item.h:37
short m_ItemDamage
Definition: Item.h:165
constexpr cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo)
Definition: ItemFood.h:17
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item) const override
Lets the player eat a selected item.
constexpr cItemGoldenAppleHandler(int a_ItemType)
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item) const
Lets the player eat a selected item.