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:
15  : cBlockHandler(a_BlockType)
16  {
17  }
18 
19 
20 
21 
22 
23  virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
24  {
25  // Drop self only when using silk-touch:
26  if (ToolHasSilkTouch(a_Tool))
27  {
28  return cItem(E_BLOCK_GLOWSTONE, 1, 0);
29  }
30  else
31  {
32  // TODO: Handle the Fortune enchantment here
33  return cItem(E_ITEM_GLOWSTONE_DUST, GetRandomProvider().RandInt<char>(2, 4), 0);
34  }
35  }
36 
37 
38 
39 
40 
41  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
42  {
43  UNUSED(a_Meta);
44  return 2;
45  }
46 } ;
47 
48 
49 
50 
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
MTRand & GetRandomProvider()
Returns the current thread&#39;s random number source.
Definition: FastRandom.cpp:20
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
static bool ToolHasSilkTouch(const cItem *a_Tool)
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
cBlockGlowstoneHandler(BLOCKTYPE a_BlockType)
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity *a_BlockEntity, const cEntity *a_Digger, const cItem *a_Tool) override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
#define UNUSED
Definition: Globals.h:152
Byte ColourID
Definition: Globals.h:118
Definition: Entity.h:73
Definition: Item.h:36
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234