修改HandleRequestAction事件
This commit is contained in:
Vendored
+11
-5
@@ -123,7 +123,7 @@ declare class Event {
|
|||||||
/** 死亡信息键名 */
|
/** 死亡信息键名 */
|
||||||
deathMsgKey: string,
|
deathMsgKey: string,
|
||||||
/** 死亡信息翻译参数 */
|
/** 死亡信息翻译参数 */
|
||||||
deathMsgParams: Array.<string>,
|
deathMsgParams: string[],
|
||||||
/** 死亡实体的实体对象 */
|
/** 死亡实体的实体对象 */
|
||||||
entity: Entity
|
entity: Entity
|
||||||
) => void
|
) => void
|
||||||
@@ -215,10 +215,16 @@ declare class Event {
|
|||||||
player: Player,
|
player: Player,
|
||||||
/** 请求类型 */
|
/** 请求类型 */
|
||||||
actionType: string,
|
actionType: string,
|
||||||
/** 容器枚举名 */
|
/** 请求数量 */
|
||||||
containerNetId: string,
|
count: number,
|
||||||
/** 请求的槽位 */
|
/** 第一个格子的容器类型 */
|
||||||
slot: number
|
sourceContainerNetId: string,
|
||||||
|
/** 第一个格子的槽位 */
|
||||||
|
sourceSlot: number,
|
||||||
|
/** 第二个格子的容器类型 */
|
||||||
|
destinationContainerNetId: string,
|
||||||
|
/** 第二个格子的槽位 */
|
||||||
|
destinationSlot: number
|
||||||
) => boolean | void
|
) => boolean | void
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "magic_enum.hpp"
|
|
||||||
#include "mc/network/packet/InventorySlotPacket.h"
|
|
||||||
#include "mc/world/Container.h"
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
bool isInteger(const std::string& str) {
|
bool isInteger(const std::string& str) {
|
||||||
std::regex pattern("^[+-]?\\d+$");
|
std::regex pattern("^[+-]?\\d+$");
|
||||||
|
|||||||
+17
-7
@@ -265,21 +265,31 @@ void Export_Event_API() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case doHash("HandleRequestAction"): {
|
case doHash("HandleRequestAction"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<bool(
|
||||||
bool(Player * player, std::string const& actionType, std::string const& containerNetId, int slot)>(
|
Player * player,
|
||||||
eventName,
|
std::string const& actionType,
|
||||||
eventId
|
int count,
|
||||||
);
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot
|
||||||
|
)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<Event::PlayerEvent::HandleRequestActionBeforeEvent>(
|
eventBus->emplaceListener<Event::PlayerEvent::HandleRequestActionBeforeEvent>(
|
||||||
[Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) {
|
[Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try {
|
try {
|
||||||
auto requestAction = (ItemStackRequestActionTransferBase*)&ev.getRequestAction();
|
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(
|
result = Call(
|
||||||
&ev.self(),
|
&ev.self(),
|
||||||
magic_enum::enum_name(requestAction->mActionType).data(),
|
magic_enum::enum_name(requestAction->mActionType).data(),
|
||||||
magic_enum::enum_name(requestAction->getSrc().mOpenContainerNetId).data(),
|
ll::memory::dAccess<uchar>(requestAction, 18),
|
||||||
requestAction->getSrc().mSlot
|
magic_enum::enum_name(source.mOpenContainerNetId).data(),
|
||||||
|
source.mSlot,
|
||||||
|
magic_enum::enum_name(destination.mOpenContainerNetId).data(),
|
||||||
|
destination.mSlot
|
||||||
);
|
);
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user