Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockRedstoneOre.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "BlockOre.h"
6 
7 
8 
9 
10 
12  public cBlockOreHandler
13 {
15 
16 public:
17 
18  using Super::Super; // Inherit constructor from base
19 
20 
21 
22 
23 
24  virtual bool OnUse(
25  cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
26  const Vector3i a_BlockPos,
27  eBlockFace a_BlockFace,
28  const Vector3i a_CursorPos
29  ) const override
30  {
31  a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
32  return false;
33  }
34 
35 
36 
37 
38 
39  virtual void OnDigging(
40  cChunkInterface & a_ChunkInterface,
41  cWorldInterface & a_WorldInterface,
42  cPlayer & a_Player,
43  const Vector3i a_BlockPos
44  ) const override
45  {
46  a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_REDSTONE_ORE_GLOWING, 0);
47  }
48 
49 
50 
51 
52 
53  virtual bool IsUseable() const override
54  {
55  return true;
56  }
57 };
58 
59 
60 
61 
62 
64  public cBlockOreHandler
65 {
67 
68 public:
69 
70  using Super::Super; // Inherit constructor from base
71 
72 
73 
74 
75 
76  virtual void OnUpdate(
77  cChunkInterface & a_ChunkInterface,
78  cWorldInterface & a_WorldInterface,
79  cBlockPluginInterface & a_BlockPluginInterface,
80  cChunk & a_Chunk,
81  const Vector3i a_RelPos
82  ) const override
83  {
84  auto BlockPos = a_Chunk.RelativeToAbsolute(a_RelPos);
85  a_ChunkInterface.SetBlock(BlockPos, E_BLOCK_REDSTONE_ORE, 0);
86  }
87 };
88 
89 
90 
91 
92 
@ E_BLOCK_REDSTONE_ORE
Definition: BlockType.h:87
@ E_BLOCK_REDSTONE_ORE_GLOWING
Definition: BlockType.h:88
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
cBlockHandler Super
Definition: BlockOre.h:14
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
virtual bool IsUseable() const override
Called to check whether this block supports a rclk action.
virtual void OnDigging(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos) const override
Called when the player starts digging the block.
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.
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_BlockPluginInterface, cChunk &a_Chunk, const Vector3i a_RelPos) const override
Called when the block gets ticked either by a random tick or by a queued tick.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Definition: Chunk.h:36
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition) const
Converts the coord relative to this chunk into an absolute coord.
Definition: Chunk.h:450
Definition: Player.h:29