Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockStairs.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "Mixins.h"
6 
7 
8 
9 
10 class cBlockStairsHandler final :
11  public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x02, 0x01, true>>
12 {
14 
15 public:
16 
17  using Super::Super;
18 
19  static bool IsAnyStairType(BLOCKTYPE a_Block)
20  {
21  switch (a_Block)
22  {
37  return true;
38  default:
39  {
40  return false;
41  }
42  }
43  }
44 
45 private:
46 
47  virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override
48  {
49  // Toggle bit 3:
50  return (a_Meta & 0x0b) | ((~a_Meta) & 0x04);
51  }
52 
53 
54  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
55  {
56  UNUSED(a_Meta);
57  switch (m_BlockType)
58  {
60  case E_BLOCK_BIRCH_WOOD_STAIRS: return 2;
61  case E_BLOCK_QUARTZ_STAIRS: return 8;
63  case E_BLOCK_RED_SANDSTONE_STAIRS: return 10;
65  case E_BLOCK_STONE_BRICK_STAIRS: return 11;
66  case E_BLOCK_OAK_WOOD_STAIRS: return 13;
67  case E_BLOCK_ACACIA_WOOD_STAIRS: return 15;
68  case E_BLOCK_PURPUR_STAIRS: return 16;
69  case E_BLOCK_DARK_OAK_WOOD_STAIRS: return 26;
70  case E_BLOCK_BRICK_STAIRS: return 28;
71  case E_BLOCK_NETHER_BRICK_STAIRS: return 35;
72  case E_BLOCK_SPRUCE_WOOD_STAIRS: return 34;
73  default:
74  {
75  ASSERT(!"Unhandled blocktype in stairs handler!");
76  return 0;
77  }
78  }
79  }
80 
81 
82 
83 
84 
89  #if 0
90  bool IsInsideBlock(Vector3d a_RelPosition, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta)
91  {
92  if (a_BlockMeta & 0x4) // upside down
93  {
94  return true;
95  }
96  else if ((a_BlockMeta & 0x3) == 0) // tall side is east (+X)
97  {
98  return (a_RelPosition.y < ((a_RelPosition.x > 0.5) ? 1.0 : 0.5));
99  }
100  else if ((a_BlockMeta & 0x3) == 1) // tall side is west (-X)
101  {
102  return (a_RelPosition.y < ((a_RelPosition.x < 0.5) ? 1.0 : 0.5));
103  }
104  else if ((a_BlockMeta & 0x3) == 2) // tall side is south (+Z)
105  {
106  return (a_RelPosition.y < ((a_RelPosition.z > 0.5) ? 1.0 : 0.5));
107  }
108  else if ((a_BlockMeta & 0x3) == 3) // tall side is north (-Z)
109  {
110  return (a_RelPosition.y < ((a_RelPosition.z < 0.5) ? 1.0 : 0.5));
111  }
112  return false;
113  }
114  #endif
115 
116 } ;
117 
118 
119 
120 
@ E_BLOCK_NETHER_BRICK_STAIRS
Definition: BlockType.h:129
@ E_BLOCK_OAK_WOOD_STAIRS
Definition: BlockType.h:63
@ E_BLOCK_PURPUR_STAIRS
Definition: BlockType.h:222
@ E_BLOCK_COBBLESTONE_STAIRS
Definition: BlockType.h:81
@ E_BLOCK_DARK_OAK_WOOD_STAIRS
Definition: BlockType.h:183
@ E_BLOCK_BRICK_STAIRS
Definition: BlockType.h:123
@ E_BLOCK_STONE_BRICK_STAIRS
Definition: BlockType.h:124
@ E_BLOCK_BIRCH_WOOD_STAIRS
Definition: BlockType.h:150
@ E_BLOCK_JUNGLE_WOOD_STAIRS
Definition: BlockType.h:151
@ E_BLOCK_ACACIA_WOOD_STAIRS
Definition: BlockType.h:182
@ E_BLOCK_RED_SANDSTONE_STAIRS
Definition: BlockType.h:199
@ E_BLOCK_SPRUCE_WOOD_STAIRS
Definition: BlockType.h:149
@ E_BLOCK_SANDSTONE_STAIRS
Definition: BlockType.h:143
@ E_BLOCK_QUARTZ_STAIRS
Definition: BlockType.h:173
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
Byte ColourID
Definition: Globals.h:162
#define ASSERT(x)
Definition: Globals.h:276
#define UNUSED
Definition: Globals.h:72
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const override
Definition: BlockStairs.h:47
static bool IsAnyStairType(BLOCKTYPE a_Block)
Definition: BlockStairs.h:19
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Definition: BlockStairs.h:54
Mixin to clear the block's meta value when converting to a pickup.
Definition: Mixins.h:31
cMetaRotator< Base, BitMask, North, East, South, West, AssertIfNotMatched > Super
Definition: Mixins.h:163
T x
Definition: Vector3.h:17
T y
Definition: Vector3.h:17
T z
Definition: Vector3.h:17