Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemEyeOfEnder.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 #include "ItemThrowable.h"
6 
7 
8 
9 
10 
13 {
15 public:
17  super(E_ITEM_EYE_OF_ENDER, cProjectileEntity::pkSnowball, 30)
18  {
19  }
20 
21  virtual bool OnItemUse(
22  cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item,
23  int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace
24  ) override
25  {
26  BLOCKTYPE FacingBlock;
27  NIBBLETYPE FacingMeta;
28  a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, FacingBlock, FacingMeta);
29  switch (FacingBlock)
30  {
32  {
33  // Fill the portal frame. E_META_END_PORTAL_EYE is the bit for holding the eye of ender.
34  if ((FacingMeta & E_META_END_PORTAL_FRAME_EYE) != E_META_END_PORTAL_FRAME_EYE)
35  {
36  a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_END_PORTAL_FRAME, FacingMeta | E_META_END_PORTAL_FRAME_EYE);
37  if (!a_Player->IsGameModeCreative())
38  {
39  a_Player->GetInventory().RemoveOneEquippedItem();
40  }
41  }
42  break;
43  }
44  default:
45  {
46  // TODO: Create projectile for Eye Of Ender
47  // return cItemThrowableHandler::OnItemUse(a_World, a_Player, a_PluginInterface, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
48  }
49  }
50 
51  return false;
52  }
53 
54 } ;
55 
56 
57 
58 
59 
cItemThrowableHandler super
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.
Definition: Inventory.cpp:207
Definition: Player.h:27
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta)
Retrieves the block type and meta at the specified coords.
Definition: World.cpp:1909
Definition: World.h:65
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cBlockPluginInterface &a_PluginInterface, const cItem &a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
Called when the player tries to use the item (right mouse button).
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
Definition: Player.cpp:1260
cInventory & GetInventory(void)
Definition: Player.h:136
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Definition: World.cpp:1873
Definition: Item.h:36