1111#include " mc/server/commands/CommandOrigin.h"
1212#include " mc/server/commands/CommandOriginType.h"
1313#include " mc/world/ActorUniqueID.h"
14+ #include " mc/world/containers/ContainerID.h"
15+ #include " mc/world/inventory/transaction/InventorySource.h"
1416#include " mc/world/scores/ScoreInfo.h"
1517
1618#include < ll/api/memory/Hook.h>
2830#include < mc/world/actor/player/Player.h>
2931#include < mc/world/containers/models/LevelContainerModel.h>
3032#include < mc/world/events/EventResult.h>
33+ #include < mc/world/inventory/transaction/ComplexInventoryTransaction.h>
3134#include < mc/world/item/BucketItem.h>
3235#include < mc/world/item/CrossbowItem.h>
3336#include < mc/world/item/ItemInstance.h>
@@ -84,7 +87,7 @@ LL_TYPE_INSTANCE_HOOK(
8487}
8588
8689LL_TYPE_INSTANCE_HOOK (
87- PlayerDropItemHook ,
90+ PlayerDropItemHook1 ,
8891 HookPriority::Normal,
8992 Player,
9093 " ?drop@Player@@UEAA_NAEBVItemStack@@_N@Z" ,
@@ -104,6 +107,33 @@ LL_TYPE_INSTANCE_HOOK(
104107 return origin (item, randomly);
105108}
106109
110+ LL_TYPE_INSTANCE_HOOK (
111+ PlayerDropItemHook2,
112+ HookPriority::Normal,
113+ ComplexInventoryTransaction,
114+ " ?handle@ComplexInventoryTransaction@@UEBA?AW4InventoryTransactionError@@AEAVPlayer@@_N@Z" ,
115+ InventoryTransactionError,
116+ Player& player,
117+ bool isSenderAuthority
118+ ) {
119+ if (type == ComplexInventoryTransaction::Type::NormalTransaction) {
120+ IF_LISTENED (EVENT_TYPES::onDropItem) {
121+ InventorySource source (InventorySourceType::ContainerInventory, ContainerID::Inventory);
122+ auto & actions = data.getActions (source);
123+ if (actions.size () == 1 ) {
124+ CallEventRtnValue (
125+ EVENT_TYPES::onDropItem,
126+ InventoryTransactionError::NoError,
127+ PlayerClass::newPlayer (&player),
128+ ItemClass::newItem (&const_cast <ItemStack&>(player.getInventory ().getItem (actions[0 ].mSlot )), false )
129+ );
130+ }
131+ }
132+ IF_LISTENED_END (EVENT_TYPES::onDropItem);
133+ }
134+ return origin (player, isSenderAuthority);
135+ }
136+
107137LL_TYPE_INSTANCE_HOOK (
108138 PlayerOpenContainerHook,
109139 HookPriority::Normal,
@@ -1008,7 +1038,10 @@ LL_TYPE_INSTANCE_HOOK(
10081038}
10091039
10101040void PlayerStartDestroyBlock () { PlayerStartDestroyHook::hook (); }
1011- void PlayerDropItem () { PlayerDropItemHook::hook (); }
1041+ void PlayerDropItem () {
1042+ PlayerDropItemHook1::hook ();
1043+ PlayerDropItemHook2::hook ();
1044+ }
10121045void PlayerOpenContainerEvent () { PlayerOpenContainerHook::hook (); }
10131046void PlayerCloseContainerEvent () {
10141047 PlayerCloseContainerHook1::hook ();
0 commit comments