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 #include "BlockSlab.h"
6 #include "../Chunk.h"
7 #include "BlockStairs.h"
8 
9 
10 
11 
13  public cClearMetaOnDrop<cBlockHandler>
14 {
16 
17 public:
18 
19  using Super::Super;
20 
21 private:
22 
23  virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
24  {
25  if (a_Position.y <= 0)
26  {
27  return false;
28  }
29 
31  NIBBLETYPE BlockMeta;
32  a_Chunk.GetBlockTypeMeta(a_Position.addedY(-1), Block, BlockMeta);
33 
34  // upside down slabs
36  {
37  return BlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN;
38  }
39 
40  // upside down stairs
42  {
43  return BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN;
44  }
45 
46  switch (Block)
47  {
51  case E_BLOCK_FENCE:
52  case E_BLOCK_HOPPER:
56  {
57  return true;
58  }
59  default:
60  {
62  }
63  }
64  }
65 
66 
67 
68 
69 
70  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
71  {
72  UNUSED(a_Meta);
73  switch (m_BlockType)
74  {
75  case E_BLOCK_STONE_PRESSURE_PLATE: return 11;
76  case E_BLOCK_WOODEN_PRESSURE_PLATE: return 13;
79  default:
80  {
81  ASSERT(!"Unhandled blocktype in pressure plate handler!");
82  return 0;
83  }
84  }
85  }
86 } ;
87 
88 
89 
90 
@ E_META_WOODEN_SLAB_UPSIDE_DOWN
Definition: BlockType.h:989
@ E_BLOCK_STAIRS_UPSIDE_DOWN
Definition: BlockType.h:902
@ E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE
Definition: BlockType.h:163
@ E_BLOCK_STONE_PRESSURE_PLATE
Definition: BlockType.h:84
@ E_BLOCK_DARK_OAK_FENCE
Definition: BlockType.h:210
@ E_BLOCK_FENCE
Definition: BlockType.h:100
@ E_BLOCK_WOODEN_PRESSURE_PLATE
Definition: BlockType.h:86
@ E_BLOCK_SPRUCE_FENCE
Definition: BlockType.h:207
@ E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE
Definition: BlockType.h:162
@ E_BLOCK_HOPPER
Definition: BlockType.h:171
@ E_BLOCK_ACACIA_FENCE
Definition: BlockType.h:211
@ E_BLOCK_NETHER_BRICK_FENCE
Definition: BlockType.h:128
@ E_BLOCK_BIRCH_FENCE
Definition: BlockType.h:208
@ E_BLOCK_JUNGLE_FENCE
Definition: BlockType.h:209
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 ASSERT(x)
Definition: Globals.h:276
#define UNUSED
Definition: Globals.h:72
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
Definition: BlockInfo.cpp:961
const BLOCKTYPE m_BlockType
Definition: BlockHandler.h:205
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...
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.
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
Returns true if the specified blocktype is one of the slabs handled by this handler.
Definition: BlockSlab.h:30
static bool IsAnyStairType(BLOCKTYPE a_Block)
Definition: BlockStairs.h:19
Mixin to clear the block's meta value when converting to a pickup.
Definition: Mixins.h:31
Definition: Chunk.h:36
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Definition: Chunk.cpp:1757
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