Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockCobWeb.h
Go to the documentation of this file.
1 
2 // BlockCobWeb.h
3 
4 // Declares the cBlockCobWebHandler object representing the BlockHandler for cobwebs
5 
6 #pragma once
7 
8 
9 
10 
11 
12 class cBlockCobWebHandler final :
13  public cBlockHandler
14 {
15 public:
16 
18 
19 private:
20 
21  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
22  {
23  // Silk touch gives cobweb, anything else gives just string:
24  if (ToolHasSilkTouch(a_Tool))
25  {
26  return cItem(m_BlockType, 1, 0);
27  }
28  else
29  {
30  return cItem(E_ITEM_STRING, 1, 0);
31  }
32  }
33 
34 
35 
36 
37 
38  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
39  {
40  UNUSED(a_Meta);
41  return 3;
42  }
43 } ;
44 
45 
46 
47 
@ E_ITEM_STRING
Definition: BlockType.h:331
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 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: BlockCobWeb.h:38
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: BlockCobWeb.h:21
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
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215