Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockLilypad.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
10 class cBlockLilypadHandler final :
11  public cClearMetaOnDrop<cBlockHandler>
12 {
14 
15 public:
16 
17  using Super::Super;
18 
19 private:
20 
21  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
22  {
23  UNUSED(a_Meta);
24  return 7;
25  }
26 
27 
28 
29 
30 
31  virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
32  {
33  auto UnderPos = a_Position.addedY(-1);
34  if (!cChunkDef::IsValidHeight(UnderPos))
35  {
36  return false;
37  }
38  BLOCKTYPE UnderType;
39  NIBBLETYPE UnderMeta;
40  a_Chunk.GetBlockTypeMeta(UnderPos, UnderType, UnderMeta);
41  return (
42  (((UnderType == E_BLOCK_STATIONARY_WATER) || (UnderType == E_BLOCK_WATER)) && (UnderMeta == 0)) || // A water source is below
43  (UnderType == E_BLOCK_ICE) || (UnderType == E_BLOCK_FROSTED_ICE) // Or (frosted) ice
44  );
45  }
46 };
47 
48 
49 
50 
@ E_BLOCK_WATER
Definition: BlockType.h:18
@ E_BLOCK_ICE
Definition: BlockType.h:93
@ E_BLOCK_STATIONARY_WATER
Definition: BlockType.h:19
@ E_BLOCK_FROSTED_ICE
Definition: BlockType.h:231
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
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.
Definition: BlockLilypad.h:31
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...
Definition: BlockLilypad.h:21
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
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
Definition: ChunkDef.h:185
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