Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockTripwireHook.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "BlockHandler.h"
4 #include "Mixins.h"
5 
6 
7 
8 
9 
11  public cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01>
12 {
13  using Super = cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01>;
14 
15 public:
16 
17  using Super::Super;
18 
20  {
21  switch (a_Meta & 0x03)
22  {
23  case 0x1: return BLOCK_FACE_XM;
24  case 0x3: return BLOCK_FACE_XP;
25  case 0x2: return BLOCK_FACE_ZM;
26  case 0x0: return BLOCK_FACE_ZP;
27  default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
28  }
29  }
30 
31 private:
32 
33  virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
34  {
35  const auto RearPosition = AddFaceDirection(a_Position, MetadataToDirection(a_Meta), true);
36 
37  BLOCKTYPE NeighborBlockType;
38  if (!a_Chunk.UnboundedRelGetBlockType(RearPosition, NeighborBlockType))
39  {
40  return false;
41  }
42 
43  return cBlockInfo::FullyOccupiesVoxel(NeighborBlockType);
44  }
45 
46 
47 
48 
49 
50  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
51  {
52  UNUSED(a_Meta);
53  return 0;
54  }
55 };
56 
57 
58 
59 
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
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse)
Modifies the specified coords so that they point to the block adjacent to the one specified through i...
Definition: Defines.cpp:378
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
@ BLOCK_FACE_XP
Definition: Defines.h:41
@ BLOCK_FACE_ZM
Definition: Defines.h:44
@ BLOCK_FACE_ZP
Definition: Defines.h:45
@ BLOCK_FACE_XM
Definition: Defines.h:40
@ BLOCK_FACE_NONE
Definition: Defines.h:39
Byte ColourID
Definition: Globals.h:162
#define ASSERT(x)
Definition: Globals.h:276
#define UNUSED
Definition: Globals.h:72
static bool FullyOccupiesVoxel(BLOCKTYPE Block)
Does this block fully occupy its voxel - is it a 'full' block?
Definition: BlockInfo.cpp:606
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...
static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
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.
Mixin for rotations and reflections following the standard pattern of "apply mask,...
Definition: Mixins.h:62
Definition: Chunk.h:36
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap...
Definition: Chunk.cpp:1029