Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockAnvil.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockHandler.h"
5 #include "Mixins.h"
6 #include "../Entities/Player.h"
7 #include "../UI/AnvilWindow.h"
8 
9 
10 
11 
12 
13 class cBlockAnvilHandler final :
14  public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>
15 {
17 
18 public:
19 
20  using Super::Super;
21 
22 private:
23 
24  virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
25  {
26  return cItem(m_BlockType, 1, a_BlockMeta >> 2);
27  }
28 
29 
30 
31 
32 
33  virtual bool OnUse(
34  cChunkInterface & a_ChunkInterface,
35  cWorldInterface & a_WorldInterface,
36  cPlayer & a_Player,
37  const Vector3i a_BlockPos,
38  eBlockFace a_BlockFace,
39  const Vector3i a_CursorPos
40  ) const override
41  {
42  cWindow * Window = new cAnvilWindow(a_BlockPos);
43  a_Player.OpenWindow(*Window);
44  return true;
45  }
46 
47 
48 
49 
50 
51  virtual bool IsUseable() const override
52  {
53  return true;
54  }
55 
56 
57 
58 
59 
60  virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
61  {
62  UNUSED(a_Meta);
63  return 6;
64  }
65 } ;
66 
67 
68 
69 
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
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Definition: BlockAnvil.h:60
virtual bool IsUseable() const override
Definition: BlockAnvil.h:51
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
Definition: BlockAnvil.h:33
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
Definition: BlockAnvil.h:24
Mixin for blocks whose meta on placement depends on the yaw of the player placing the block.
Definition: Mixins.h:162
cMetaRotator< cBlockHandler, BitMask, North, East, South, West, false > Super
Definition: Mixins.h:163
Definition: Player.h:29
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
Definition: Player.cpp:1123
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
Represents a UI window.
Definition: Window.h:54