Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockSeaLantern.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 {
14 
15 public:
16 
17  using Super::Super;
18 
19 private:
20 
21  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
22  {
23  // Drop self only when using silk-touch:
24  if (ToolHasSilkTouch(a_Tool))
25  {
26  return cItem(E_BLOCK_SEA_LANTERN);
27  }
28 
29  // Number of crystals to drop, capped at the max amount of 5.
30  const auto DropNum = FortuneDiscreteRandom(2, 3, ToolFortuneLevel(a_Tool), 5);
31  return cItem(E_ITEM_PRISMARINE_CRYSTALS, DropNum);
32  }
33 } ;
BlockHandler.h
cBlockHandler::ToolHasSilkTouch
static bool ToolHasSilkTouch(const cItem *a_Tool)
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
Definition: BlockHandler.cpp:593
cBlockHandler
Definition: BlockHandler.h:25
NIBBLETYPE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
E_ITEM_PRISMARINE_CRYSTALS
@ E_ITEM_PRISMARINE_CRYSTALS
Definition: BlockType.h:456
cBlockHandler::FortuneDiscreteRandom
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.
Definition: BlockHandler.cpp:618
cItem
Definition: Item.h:36
cItems
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:213
E_BLOCK_SEA_LANTERN
@ E_BLOCK_SEA_LANTERN
Definition: BlockType.h:188
cBlockSeaLanternHandler
Definition: BlockSeaLantern.h:10
cBlockSeaLanternHandler::ConvertToPickups
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: BlockSeaLantern.h:21
cBlockHandler::ToolFortuneLevel
static unsigned char ToolFortuneLevel(const cItem *a_Tool)
Returns the fortune level of a tool, if it is a valid tool.
Definition: BlockHandler.cpp:602
cBlockHandler::cBlockHandler
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29