diff options
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemLilypad.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index 985da3ed5..1190e817b 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -23,6 +23,9 @@ public: } + + + virtual bool IsPlaceable(void) override { return false; // Set as not placeable so OnItemUse is called @@ -30,16 +33,22 @@ public: + + 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 + 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) { - // Clicked on the side of a submerged block; vanilla allows placement, so should we - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LILY_PAD, 0); + // Clicked on a face of a submerged block; vanilla allows placement, so should we + auto PlacePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace); + a_World->SetBlock(PlacePos, E_BLOCK_LILY_PAD, 0); if (!a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); @@ -47,12 +56,12 @@ public: return true; } - class cCallbacks : + class cCallbacks: public cBlockTracer::cCallbacks { public: - cCallbacks(void) : + cCallbacks(): m_HasHitFluid(false) { } @@ -84,18 +93,14 @@ public: Vector3i m_Pos; bool m_HasHitFluid; - }; - - cCallbacks Callbacks; - cLineBlockTracer Tracer(*a_Player->GetWorld(), 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); + } Callbacks; + auto Start = a_Player->GetEyePosition() + a_Player->GetLookVector(); + auto End = a_Player->GetEyePosition() + a_Player->GetLookVector() * 5; + cLineBlockTracer::Trace(*a_Player->GetWorld(), Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z); if (Callbacks.m_HasHitFluid) { - a_World->SetBlock(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z, E_BLOCK_LILY_PAD, 0); + a_World->SetBlock(Callbacks.m_Pos, E_BLOCK_LILY_PAD, 0); if (!a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); |