修改HandleRequestAction事件
This commit is contained in:
Vendored
+11
-5
@@ -123,7 +123,7 @@ declare class Event {
|
||||
/** 死亡信息键名 */
|
||||
deathMsgKey: string,
|
||||
/** 死亡信息翻译参数 */
|
||||
deathMsgParams: Array.<string>,
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#include "Global.h"
|
||||
#include "magic_enum.hpp"
|
||||
#include "mc/network/packet/InventorySlotPacket.h"
|
||||
#include "mc/world/Container.h"
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
bool isInteger(const std::string& str) {
|
||||
std::regex pattern("^[+-]?\\d+$");
|
||||
|
||||
+17
-7
@@ -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<bool(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
)>(eventName, eventId);
|
||||
eventBus->emplaceListener<Event::PlayerEvent::HandleRequestActionBeforeEvent>(
|
||||
[Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) {
|
||||
bool result = true;
|
||||
try {
|
||||
auto requestAction = (ItemStackRequestActionTransferBase*)&ev.getRequestAction();
|
||||
auto source = requestAction->getSrc();
|
||||
// TODO: The next version of LeviLamina changes to a member function
|
||||
auto destination = ll::memory::dAccess<ItemStackRequestSlotInfo>(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<uchar>(requestAction, 18),
|
||||
magic_enum::enum_name(source.mOpenContainerNetId).data(),
|
||||
source.mSlot,
|
||||
magic_enum::enum_name(destination.mOpenContainerNetId).data(),
|
||||
destination.mSlot
|
||||
);
|
||||
} catch (...) {}
|
||||
if (!result) {
|
||||
|
||||
Reference in New Issue
Block a user