11
11
#include " mc/server/commands/CommandOrigin.h"
12
12
#include " mc/server/commands/CommandOriginType.h"
13
13
#include " mc/world/ActorUniqueID.h"
14
+ #include " mc/world/containers/ContainerID.h"
15
+ #include " mc/world/inventory/transaction/InventorySource.h"
14
16
#include " mc/world/scores/ScoreInfo.h"
15
17
16
18
#include < ll/api/memory/Hook.h>
28
30
#include < mc/world/actor/player/Player.h>
29
31
#include < mc/world/containers/models/LevelContainerModel.h>
30
32
#include < mc/world/events/EventResult.h>
33
+ #include < mc/world/inventory/transaction/ComplexInventoryTransaction.h>
31
34
#include < mc/world/item/BucketItem.h>
32
35
#include < mc/world/item/CrossbowItem.h>
33
36
#include < mc/world/item/ItemInstance.h>
@@ -84,7 +87,7 @@ LL_TYPE_INSTANCE_HOOK(
84
87
}
85
88
86
89
LL_TYPE_INSTANCE_HOOK (
87
- PlayerDropItemHook ,
90
+ PlayerDropItemHook1 ,
88
91
HookPriority::Normal,
89
92
Player,
90
93
" ?drop@Player@@UEAA_NAEBVItemStack@@_N@Z" ,
@@ -104,6 +107,33 @@ LL_TYPE_INSTANCE_HOOK(
104
107
return origin (item, randomly);
105
108
}
106
109
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
+
107
137
LL_TYPE_INSTANCE_HOOK (
108
138
PlayerOpenContainerHook,
109
139
HookPriority::Normal,
@@ -1008,7 +1038,10 @@ LL_TYPE_INSTANCE_HOOK(
1008
1038
}
1009
1039
1010
1040
void PlayerStartDestroyBlock () { PlayerStartDestroyHook::hook (); }
1011
- void PlayerDropItem () { PlayerDropItemHook::hook (); }
1041
+ void PlayerDropItem () {
1042
+ PlayerDropItemHook1::hook ();
1043
+ PlayerDropItemHook2::hook ();
1044
+ }
1012
1045
void PlayerOpenContainerEvent () { PlayerOpenContainerHook::hook (); }
1013
1046
void PlayerCloseContainerEvent () {
1014
1047
PlayerCloseContainerHook1::hook ();
0 commit comments