Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemHopper.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 
6 
7 
8 
9 
10 class cItemHopperHandler final :
11  public cItemHandler
12 {
14 
15 public:
16 
17  using Super::Super;
18 
19 private:
20 
21  inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace)
22  {
23  switch (a_BlockFace)
24  {
31  default: UNREACHABLE("Unsupported block face");
32  }
33  }
34 
35 
36  virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
37  {
38  return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_HOPPER, BlockFaceToMetaData(a_ClickedBlockFace));
39  }
40 };
@ E_META_HOPPER_FACING_XM
Definition: BlockType.h:698
@ E_META_HOPPER_FACING_ZM
Definition: BlockType.h:696
@ E_META_HOPPER_FACING_ZP
Definition: BlockType.h:697
@ E_META_HOPPER_FACING_XP
Definition: BlockType.h:699
@ E_META_HOPPER_FACING_YM
Definition: BlockType.h:694
@ E_BLOCK_HOPPER
Definition: BlockType.h:171
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
@ BLOCK_FACE_EAST
Definition: Defines.h:53
@ BLOCK_FACE_SOUTH
Definition: Defines.h:51
@ BLOCK_FACE_TOP
Definition: Defines.h:49
@ BLOCK_FACE_WEST
Definition: Defines.h:52
@ BLOCK_FACE_BOTTOM
Definition: Defines.h:48
@ BLOCK_FACE_NORTH
Definition: Defines.h:50
#define UNREACHABLE(x)
Definition: Globals.h:288
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
static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace)
Definition: ItemHopper.h:21
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: ItemHopper.h:36