Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemMap.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "../Item.h"
5 
6 
7 
8 
9 
10 class cItemMapHandler final:
11  public cItemHandler
12 {
14 
15  static const unsigned int DEFAULT_RADIUS = 128;
16 
17 public:
18 
19  using Super::Super;
20 
21  virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) const override
22  {
23  cMap * Map = a_World->GetMapManager().GetMapData(static_cast<unsigned>(a_Item.m_ItemDamage));
24 
25  if (Map == nullptr)
26  {
27  return;
28  }
29 
30  Map->UpdateRadius(*a_Player, DEFAULT_RADIUS);
31  Map->UpdateClient(a_Player);
32  }
33 } ;
Definition: Player.h:29
Definition: Item.h:37
short m_ItemDamage
Definition: Item.h:165
constexpr cItemHandler(int a_ItemType)
Definition: ItemHandler.h:37
virtual void OnUpdate(cWorld *a_World, cPlayer *a_Player, const cItem &a_Item) const override
Called every tick while the item is on the player's inventory (used by maps, for example) - For now,...
Definition: ItemMap.h:21
static const unsigned int DEFAULT_RADIUS
Definition: ItemMap.h:15
Encapsulates an in-game world map.
Definition: Map.h:83
cMap * GetMapData(unsigned int a_ID)
Returns the map with the specified ID, nullptr if out of range.
Definition: MapManager.cpp:58
Definition: World.h:53
cMapManager & GetMapManager(void)
Returns the associated map manager instance.
Definition: World.h:703