Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockEntity.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "ChunkInterface.h"
6 #include "../Item.h"
7 
8 
9 
10 
11 
15  public cBlockHandler
16 {
18 
19 public:
20 
21  using Super::Super;
22 
23 protected:
24 
25  ~cBlockEntityHandler() = default;
26 
27 private:
28 
29  virtual bool OnUse(
30  cChunkInterface & a_ChunkInterface,
31  cWorldInterface & a_WorldInterface,
32  cPlayer & a_Player,
33  const Vector3i a_BlockPos,
34  eBlockFace a_BlockFace,
35  const Vector3i a_CursorPos
36  ) const override
37  {
38  return a_ChunkInterface.UseBlockEntity(&a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
39  }
40 
41  virtual bool IsUseable() const override
42  {
43  return true;
44  }
45 };
46 
47 
48 
49 
50 
52  public cBlockEntityHandler
53 {
54 public:
55 
56  using cBlockEntityHandler::cBlockEntityHandler;
57 };
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
Wrapper for blocks that have a cBlockEntity descendant attached to them and can be "used" by the play...
Definition: BlockEntity.h:16
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.
Definition: BlockEntity.h:29
virtual bool IsUseable() const override
Called to check whether this block supports a rclk action.
Definition: BlockEntity.h:41
~cBlockEntityHandler()=default
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
bool UseBlockEntity(cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
Use block entity on coordinate.
Definition: Player.h:29
T x
Definition: Vector3.h:17
T y
Definition: Vector3.h:17
T z
Definition: Vector3.h:17