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 
12  public cBlockHandler
13 {
15 
16 public:
17 
19  super(a_BlockType)
20  {
21  }
22 
23 
24 
25 
26  virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
27  {
28  return cItem(E_ITEM_SIGN, 1, 0);
29  }
30 
31 
32 
33 
34 
35  virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
36  {
37  if (a_RelY <= 0)
38  {
39  return false;
40  }
41  BLOCKTYPE Type = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
42 
43  return ((Type == E_BLOCK_SIGN_POST) || (Type == E_BLOCK_WALLSIGN) || cBlockInfo::IsSolid(Type));
44  }
45 
46  static NIBBLETYPE RotationToMetaData(double a_Rotation)
47  {
48  a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
49  if (a_Rotation > 360)
50  {
51  a_Rotation -= 360;
52  }
53 
54  a_Rotation = (a_Rotation / 360) * 16;
55 
56  return (static_cast<char>(a_Rotation)) % 16;
57  }
58 
59  virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
60  {
61  return (a_Meta + 4) & 0x0f;
62  }
63 
64  virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
65  {
66  return (a_Meta + 12) & 0x0f;
67  }
68 
69  virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
70  {
71  // Mirrors signs over the XY plane (North-South Mirroring)
72 
73  // There are 16 meta values which correspond to different directions.
74  // These values are equated to angles on a circle; 0x08 = 180 degrees.
75  return (a_Meta < 0x08) ? (0x08 - a_Meta) : (0x18 - a_Meta);
76  }
77 
78  virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
79  {
80  // Mirrors signs over the YZ plane (East-West Mirroring)
81 
82  // There are 16 meta values which correspond to different directions.
83  // These values are equated to angles on a circle; 0x10 = 360 degrees.
84  return 0x0f - a_Meta;
85  }
86 
87  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
88  {
89  UNUSED(a_Meta);
90  return 13;
91  }
92 } ;
93 
94 
95 
96 
cBlockSignPostHandler(BLOCKTYPE a_BlockType)
Definition: BlockSignPost.h:18
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
Rotates a given block meta counter-clockwise.
Definition: BlockSignPost.h:64
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
Mirrors a given block meta around the XY plane.
Definition: BlockSignPost.h:69
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: BlockSignPost.h:35
static bool IsSolid(BLOCKTYPE a_Type)
Definition: BlockInfo.h:48
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
static NIBBLETYPE RotationToMetaData(double a_Rotation)
Definition: BlockSignPost.h:46
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
Rotates a given block meta clockwise.
Definition: BlockSignPost.h:59
cBlockHandler(BLOCKTYPE a_BlockType)
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: BlockSignPost.h:87
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity *a_BlockEntity, const cEntity *a_Digger, const cItem *a_Tool) override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
Definition: BlockSignPost.h:26
#define UNUSED
Definition: Globals.h:152
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:177
Byte ColourID
Definition: Globals.h:118
Definition: Entity.h:73
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
Mirros a given block meta around the YZ plane.
Definition: BlockSignPost.h:78
Definition: Item.h:36
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234