Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockHugeMushroom.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
12  public cBlockHandler
13 {
15 
16 public:
17 
18  using Super::Super;
19 
20 private:
21 
22  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
23  {
24  if (ToolHasSilkTouch(a_Tool))
25  {
26  return cItem(m_BlockType);
27  }
28  else if ((a_BlockMeta == E_META_MUSHROOM_FULL_STEM) || (a_BlockMeta == E_META_MUSHROOM_STEM))
29  {
30  // Stems don't drop anything
31  return cItem();
32  }
33 
35  const auto DropNum = GetRandomProvider().RandInt<char>(2);
36 
37  return cItem(MushroomType, DropNum);
38  }
39 
40 
41 
42 
43 
44  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
45  {
46  UNUSED(a_Meta);
47  return (m_BlockType == E_BLOCK_HUGE_BROWN_MUSHROOM) ? 10 : 28;
48  }
49 } ;
50 
51 
52 
53 
@ E_META_MUSHROOM_STEM
Definition: BlockType.h:726
@ E_META_MUSHROOM_FULL_STEM
Definition: BlockType.h:728
@ E_BLOCK_BROWN_MUSHROOM
Definition: BlockType.h:49
@ E_BLOCK_HUGE_BROWN_MUSHROOM
Definition: BlockType.h:114
@ E_BLOCK_RED_MUSHROOM
Definition: BlockType.h:50
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Definition: FastRandom.cpp:12
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
Handler for huge mushroom blocks.
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...
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
Definition: FastRandom.h:78
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215