Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockQuartz.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
11 {
12 public:
14  : cBlockHandler(a_BlockType)
15  {
16  }
17 
19  cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
20  int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
21  int a_CursorX, int a_CursorY, int a_CursorZ,
22  BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
23  ) override
24  {
25  a_BlockType = m_BlockType;
26  NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
27 
28  if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
29  {
30  a_BlockMeta = Meta;
31  return true;
32  }
33 
34  a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta);
35  return true;
36  }
37 
38  inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta)
39  {
40  switch (a_BlockFace)
41  {
42  case BLOCK_FACE_YM:
43  case BLOCK_FACE_YP:
44  {
45  return a_QuartzMeta; // Top or bottom, just return original
46  }
47 
48  case BLOCK_FACE_ZP:
49  case BLOCK_FACE_ZM:
50  {
51  return 0x4; // North or south
52  }
53 
54  case BLOCK_FACE_XP:
55  case BLOCK_FACE_XM:
56  {
57  return 0x3; // East or west
58  }
59 
60  case BLOCK_FACE_NONE:
61  {
62  ASSERT(!"Unhandled block face!");
63  return a_QuartzMeta; // No idea, give a special meta (all sides the same)
64  }
65  }
66  UNREACHABLE("Unsupported block face");
67  }
68 
69  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
70  {
71  UNUSED(a_Meta);
72  return 8;
73  }
74 } ;
static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta)
Definition: BlockQuartz.h:38
virtual bool GetPlacementBlockTypeMeta(cChunkInterface &a_ChunkInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) override
Called before a block is placed into a world.
Definition: BlockQuartz.h:18
short m_ItemDamage
Definition: Item.h:211
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
cBlockQuartzHandler(BLOCKTYPE a_BlockType)
Definition: BlockQuartz.h:13
const cItem & GetEquippedItem(void) const
Definition: Player.h:142
Definition: Player.h:27
BLOCKTYPE m_BlockType
Definition: BlockHandler.h:213
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
#define ASSERT(x)
Definition: Globals.h:335
#define UNUSED
Definition: Globals.h:152
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
Byte ColourID
Definition: Globals.h:118
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...
Definition: BlockQuartz.h:69
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.
Definition: Globals.h:344