Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemNetherWart.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 #include "../World.h"
6 
7 
8 
9 
10 
12  public cItemHandler
13 {
15 
16 public:
17 
18  using Super::Super;
19 
20 
21 
22 
23 
24  virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
25  {
26  // Only allow planting nether wart onto the top side of the block:
27  if (a_ClickedBlockFace != BLOCK_FACE_TOP)
28  {
29  return true;
30  }
31 
32  return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_NETHER_WART, 0);
33  }
34 
35 
36 
37 
38 
39  virtual bool IsPlaceable(void) const override
40  {
41  return true;
42  }
43 } ;
@ E_BLOCK_NETHER_WART
Definition: BlockType.h:130
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
@ BLOCK_FACE_TOP
Definition: Defines.h:49
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.
virtual bool IsPlaceable(void) const override
Blocks simply get placed.