Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemLeaves.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 
6 
7 
8 
9 
10 class cItemLeavesHandler final :
11  public cItemHandler
12 {
14 
15 public:
16 
17  using Super::Super;
18 
19 
20 
21 
22 
23  virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
24  {
25  return a_Player.PlaceBlock(
26  a_PlacePosition,
27  static_cast<BLOCKTYPE>(m_ItemType),
28  static_cast<NIBBLETYPE>(a_HeldItem.m_ItemDamage | 0x4) // 0x4 bit set means this is a player-placed leaves block, not to be decayed.
29  );
30  }
31 } ;
32 
33 
34 
35 
cPlayer::PlaceBlock
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
NIBBLETYPE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
cItemLeavesHandler::CommitPlacement
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.
Definition: ItemLeaves.h:23
ItemHandler.h
cItem
Definition: Item.h:36
cItem::m_ItemDamage
short m_ItemDamage
Definition: Item.h:165
cItemHandler::cItemHandler
constexpr cItemHandler(int a_ItemType)
Definition: ItemHandler.h:37
cItemLeavesHandler
Definition: ItemLeaves.h:10
BLOCKTYPE
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
cItemHandler::m_ItemType
const int m_ItemType
Definition: ItemHandler.h:141
eBlockFace
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:37
cPlayer
Definition: Player.h:27
cItemHandler
Definition: ItemHandler.h:21
Vector3< int >