Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockObserver.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "Mixins.h"
6 
7 
8 class cBlockObserverHandler final :
9  public cClearMetaOnDrop<cDisplacementYawRotator<cBlockHandler>>
10 {
12 
13 public:
14 
15  using Super::Super;
16 
18  {
19  return -GetSignalOutputOffset(a_Meta);
20  }
21 
23  {
24  switch (a_Meta & 0x7)
25  {
26  case 0x00: return { 0, 1, 0 };
27  case 0x01: return { 0, -1, 0 };
28  case 0x02: return { 0, 0, 1 };
29  case 0x03: return { 0, 0, -1 };
30  case 0x04: return { 1, 0, 0 };
31  case 0x05: return { -1, 0, 0 };
32  default:
33  {
34  LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta);
35  ASSERT(!"Unknown metadata while determining orientation of observer!");
36  return { 0, 0, 0 };
37  }
38  }
39  }
40 };
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
#define ASSERT(x)
Definition: Globals.h:276
void LOGWARNING(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:67
static Vector3i GetObservingFaceOffset(NIBBLETYPE a_Meta)
Definition: BlockObserver.h:17
static Vector3i GetSignalOutputOffset(NIBBLETYPE a_Meta)
Definition: BlockObserver.h:22
Mixin to clear the block's meta value when converting to a pickup.
Definition: Mixins.h:31
cYawRotator< Base, BitMask, North, East, South, West > Super
Definition: Mixins.h:216