From 23bca008317e125659d4b97f29cf13da81a7aecd Mon Sep 17 00:00:00 2001 From: KrystilizeNevaDies <57762380+KrystilizeNevaDies@users.noreply.github.com> Date: Tue, 22 Sep 2020 01:31:45 +1000 Subject: Implement Dropspenser Hook (#4903) * Implement Dropspenser Hook Implemented a hook for dropspensing. HOOK_DROPSPENSE When plugin callback returns true then dropspense is cancelled * Update src/Bindings/PluginManager.h Co-authored-by: peterbell10 * Create OnDropSpense.lua * Fix indent * Forgot include Forgot to include the plugin manager. Although now im confused why it was working on my end without including the plugin manager * Update plugins.lua with dropspense * fix typos * haha notepad++ go brr Co-authored-by: peterbell10 --- src/BlockEntities/DropSpenserEntity.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/BlockEntities/DropSpenserEntity.cpp') diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 97a67ff60..243ec8594 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -6,6 +6,7 @@ #include "Globals.h" #include "DropSpenserEntity.h" +#include "../Bindings/PluginManager.h" #include "../EffectID.h" #include "../Entities/Player.h" #include "../Chunk.h" @@ -80,8 +81,16 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1); + int SpenseSlot = OccupiedSlots[RandomSlot]; + + if (cPluginManager::Get()->CallHookDropSpense(*m_World, *this, SpenseSlot)) + { + // Plugin disagrees with the move + return; + } + // DropSpense the item, using the specialized behavior in the subclasses: - DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]); + DropSpenseFromSlot(a_Chunk, SpenseSlot); // Broadcast a smoke and click effects: NIBBLETYPE Meta = a_Chunk.GetMeta(GetRelPos()); -- cgit v1.2.3