Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockGlowstone.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
11  public cBlockHandler
12 {
13 public:
14 
16 
17 private:
18 
19  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
20  {
21  // Drop self only when using silk-touch:
22  if (ToolHasSilkTouch(a_Tool))
23  {
24  return cItem(E_BLOCK_GLOWSTONE);
25  }
26 
27  // Number of dust to drop, capped at the max amount of 4.
28  const auto DropNum = FortuneDiscreteRandom(2, 4, ToolFortuneLevel(a_Tool), 4);
29  return cItem(E_ITEM_GLOWSTONE_DUST, DropNum);
30  }
31 
32 
33 
34 
35 
36  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
37  {
38  UNUSED(a_Meta);
39  return 2;
40  }
41 } ;
42 
43 
44 
45 
@ E_BLOCK_GLOWSTONE
Definition: BlockType.h:104
@ E_ITEM_GLOWSTONE_DUST
Definition: BlockType.h:393
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
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.
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...
static unsigned char ToolFortuneLevel(const cItem *a_Tool)
Returns the fortune level of a tool, if it is a valid tool.
static char FortuneDiscreteRandom(char a_MinDrop, char a_DefaultMax, unsigned char a_BonusMax, char a_DropCap=25)
Returns a random number of drops taking into account fortune.
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
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215