Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockWorkbench.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "../UI/CraftingWindow.h"
6 #include "../Entities/Player.h"
7 
8 
9 
10 
11 
13  public cBlockHandler
14 {
16 
17 public:
18 
19  using Super::Super;
20 
21 private:
22 
23  virtual bool OnUse(
24  cChunkInterface & a_ChunkInterface,
25  cWorldInterface & a_WorldInterface,
26  cPlayer & a_Player,
27  const Vector3i a_BlockPos,
28  eBlockFace a_BlockFace,
29  const Vector3i a_CursorPos
30  ) const override
31  {
33 
34  cWindow * Window = new cCraftingWindow();
35  a_Player.OpenWindow(*Window);
36  return true;
37  }
38 
39 
40 
41 
42 
43  virtual bool IsUseable(void) const override
44  {
45  return true;
46  }
47 
48 
49 
50 
51 
52  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
53  {
54  UNUSED(a_Meta);
55  return 13;
56  }
57 } ;
58 
59 
60 
61 
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
Byte ColourID
Definition: Globals.h:162
#define UNUSED
Definition: Globals.h:72
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
Definition: BlockHandler.h:29
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 ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
virtual bool IsUseable(void) const override
Called to check whether this block supports a rclk action.
Definition: Player.h:29
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
Definition: Player.h:237
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
Definition: Player.cpp:1123
std::unordered_map< CustomStatistic, StatValue > Custom
Represents a UI window.
Definition: Window.h:54