Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockCarpet.h
Go to the documentation of this file.
1 
2 // BlockCarpet.h
3 
4 // Declares the cBlockCarpetHandler class representing the handler for the carpet block
5 
6 
7 
8 
9 #pragma once
10 
11 #include "BlockHandler.h"
12 
13 
14 
15 
16 
18  public cBlockHandler
19 {
21 
22 public:
23 
25  super(a_BlockType)
26  {
27  }
28 
29 
30 
31 
32 
34  cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
35  int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
36  int a_CursorX, int a_CursorY, int a_CursorZ,
37  BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
38  ) override
39  {
40  a_BlockType = m_BlockType;
41  a_BlockMeta = a_Player.GetEquippedItem().m_ItemDamage & 0x0f;
42  return true;
43  }
44 
45 
46 
47 
48 
49  virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
50  {
51  return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR);
52  }
53 
54 
55 
56 
57 
58  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
59  {
60  switch (a_Meta)
61  {
62  case E_META_CARPET_WHITE: return 14;
63  case E_META_CARPET_ORANGE: return 15;
64  case E_META_CARPET_MAGENTA: return 16;
65  case E_META_CARPET_LIGHTBLUE: return 17;
66  case E_META_CARPET_YELLOW: return 18;
67  case E_META_CARPET_LIGHTGREEN: return 19;
68  case E_META_CARPET_PINK: return 20;
69  case E_META_CARPET_GRAY: return 21;
70  case E_META_CARPET_LIGHTGRAY: return 22;
71  case E_META_CARPET_CYAN: return 23;
72  case E_META_CARPET_PURPLE: return 24;
73  case E_META_CARPET_BLUE: return 25;
74  case E_META_CARPET_BROWN: return 26;
75  case E_META_CARPET_GREEN: return 27;
76  case E_META_CARPET_RED: return 28;
77  case E_META_CARPET_BLACK: return 29;
78  default:
79  {
80  ASSERT(!"Unhandled meta in carpet handler!");
81  return 0;
82  }
83  }
84  }
85 } ;
86 
87 
88 
89 
cBlockCarpetHandler(BLOCKTYPE a_BlockType)
Definition: BlockCarpet.h:24
short m_ItemDamage
Definition: Item.h:211
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
const cItem & GetEquippedItem(void) const
Definition: Player.h:142
Definition: Player.h:27
cBlockHandler(BLOCKTYPE a_BlockType)
BLOCKTYPE m_BlockType
Definition: BlockHandler.h:213
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
Definition: Chunk.h:49
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: BlockCarpet.h:58
virtual bool CanBeAt(cChunkInterface &a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk &a_Chunk) override
Checks if the block can stay at the specified relative coords in the chunk.
Definition: BlockCarpet.h:49
#define ASSERT(x)
Definition: Globals.h:335
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:177
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: BlockCarpet.h:33
Byte ColourID
Definition: Globals.h:118