Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockMushroom.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
11 class cBlockMushroomHandler final :
12  public cClearMetaOnDrop<cBlockHandler>
13 {
15 
16 public:
17 
18  using Super::Super;
19 
20 private:
21 
22  // TODO: Add Mushroom Spread
23 
24  virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
25  {
26  if (a_Position.y <= 0)
27  {
28  return false;
29  }
30 
31  // TODO: Cannot be at too much daylight
32 
33  switch (a_Chunk.GetBlock(a_Position.addedY(-1)))
34  {
35  case E_BLOCK_GLASS:
36  case E_BLOCK_CACTUS:
37  case E_BLOCK_ICE:
38  case E_BLOCK_LEAVES:
39  case E_BLOCK_NEW_LEAVES:
40  case E_BLOCK_AIR:
41  {
42  return false;
43  }
44  }
45  return true;
46  }
47 
48 
49 
50 
51 
52  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
53  {
54  UNUSED(a_Meta);
55  return 0;
56  }
57 } ;
58 
59 
60 
61 
@ E_BLOCK_NEW_LEAVES
Definition: BlockType.h:180
@ E_BLOCK_AIR
Definition: BlockType.h:10
@ E_BLOCK_LEAVES
Definition: BlockType.h:28
@ E_BLOCK_CACTUS
Definition: BlockType.h:95
@ E_BLOCK_ICE
Definition: BlockType.h:93
@ E_BLOCK_GLASS
Definition: BlockType.h:30
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
Byte ColourID
Definition: Globals.h:162
#define UNUSED
Definition: Globals.h:72
Handler for the small (singleblock) mushrooms.
Definition: BlockMushroom.h:13
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: BlockMushroom.h:52
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: BlockMushroom.h:24
Mixin to clear the block's meta value when converting to a pickup.
Definition: Mixins.h:31
Definition: Chunk.h:36
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:146
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