Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockSignPost.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "../Chunk.h"
6 
7 
8 
9 
10 
11 class cBlockSignPostHandler final :
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  return cItem(E_ITEM_SIGN, 1, 0);
25  }
26 
27 
28 
29 
30 
31  virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
32  {
33  if (a_Position.y <= 0)
34  {
35  return false;
36  }
37 
38  BLOCKTYPE Type = a_Chunk.GetBlock(a_Position.addedY(-1));
40  }
41 
42 
43 
44 
45 
46  virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
47  {
48  return (a_Meta + 4) & 0x0f;
49  }
50 
51 
52 
53 
54 
55  virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
56  {
57  return (a_Meta + 12) & 0x0f;
58  }
59 
60 
61 
62 
63 
64  virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
65  {
66  // Mirrors signs over the XY plane (North-South Mirroring)
67 
68  // There are 16 meta values which correspond to different directions.
69  // These values are equated to angles on a circle; 0x08 = 180 degrees.
70  return (a_Meta < 0x08) ? (0x08 - a_Meta) : (0x18 - a_Meta);
71  }
72 
73 
74 
75 
76 
77  virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
78  {
79  // Mirrors signs over the YZ plane (East-West Mirroring)
80 
81  // There are 16 meta values which correspond to different directions.
82  // These values are equated to angles on a circle; 0x10 = 360 degrees.
83  return 0x0f - a_Meta;
84  }
85 
86 
87 
88 
89 
90  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
91  {
92  UNUSED(a_Meta);
93  return 13;
94  }
95 } ;
96 
97 
98 
99 
@ E_BLOCK_SIGN_POST
Definition: BlockType.h:76
@ E_BLOCK_WALLSIGN
Definition: BlockType.h:82
@ E_ITEM_SIGN
Definition: BlockType.h:367
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 UNUSED
Definition: Globals.h:72
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
Definition: BlockInfo.cpp:892
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
Mirros a given block meta around the YZ plane.
Definition: BlockSignPost.h:77
virtual bool CanBeAt(const cChunk &a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
Checks if the block can stay at the specified relative coords in the chunk.
Definition: BlockSignPost.h:31
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
Rotates a given block meta clockwise.
Definition: BlockSignPost.h:46
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...
Definition: BlockSignPost.h:90
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
Rotates a given block meta counter-clockwise.
Definition: BlockSignPost.h:55
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
Mirrors a given block meta around the XY plane.
Definition: BlockSignPost.h:64
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: BlockSignPost.h:22
Definition: Chunk.h:36
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:146
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
Definition: Vector3.h:314
T y
Definition: Vector3.h:17