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 };
cBlockEntityHandler::OnUse
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
BlockHandler.h
Vector3::x
T x
Definition: Vector3.h:17
cBlockHandler
Definition: BlockHandler.h:25
cWorldInterface
Definition: WorldInterface.h:19
Vector3::z
T z
Definition: Vector3.h:17
cChunkInterface
Definition: ChunkInterface.h:21
cBlockEntityHandler::IsUseable
virtual bool IsUseable() const override
Called to check whether this block supports a rclk action.
Definition: BlockEntity.h:41
cDefaultBlockEntityHandler
Definition: BlockEntity.h:51
cBlockEntityHandler::~cBlockEntityHandler
~cBlockEntityHandler()=default
cChunkInterface::UseBlockEntity
bool UseBlockEntity(cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
Use block entity on coordinate.
Definition: ChunkInterface.cpp:77
eBlockFace
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:37
cPlayer
Definition: Player.h:27
Vector3::y
T y
Definition: Vector3.h:17
Vector3< int >
ChunkInterface.h
cBlockEntityHandler
Wrapper for blocks that have a cBlockEntity descendant attached to them and can be "used" by the play...
Definition: BlockEntity.h:14
cBlockHandler::cBlockHandler
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29