Cuberite
A lightweight, fast and extensible game server for Minecraft
SmallGateHandler.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 
6 
7 
8 namespace SmallGateHandler
9 {
10  static PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
11  {
12  UNUSED(a_Chunk);
13  UNUSED(a_Position);
14  UNUSED(a_BlockType);
15  UNUSED(a_QueryPosition);
16  UNUSED(a_QueryBlockType);
17  UNUSED(IsLinked);
18  return 0;
19  }
20 
21  static void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
22  {
23  // LOGD("Evaluating gateydory the fence gate/trapdoor (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
24 
25  // Use redstone data rather than block state so players can override redstone control
26  const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power);
27  const bool IsOpen = (Previous != 0);
28  const bool ShouldBeOpen = Power != 0;
29 
30  if (ShouldBeOpen != IsOpen)
31  {
32  a_Chunk.SetMeta(a_Position, ShouldBeOpen ? (a_Meta | 0x4) : (a_Meta & ~0x04));
33  }
34  }
35 
36  static void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback & Callback)
37  {
38  UNUSED(a_Chunk);
39  UNUSED(a_BlockType);
40  UNUSED(a_Meta);
41  InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
42  }
43 };
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
#define UNUSED
Definition: Globals.h:72
auto & DataForChunk(const cChunk &a_Chunk)
constexpr std::array< Vector3i, 6 > RelativeAdjacents
void InvokeForAdjustedRelatives(ForEachSourceCallback &Callback, const Vector3i Position, const ArrayType &Relative)
unsigned char PowerLevel
unsigned char Power(const BlockState Block)
static PowerLevel GetPowerDeliveredToPosition(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
static void Update(cChunk &a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
static void ForValidSourcePositions(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback &Callback)
Definition: Chunk.h:36
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
Definition: Chunk.h:286