Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemRail.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 #include "Blocks/BlockRail.h"
6 
7 
8 
9 
10 
11 class cItemRailHandler final :
12  public cItemHandler
13 {
15 
16 public:
17 
18  using Super::Super;
19 
20 private:
21 
22  virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
23  {
24  cChunkInterface ChunkInterface(a_Player.GetWorld()->GetChunkMap());
25  const auto RailType = static_cast<BLOCKTYPE>(a_HeldItem.m_ItemType);
26  return a_Player.PlaceBlock(a_PlacePosition, RailType, cBlockRailHandler::FindMeta(ChunkInterface, a_PlacePosition, RailType));
27  }
28 };
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
static NIBBLETYPE FindMeta(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, BLOCKTYPE a_RailType)
Definition: BlockRail.h:37
cWorld * GetWorld(void) const
Definition: Entity.h:190
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
short m_ItemType
Definition: Item.h:163
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.
Definition: ItemRail.h:22
cChunkMap * GetChunkMap(void)
Definition: World.h:852