diff options
Diffstat (limited to 'src/Items/ItemBottle.h')
-rw-r--r-- | src/Items/ItemBottle.h | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/Items/ItemBottle.h b/src/Items/ItemBottle.h index 319bc708f..2f4d8f93f 100644 --- a/src/Items/ItemBottle.h +++ b/src/Items/ItemBottle.h @@ -9,19 +9,28 @@ -class cItemBottleHandler : +class cItemBottleHandler: public cItemHandler { + using Super = cItemHandler; + public: - cItemBottleHandler() : - cItemHandler(E_ITEM_GLASS_BOTTLE) + + cItemBottleHandler(): + Super(E_ITEM_GLASS_BOTTLE) { } + + + + /** Searches for a water source block in the line of sight. + Returns true and sets a_BlockPos if a water source block is found within line-of-sight. + Returns false if not. */ bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) { - class cCallbacks : + class cCallbacks: public cBlockTracer::cCallbacks { public: @@ -29,7 +38,7 @@ public: bool m_HasHitFluid; - cCallbacks(void) : + cCallbacks(): m_HasHitFluid(false) { } @@ -49,31 +58,32 @@ public: return false; } } Callbacks; - - cLineBlockTracer Tracer(*a_World, Callbacks); - Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); - Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - - Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z); - + auto Start = a_Player->GetEyePosition() + a_Player->GetLookVector(); + auto End = a_Player->GetEyePosition() + a_Player->GetLookVector() * 5; + cLineBlockTracer::Trace(*a_World, Callbacks, Start, End); if (!Callbacks.m_HasHitFluid) { return false; } - a_BlockPos = Callbacks.m_Pos; return true; } + + 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 + cWorld * a_World, + cPlayer * a_Player, + cBlockPluginInterface & a_PluginInterface, + const cItem & a_HeldItem, + const Vector3i a_ClickedBlockPos, + eBlockFace a_ClickedBlockFace + ) override { - if (a_BlockFace != BLOCK_FACE_NONE) + if (a_ClickedBlockFace != BLOCK_FACE_NONE) { return false; } |