Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockEnchantmentTable.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "../UI/EnchantingWindow.h"
6 #include "../Entities/Player.h"
7 
8 
9 
10 
11 
13  public cBlockHandler
14 {
15 public:
17  : cBlockHandler(a_BlockType)
18  {
19  }
20 
21  virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
22  {
23  cWindow * Window = new cEnchantingWindow(a_BlockX, a_BlockY, a_BlockZ);
24  a_Player.OpenWindow(*Window);
25  return true;
26  }
27 
28  virtual bool IsUseable(void) override
29  {
30  return true;
31  }
32 
33  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
34  {
35  UNUSED(a_Meta);
36  return 29;
37  }
38 };
39 
40 
41 
42 
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
Definition: Player.h:27
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
virtual bool OnUse(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
Called if the user right clicks the block and the block is useable returns true if the use was succes...
#define UNUSED
Definition: Globals.h:152
virtual bool IsUseable(void) override
Checks if the block can be placed at this point.
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
Byte ColourID
Definition: Globals.h:118
Represents a UI window.
Definition: Window.h:53
cBlockEnchantmentTableHandler(BLOCKTYPE a_BlockType)
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
Definition: Player.cpp:1349