Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockPressurePlate.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
10  public cClearMetaOnDrop<cBlockHandler>
11 {
13 
14 public:
15 
17  super(a_BlockType)
18  {
19  }
20 
21  virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
22  {
23  if (a_RelY - 1 <= 0)
24  {
25  return false;
26  }
27 
28  // TODO: check if the block is upside-down slab or upside-down stairs
29  BLOCKTYPE Block = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
30  switch (Block)
31  {
35  case E_BLOCK_FENCE:
36  case E_BLOCK_HOPPER:
40  {
41  return true;
42  }
43  default:
44  {
45  return (!cBlockInfo::IsTransparent(Block));
46  }
47  }
48  }
49 
50  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
51  {
52  UNUSED(a_Meta);
53  switch (m_BlockType)
54  {
55  case E_BLOCK_STONE_PRESSURE_PLATE: return 11;
56  case E_BLOCK_WOODEN_PRESSURE_PLATE: return 13;
59  default:
60  {
61  ASSERT(!"Unhandled blocktype in pressure plate handler!");
62  return 0;
63  }
64  }
65  }
66 } ;
67 
68 
69 
70 
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
BLOCKTYPE m_BlockType
Definition: BlockHandler.h:213
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...
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
Definition: Chunk.h:49
#define ASSERT(x)
Definition: Globals.h:335
#define UNUSED
Definition: Globals.h:152
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:177
static bool IsTransparent(BLOCKTYPE a_Type)
Definition: BlockInfo.h:32
Byte ColourID
Definition: Globals.h:118
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.
Mixin to clear the block&#39;s meta value when converting to a pickup.
Definition: Mixins.h:55
cBlockPressurePlateHandler(BLOCKTYPE a_BlockType)