Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockRedstoneWire.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "BlockSlab.h"
6 #include "BlockStairs.h"
7 #include "../Chunk.h"
8 
9 
10 
11 
13  public 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 
30  BLOCKTYPE BelowBlock;
31  NIBBLETYPE BelowBlockMeta;
32  a_Chunk.GetBlockTypeMeta(a_Position.addedY(-1), BelowBlock, BelowBlockMeta);
33 
34  if (cBlockInfo::FullyOccupiesVoxel(BelowBlock))
35  {
36  return true;
37  }
38 
39  // upside down slabs
40  if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
41  {
42  return BelowBlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN;
43  }
44 
45  // upside down stairs
47  {
48  return BelowBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN;
49  }
50 
51  return false;
52  }
53 
54 
55 
56 
57 
58  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
59  {
60  return cItem(E_ITEM_REDSTONE_DUST, 1, 0);
61  }
62 
63 
64 
65 
66 
67  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
68  {
69  UNUSED(a_Meta);
70  return 0;
71  }
72 } ;
73 
74 
75 
76 
@ E_META_WOODEN_SLAB_UPSIDE_DOWN
Definition: BlockType.h:989
@ E_BLOCK_STAIRS_UPSIDE_DOWN
Definition: BlockType.h:902
@ E_ITEM_REDSTONE_DUST
Definition: BlockType.h:375
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 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
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
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.
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 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
Definition: Chunk.h:36
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Definition: Chunk.cpp:1757
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
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