Cuberite
A lightweight, fast and extensible game server for Minecraft
SimplePlaceableItemHandler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ItemHandler.h"
4 
5 
6 
7 
8 
10  public cItemHandler
11 {
13 
14 public:
15 
16  constexpr cSimplePlaceableItemHandler(int a_ItemType, BLOCKTYPE a_BlockType) :
17  Super(a_ItemType),
18  m_BlockType(a_BlockType)
19  {
20  }
21 
22 
23  virtual bool IsPlaceable(void) const override
24  {
25  return true;
26  }
27 
28 
29  virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
30  {
31  return a_Player.PlaceBlock(a_PlacePosition, m_BlockType, 0);
32  }
33 
34 private:
35 
37 };
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
Definition: Player.h:29
bool PlaceBlock(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Attempts to place the block in the world with a call to PlaceBlocks.
Definition: Player.cpp:2440
Definition: Item.h:37
constexpr cItemHandler(int a_ItemType)
Definition: ItemHandler.h:37
virtual bool CommitPlacement(cPlayer &a_Player, const cItem &a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
Performs the actual placement of this placeable item.
constexpr cSimplePlaceableItemHandler(int a_ItemType, BLOCKTYPE a_BlockType)
virtual bool IsPlaceable(void) const override
Blocks simply get placed.