diff --git a/LiteLoader/include/llapi/Offset.h b/LiteLoader/include/llapi/Offset.h index d34afb9..9ba31fd 100644 --- a/LiteLoader/include/llapi/Offset.h +++ b/LiteLoader/include/llapi/Offset.h @@ -79,6 +79,8 @@ namespace ll{ constexpr uint64_t EVENTAPI_PlayerInteractEntity_2 = 0x70; // Hopper::Hopper constexpr uint64_t EVENTAPI_HopperSearchItem = 0x5; + // FillingContainer::FillingContainer a2 + constexpr uint64_t EVENTAPI_PlayerDropItem = 0xF8; // ->src/llapi/mc diff --git a/LiteLoader/src/llapi/EventAPI.cpp b/LiteLoader/src/llapi/EventAPI.cpp index b51125b..84e09b5 100644 --- a/LiteLoader/src/llapi/EventAPI.cpp +++ b/LiteLoader/src/llapi/EventAPI.cpp @@ -1825,28 +1825,29 @@ TInstanceHook(void*, "?handle@ComplexInventoryTransaction@@UEBA?AW4InventoryTran return original(this, player, isSenderAuthority); } -// 没有这个符号 -// TInstanceHook(void, "?dropSlot@Inventory@@QEAAXH_N00@Z", -// Container, int a2, char a3, char a4, bool a5) { -// auto pl = dAccess(this); -// if (pl->isPlayer()) { -// IF_LISTENED(PlayerDropItemEvent) { -// PlayerDropItemEvent ev{}; -// if (a2 >= 0) { -// auto& item = this->getItem(a2); -// if (!item.isNull()) { -// ev.mItemStack = const_cast(&item); -// ev.mPlayer = pl; -// } -// if (!ev.call()) { -// return; -// } -// } -// } -// IF_LISTENED_END(PlayerDropItemEvent) -// } -// return original(this, a2, a3, a4, a5); -// } +// 更换符号,逻辑大概一致,未清楚玩家丢物品是否调用 +#include + TInstanceHook(void, "?dropSlot@FillingContainer@@QEAAXH_N00@Z", + FillingContainer, signed int slot, char unk) { + auto player = dAccess(this); + if (player->isPlayer()) { + IF_LISTENED(PlayerDropItemEvent) { + PlayerDropItemEvent ev{}; + if (slot >= 0) { + auto& item = this->getItem(slot); + if (!item.isNull()) { + ev.mItemStack = const_cast(&item); + ev.mPlayer = player; + } + if (!ev.call()) { + return; + } + } + } + IF_LISTENED_END(PlayerDropItemEvent) + } + return original(this, slot, unk); + } ////////////// PlayerBedEnter ////////////// TInstanceHook(int, "?startSleepInBed@Player@@UEAA?AW4BedSleepingResult@@AEBVBlockPos@@@Z",