Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockConcretePowder.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 
6 
7 
8 
9 
11  public cBlockHandler
12 {
14 
15 public:
16 
18  super(a_BlockType)
19  {
20  }
21 
22 
23 
24 
25 
26  virtual void Check(
27  cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface,
28  Vector3i a_RelPos,
29  cChunk & a_Chunk
30  ) override
31  {
32  if (GetSoaked(a_RelPos, a_Chunk))
33  {
34  return;
35  }
36  super::Check(a_ChunkInterface, a_PluginInterface, a_RelPos, a_Chunk);
37  }
38 
39 
40 
41 
42 
45  bool GetSoaked(Vector3i a_Rel, cChunk & a_Chunk)
46  {
47  static const std::array<Vector3i, 5> WaterCheck
48  {
49  {
50  { 1, 0, 0},
51  {-1, 0, 0},
52  { 0, 0, 1},
53  { 0, 0, -1},
54  { 0, 1, 0},
55  }
56  };
57 
58  bool ShouldSoak = std::any_of(WaterCheck.cbegin(), WaterCheck.cend(), [a_Rel, & a_Chunk](Vector3i a_Offset)
59  {
60  BLOCKTYPE NeighborType;
61  return (
62  a_Chunk.UnboundedRelGetBlockType(a_Rel.x + a_Offset.x, a_Rel.y + a_Offset.y, a_Rel.z + a_Offset.z, NeighborType)
63  && IsBlockWater(NeighborType)
64  );
65  }
66  );
67 
68  if (ShouldSoak)
69  {
70  NIBBLETYPE BlockMeta;
71  BlockMeta = a_Chunk.GetMeta(a_Rel.x, a_Rel.y, a_Rel.z);
72  a_Chunk.SetBlock(a_Rel, E_BLOCK_CONCRETE, BlockMeta);
73  return true;
74  }
75  return false;
76  }
77 
78 
79 
80 
81 
82  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
83  {
84  switch (a_Meta)
85  {
86  case E_META_CONCRETE_POWDER_WHITE: return 8;
87  case E_META_CONCRETE_POWDER_ORANGE: return 15;
88  case E_META_CONCRETE_POWDER_MAGENTA: return 16;
89  case E_META_CONCRETE_POWDER_LIGHTBLUE: return 17;
90  case E_META_CONCRETE_POWDER_YELLOW: return 18;
91  case E_META_CONCRETE_POWDER_LIGHTGREEN: return 19;
92  case E_META_CONCRETE_POWDER_PINK: return 20;
93  case E_META_CONCRETE_POWDER_GRAY: return 21;
94  case E_META_CONCRETE_POWDER_LIGHTGRAY: return 22;
95  case E_META_CONCRETE_POWDER_CYAN: return 23;
96  case E_META_CONCRETE_POWDER_PURPLE: return 24;
97  case E_META_CONCRETE_POWDER_BLUE: return 25;
98  case E_META_CONCRETE_POWDER_BROWN: return 26;
99  case E_META_CONCRETE_POWDER_GREEN: return 27;
100  case E_META_CONCRETE_POWDER_RED: return 28;
101  case E_META_CONCRETE_POWDER_BLACK: return 29;
102  default:
103  {
104  ASSERT(!"Unhandled meta in concrete powder handler!");
105  return 0;
106  }
107  }
108  }
109 };
110 
111 
112 
113 
virtual void Check(cChunkInterface &a_ChunkInterface, cBlockPluginInterface &a_PluginInterface, Vector3i a_RelPos, cChunk &a_Chunk) override
Called when one of the neighbors gets set; equivalent to MC block update.
T x
Definition: Vector3.h:17
bool IsBlockWater(BLOCKTYPE a_BlockType)
Definition: Defines.h:436
virtual void Check(cChunkInterface &ChunkInterface, cBlockPluginInterface &a_PluginInterface, Vector3i a_RelPos, cChunk &a_Chunk)
Called when one of the neighbors gets set; equivalent to MC block update.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn&#39;t be in this chunk (uses m_Neighbor-s or m_ChunkMap...
Definition: Chunk.cpp:1018
cBlockConcretePowderHandler(BLOCKTYPE a_BlockType)
cBlockHandler(BLOCKTYPE a_BlockType)
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: Chunk.cpp:1313
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
Definition: Chunk.h:49
T y
Definition: Vector3.h:17
T z
Definition: Vector3.h:17
bool GetSoaked(Vector3i a_Rel, cChunk &a_Chunk)
Check blocks above and around to see if they are water.
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
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...
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
Definition: Chunk.h:380
#define ASSERT(x)
Definition: Globals.h:335
Byte ColourID
Definition: Globals.h:118