Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockStone.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 class cBlockStoneHandler final :
10  public cBlockHandler
11 {
13 
14 public:
15 
16  using Super::Super;
17 
18 private:
19 
20  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
21  {
22  // Convert stone to cobblestone, unless using silk-touch:
23  if (
24  (a_BlockMeta == E_META_STONE_STONE) &&
25  !ToolHasSilkTouch(a_Tool)
26  )
27  {
28  return cItem(E_BLOCK_COBBLESTONE, 1, 0);
29  }
30  return cItem(m_BlockType, 1, a_BlockMeta);
31  }
32 
33 
34 
35 
36 
37  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
38  {
39  UNUSED(a_Meta);
40  return 11;
41  }
42 };
43 
44 
45 
46 
@ E_META_STONE_STONE
Definition: BlockType.h:905
@ E_BLOCK_COBBLESTONE
Definition: BlockType.h:14
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
Byte ColourID
Definition: Globals.h:162
#define UNUSED
Definition: Globals.h:72
static bool ToolHasSilkTouch(const cItem *a_Tool)
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
const BLOCKTYPE m_BlockType
Definition: BlockHandler.h:205
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
Definition: BlockStone.h:20
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
Definition: BlockStone.h:37
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215