diff --git a/lib/EventAPI-JS.d.ts b/lib/EventAPI-JS.d.ts index 249578f..6be8885 100644 --- a/lib/EventAPI-JS.d.ts +++ b/lib/EventAPI-JS.d.ts @@ -123,7 +123,7 @@ declare class Event { /** 死亡信息键名 */ deathMsgKey: string, /** 死亡信息翻译参数 */ - deathMsgParams: Array., + deathMsgParams: string[], /** 死亡实体的实体对象 */ entity: Entity ) => void @@ -215,10 +215,16 @@ declare class Event { player: Player, /** 请求类型 */ actionType: string, - /** 容器枚举名 */ - containerNetId: string, - /** 请求的槽位 */ - slot: number + /** 请求数量 */ + count: number, + /** 第一个格子的容器类型 */ + sourceContainerNetId: string, + /** 第一个格子的槽位 */ + sourceSlot: number, + /** 第二个格子的容器类型 */ + destinationContainerNetId: string, + /** 第二个格子的槽位 */ + destinationSlot: number ) => boolean | void ): boolean; diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 3889da4..00e10a1 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -1,10 +1,5 @@ #include "Global.h" -#include "magic_enum.hpp" -#include "mc/network/packet/InventorySlotPacket.h" -#include "mc/world/Container.h" -#include #include -#include bool isInteger(const std::string& str) { std::regex pattern("^[+-]?\\d+$"); diff --git a/src/EventAPI.cpp b/src/EventAPI.cpp index c33c9ad..e0134cb 100644 --- a/src/EventAPI.cpp +++ b/src/EventAPI.cpp @@ -265,21 +265,31 @@ void Export_Event_API() { return true; } case doHash("HandleRequestAction"): { - auto Call = RemoteCall::importAs< - bool(Player * player, std::string const& actionType, std::string const& containerNetId, int slot)>( - eventName, - eventId - ); + auto Call = RemoteCall::importAs(eventName, eventId); eventBus->emplaceListener( [Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) { bool result = true; try { auto requestAction = (ItemStackRequestActionTransferBase*)&ev.getRequestAction(); - result = Call( + auto source = requestAction->getSrc(); + // TODO: The next version of LeviLamina changes to a member function + auto destination = ll::memory::dAccess(requestAction, 56); + result = Call( &ev.self(), magic_enum::enum_name(requestAction->mActionType).data(), - magic_enum::enum_name(requestAction->getSrc().mOpenContainerNetId).data(), - requestAction->getSrc().mSlot + ll::memory::dAccess(requestAction, 18), + magic_enum::enum_name(source.mOpenContainerNetId).data(), + source.mSlot, + magic_enum::enum_name(destination.mOpenContainerNetId).data(), + destination.mSlot ); } catch (...) {} if (!result) {