Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockDaylightSensor.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 
17  using Super::Super;
18 
19 private:
20 
21  virtual bool OnUse(
22  cChunkInterface & a_ChunkInterface,
23  cWorldInterface & a_WorldInterface,
24  cPlayer & a_Player,
25  const Vector3i a_BlockPos,
26  eBlockFace a_BlockFace,
27  const Vector3i a_CursorPos
28  ) const override
29  {
30  if (a_ChunkInterface.GetBlock(a_BlockPos) == E_BLOCK_DAYLIGHT_SENSOR)
31  {
32  a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_INVERTED_DAYLIGHT_SENSOR, 0);
33  }
34  else
35  {
36  a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_DAYLIGHT_SENSOR, 0);
37  }
38 
39  return true;
40  }
41 
42 
43  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
44  {
45  // Always drop the regular daylight sensor:
46  return { E_BLOCK_DAYLIGHT_SENSOR };
47  }
48 
49 
50  virtual bool IsUseable(void) const override
51  {
52  return true;
53  }
54 };
@ E_BLOCK_DAYLIGHT_SENSOR
Definition: BlockType.h:167
@ E_BLOCK_INVERTED_DAYLIGHT_SENSOR
Definition: BlockType.h:197
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
virtual bool IsUseable(void) const override
Called to check whether this block supports a rclk action.
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 OnUse(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos) const override
Called when the user right clicks the block and the block is useable.
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
BLOCKTYPE GetBlock(Vector3i a_Pos)
Definition: Player.h:29
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215