diff options
author | Mattes D <github@xoft.cz> | 2020-04-21 22:19:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 22:19:22 +0200 |
commit | 487f9a2aa9b5497495cef1ac3b9c7a603e69f862 (patch) | |
tree | 054a846942f414060e29c72f4a717c8a89e70893 /src/Items/ItemEyeOfEnder.h | |
parent | Delet SpawnObject params (diff) | |
download | cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.gz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.bz2 cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.lz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.xz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.zst cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemEyeOfEnder.h | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/Items/ItemEyeOfEnder.h b/src/Items/ItemEyeOfEnder.h index f911955a1..3849feb00 100644 --- a/src/Items/ItemEyeOfEnder.h +++ b/src/Items/ItemEyeOfEnder.h @@ -8,46 +8,53 @@ -class cItemEyeOfEnderHandler : +class cItemEyeOfEnderHandler: public cItemThrowableHandler { - typedef cItemThrowableHandler super; + using Super = cItemThrowableHandler; + public: - cItemEyeOfEnderHandler(void) : - super(E_ITEM_EYE_OF_ENDER, cProjectileEntity::pkSnowball, 30) + + cItemEyeOfEnderHandler(): + Super(E_ITEM_EYE_OF_ENDER, cProjectileEntity::pkSnowball, 30) { } + + + + 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 + const Vector3i a_ClickedBlockPos, + eBlockFace a_ClickedBlockFace ) override { - BLOCKTYPE FacingBlock; - NIBBLETYPE FacingMeta; - a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, FacingBlock, FacingMeta); - switch (FacingBlock) + // Try to fill an End Portal Frame block: + if (a_ClickedBlockFace != BLOCK_FACE_NONE) { - case E_BLOCK_END_PORTAL_FRAME: + BLOCKTYPE FacingBlock; + NIBBLETYPE FacingMeta; + a_World->GetBlockTypeMeta(a_ClickedBlockPos, FacingBlock, FacingMeta); + if (FacingBlock == E_BLOCK_END_PORTAL_FRAME) { // Fill the portal frame. E_META_END_PORTAL_EYE is the bit for holding the eye of ender. if ((FacingMeta & E_META_END_PORTAL_FRAME_EYE) != E_META_END_PORTAL_FRAME_EYE) { - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_END_PORTAL_FRAME, FacingMeta | E_META_END_PORTAL_FRAME_EYE); + a_World->SetBlock(a_ClickedBlockPos, E_BLOCK_END_PORTAL_FRAME, FacingMeta | E_META_END_PORTAL_FRAME_EYE); if (!a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); } + return true; } - break; - } - default: - { - // TODO: Create projectile for Eye Of Ender - // return cItemThrowableHandler::OnItemUse(a_World, a_Player, a_PluginInterface, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); } + return false; } + // TODO: Create projectile for Eye Of Ender + // return Super::OnItemUse(a_World, a_Player, a_PluginInterface, a_Item, a_ClickedBlockPos, a_ClickedBlockFace); + return false; } |