Fix Some EventAPI

This commit is contained in:
Qiuzhizhe 2022-10-27 15:04:16 +08:00
parent da82876fe0
commit f82f7108d7
No known key found for this signature in database
GPG Key ID: 4EF4BF5521540263
3 changed files with 185 additions and 183 deletions

View File

@ -382,7 +382,7 @@ public:
BlockInstance mPreviousBlockInstance; BlockInstance mPreviousBlockInstance;
BlockInstance mNewBlockInstance; BlockInstance mNewBlockInstance;
}; };
// TODO 没找到合适点位
class BlockExplodedEvent : public EventTemplate<BlockExplodedEvent> { class BlockExplodedEvent : public EventTemplate<BlockExplodedEvent> {
public: public:
BlockInstance mBlockInstance; BlockInstance mBlockInstance;

View File

@ -324,7 +324,6 @@ TClasslessInstanceHook(void, "?sendLoginMessageLocal@ServerNetworkHandler@@QEAAX
/////////////////// PlayerJoin /////////////////// /////////////////// PlayerJoin ///////////////////
TInstanceHook(bool, "?onReady_ClientGeneration@ServerNetworkHandler@@QEAAXAEAVPlayer@@AEBVNetworkIdentifier@@@Z", TInstanceHook(bool, "?onReady_ClientGeneration@ServerNetworkHandler@@QEAAXAEAVPlayer@@AEBVNetworkIdentifier@@@Z",
ServerNetworkHandler,Player* player,NetworkIdentifier *net) { ServerNetworkHandler,Player* player,NetworkIdentifier *net) {
//std::cout<<"PlayerJoin"<<std::endl;
IF_LISTENED(PlayerJoinEvent) { IF_LISTENED(PlayerJoinEvent) {
PlayerJoinEvent ev{}; PlayerJoinEvent ev{};
ev.mPlayer = player; ev.mPlayer = player;
@ -340,7 +339,6 @@ TClasslessInstanceHook(void, "?sendLoginMessageLocal@ServerNetworkHandler@@QEAAX
/////////////////// PlayerLeft /////////////////// /////////////////// PlayerLeft ///////////////////
TInstanceHook(void, "?_onPlayerLeft@ServerNetworkHandler@@AEAAXPEAVServerPlayer@@_N@Z", TInstanceHook(void, "?_onPlayerLeft@ServerNetworkHandler@@AEAAXPEAVServerPlayer@@_N@Z",
ServerNetworkHandler,ServerPlayer* sp,char a3) { ServerNetworkHandler,ServerPlayer* sp,char a3) {
//std::cout<<"PlayerJoin"<<std::endl;
IF_LISTENED(PlayerLeftEvent) { IF_LISTENED(PlayerLeftEvent) {
PlayerLeftEvent ev{}; PlayerLeftEvent ev{};
ev.mPlayer = sp; ev.mPlayer = sp;
@ -404,6 +402,7 @@ public:
if (request->mToDimensionId == sp->getDimensionId()) if (request->mToDimensionId == sp->getDimensionId())
return original(this, sp, std::move(request)); return original(this, sp, std::move(request));
// printf("PlayerChangeDimension Player:%s, DimensionID:%s\n",sp->getNameTag().c_str(),request->mToDimensionId);
IF_LISTENED(PlayerChangeDimEvent) { IF_LISTENED(PlayerChangeDimEvent) {
PlayerChangeDimEvent ev{}; PlayerChangeDimEvent ev{};
ev.mPlayer = sp; ev.mPlayer = sp;
@ -431,6 +430,7 @@ TInstanceHook(void, "?jumpFromGround@Player@@UEAAXXZ", Player) {
//不清楚这个符合能不能正常触发 //不清楚这个符合能不能正常触发
TClasslessInstanceHook(void, "?onActorSneakChanged@ScriptServerActorEventListener@@UEAA?AW4EventResult@@AEAVActor@@_N@Z", TClasslessInstanceHook(void, "?onActorSneakChanged@ScriptServerActorEventListener@@UEAA?AW4EventResult@@AEAVActor@@_N@Z",
Actor* ac, bool isSneaking) { Actor* ac, bool isSneaking) {
// printf("PlayerSneak Player:%s, IsSneaking:%s\n",ac->getNameTag().c_str(),isSneaking);
IF_LISTENED(PlayerSneakEvent) { IF_LISTENED(PlayerSneakEvent) {
PlayerSneakEvent ev{}; PlayerSneakEvent ev{};
ev.mPlayer = (Player*)ac; ev.mPlayer = (Player*)ac;
@ -572,17 +572,18 @@ TInstanceHook(void, "?onEffectRemoved@ServerPlayer@@MEAAXAEAVMobEffectInstance@@
/////////////////// PlayerStartDestroyBlock /////////////////// /////////////////// PlayerStartDestroyBlock ///////////////////
// 没有这个符号 // 没有这个符号
// TClasslessInstanceHook(void, "?sendBlockDestructionStarted@BlockEventCoordinator@@QEAAXAEAVPlayer@@AEBVBlockPos@@@Z", // 更换点位
// Player* pl, BlockPos* bp) { TClasslessInstanceHook(void, "?startDestroyBlock@GameMode@@UEAA_NAEBVBlockPos@@EAEA_N@Z",
// IF_LISTENED(PlayerStartDestroyBlockEvent) { Player* pl, BlockPos* bp, unsigned __int8 face, bool *hasDestroyedBlock) {
// PlayerStartDestroyBlockEvent ev{}; IF_LISTENED(PlayerStartDestroyBlockEvent) {
// ev.mPlayer = pl; PlayerStartDestroyBlockEvent ev{};
// ev.mBlockInstance = Level::getBlockInstance(bp, Level::getBlockSource(pl)); ev.mPlayer = pl;
// ev.call(); ev.mBlockInstance = Level::getBlockInstance(bp, Level::getBlockSource(pl));
// } ev.call();
// IF_LISTENED_END(PlayerStartDestroyBlockEvent) }
// return original(this, pl, bp); IF_LISTENED_END(PlayerStartDestroyBlockEvent)
// } return original(this, pl, bp,face,hasDestroyedBlock);
}
/////////////////// PlayerPlaceBlock /////////////////// /////////////////// PlayerPlaceBlock ///////////////////
#include <MC/ItemUseInventoryTransaction.hpp> #include <MC/ItemUseInventoryTransaction.hpp>
@ -998,31 +999,30 @@ TInstanceHook(void, "?setSprinting@Mob@@UEAAX_N@Z",
#include <MC/PlayerInventory.hpp> #include <MC/PlayerInventory.hpp>
#include <MC/SimpleContainer.hpp> #include <MC/SimpleContainer.hpp>
/////////////////// PlayerSetArmor /////////////////// /////////////////// PlayerSetArmor ///////////////////
// TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z",
// Player, unsigned slot, ItemStack* it) { Player, unsigned slot, ItemStack* it) {
// original(this, slot, it); original(this, slot, it);
// IF_LISTENED(PlayerSetArmorEvent) { IF_LISTENED(PlayerSetArmorEvent) {
// if (this->isPlayer()) { if (this->isPlayer()) {
// PlayerSetArmorEvent ev{}; PlayerSetArmorEvent ev{};
// ev.mPlayer = this; ev.mPlayer = this;
// ev.mSlot = slot; ev.mSlot = slot;
// ev.mArmorItem = it; ev.mArmorItem = it;
// if (!ev.call()) { if (!ev.call()) {
// auto& uid = getUniqueID(); auto& uid = getUniqueID();
// auto& plinv = getSupplies(); this->add(*it);
// plinv.add(*it, 1); getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM);
// getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM); Schedule::delay([uid] {
// Schedule::delay([uid] { auto sp = Global<Level>->getPlayer(uid);
// auto sp = Global<Level>->getPlayer(uid); if (sp)
// if (sp) sp->refreshInventory();
// sp->refreshInventory(); },
// }, 1);
// 1); }
// } }
// } }
// } IF_LISTENED_END(PlayerSetArmorEvent)
// IF_LISTENED_END(PlayerSetArmorEvent) }
// }
/////////////////// PlayerUseRespawnAnchor /////////////////// /////////////////// PlayerUseRespawnAnchor ///////////////////
TInstanceHook(bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z", TInstanceHook(bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z",
@ -1051,64 +1051,64 @@ TInstanceHook(bool, "?canOpenContainerScreen@Player@@UEAA_NXZ", Player) {
} }
/////////////////// PlayerCmdEvent & ConsoleCmd /////////////////// /////////////////// PlayerCmdEvent & ConsoleCmd ///////////////////
// TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z", TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z",
// MCRESULT* rtn, std::shared_ptr<CommandContext> context, bool print) { MCRESULT* rtn, std::shared_ptr<CommandContext> context, bool print) {
// Player* sp; Player* sp;
// string cmd; string cmd;
// try { try {
// sp = context->getOrigin().getPlayer(); sp = context->getOrigin().getPlayer();
// cmd = context->getCmd(); cmd = context->getCmd();
// if (!cmd.empty() && cmd.at(0) == '/') { if (!cmd.empty() && cmd.at(0) == '/') {
// cmd = cmd.substr(1, cmd.size() - 1); cmd = cmd.substr(1, cmd.size() - 1);
// } }
// if (!Util::isValidUTF8(cmd)) { if (!Util::isValidUTF8(cmd)) {
// logger.error("Detected invalid utf-8 character, command will not be executed"); logger.error("Detected invalid utf-8 character, command will not be executed");
// return rtn; return rtn;
// } }
// } catch (...) { } catch (...) {
// return rtn; return rtn;
// } }
// if (LL::isDebugMode() && LL::globalConfig.tickThreadId != std::this_thread::get_id()) { if (LL::isDebugMode() && LL::globalConfig.tickThreadId != std::this_thread::get_id()) {
// logger.warn("The thread executing the command \"{}\" is not the \"MC_SERVER\" thread", cmd); logger.warn("The thread executing the command \"{}\" is not the \"MC_SERVER\" thread", cmd);
// } }
// if (sp) { if (sp) {
// // PlayerCmd // PlayerCmd
// IF_LISTENED(PlayerCmdEvent) { IF_LISTENED(PlayerCmdEvent) {
// PlayerCmdEvent ev{}; PlayerCmdEvent ev{};
// ev.mCommand = cmd; ev.mCommand = cmd;
// ev.mPlayer = sp; ev.mPlayer = sp;
// ev.mResult = rtn; ev.mResult = rtn;
// if (!ev.call()) if (!ev.call())
// return rtn; return rtn;
// if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') if (ev.mCommand.empty() || ev.mCommand.at(0) != '/')
// context->getCmd() = "/" + ev.mCommand; context->getCmd() = "/" + ev.mCommand;
// else else
// context->getCmd() = ev.mCommand; context->getCmd() = ev.mCommand;
// } }
// IF_LISTENED_END(PlayerCmdEvent) IF_LISTENED_END(PlayerCmdEvent)
// } else { } else {
// // ConsoleCmd // ConsoleCmd
// IF_LISTENED(ConsoleCmdEvent) { IF_LISTENED(ConsoleCmdEvent) {
// ConsoleCmdEvent ev{}; ConsoleCmdEvent ev{};
// ev.mCommand = cmd; ev.mCommand = cmd;
// if (!ev.call()) if (!ev.call())
// return rtn; return rtn;
// if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') if (ev.mCommand.empty() || ev.mCommand.at(0) != '/')
// context->getCmd() = "/" + ev.mCommand; context->getCmd() = "/" + ev.mCommand;
// else else
// context->getCmd() = ev.mCommand; context->getCmd() = ev.mCommand;
// } }
// IF_LISTENED_END(ConsoleCmdEvent) IF_LISTENED_END(ConsoleCmdEvent)
// } }
// return original(this, rtn, context, print); return original(this, rtn, context, print);
// } }
/////////////////// PlayerExperienceAddEvent /////////////////// /////////////////// PlayerExperienceAddEvent ///////////////////
TInstanceHook(void, "?addExperience@Player@@UEAAXH@Z", Player, int exp) { TInstanceHook(void, "?addExperience@Player@@UEAAXH@Z", Player, int exp) {
@ -1129,8 +1129,8 @@ TInstanceHook(void, "?handle@ItemUseOnActorInventoryTransaction@@UEBA?AW4Invento
IF_LISTENED(PlayerInteractEntityEvent) { IF_LISTENED(PlayerInteractEntityEvent) {
PlayerInteractEntityEvent ev{}; PlayerInteractEntityEvent ev{};
ev.mPlayer = sp; ev.mPlayer = sp;
ev.mTargetId = dAccess<ActorRuntimeID, 104>(this); ev.mTargetId = dAccess<ActorRuntimeID, 104>(this);//正确
ev.mInteractiveMode = static_cast<PlayerInteractEntityEvent::InteractiveMode>(dAccess<int, 112>(this)); ev.mInteractiveMode = static_cast<PlayerInteractEntityEvent::InteractiveMode>(dAccess<int, 112>(this));//看起来应该正确
if (!ev.call()) if (!ev.call())
return; return;
} }
@ -1140,25 +1140,25 @@ TInstanceHook(void, "?handle@ItemUseOnActorInventoryTransaction@@UEBA?AW4Invento
} }
/////////////////// CmdBlockExecute /////////////////// /////////////////// CmdBlockExecute ///////////////////
// TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z", TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z",
// BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) { BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) {
// IF_LISTENED(CmdBlockExecuteEvent) { IF_LISTENED(CmdBlockExecuteEvent) {
// CmdBlockExecuteEvent ev{}; CmdBlockExecuteEvent ev{};
// ev.mCommand = this->getCommand(); ev.mCommand = this->getCommand();
// if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) { if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) {
// ev.mIsMinecart = true; ev.mIsMinecart = true;
// ev.mMinecart = a3->getEntity(); ev.mMinecart = a3->getEntity();
// } else { } else {
// ev.mIsMinecart = false; ev.mIsMinecart = false;
// ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2); ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2);
// } }
// if (!ev.call()) if (!ev.call())
// return false; return false;
// } }
// IF_LISTENED_END(CmdBlockExecuteEvent) IF_LISTENED_END(CmdBlockExecuteEvent)
// return original(this, a2, a3, a4); return original(this, a2, a3, a4);
// } }
/////////////////// BlockInteracted /////////////////// /////////////////// BlockInteracted ///////////////////
TClasslessInstanceHook(unsigned short, TClasslessInstanceHook(unsigned short,
@ -1177,19 +1177,20 @@ TClasslessInstanceHook(unsigned short,
/////////////////// BlockChanged /////////////////// /////////////////// BlockChanged ///////////////////
// 没有这个符号 // 没有这个符号
// TInstanceHook(void, "?_blockChanged@BlockSource@@IEAAXAEBVBlockPos@@IAEBVBlock@@1HPEBUActorBlockSyncMessage@@PEAVActor@@@Z", // 更换点位
// BlockSource, BlockPos* bp, int a3, Block* afterBlock, Block* beforeBlock, int a6, void* a7, Actor* ac) { TInstanceHook(void, "?onBlockChanged@Dimension@@UEAAXAEAVBlockSource@@AEBVBlockPos@@IAEBVBlock@@2HPEBUActorBlockSyncMessage@@@Z",
// IF_LISTENED(BlockChangedEvent) { Dimension, BlockSource *bs, BlockPos* bp, int a4, Block* afterBlock, Block* beforeBlock, int a7, void* a8) {
// int dimId = this->getDimensionId(); IF_LISTENED(BlockChangedEvent) {
// BlockChangedEvent ev{}; int dimId = this->getDimensionId();
// ev.mPreviousBlockInstance = BlockInstance::createBlockInstance(beforeBlock, *bp, dimId); BlockChangedEvent ev{};
// ev.mNewBlockInstance = BlockInstance::createBlockInstance(afterBlock, *bp, dimId); ev.mPreviousBlockInstance = BlockInstance::createBlockInstance(beforeBlock, *bp, dimId);
// if (!ev.call()) ev.mNewBlockInstance = BlockInstance::createBlockInstance(afterBlock, *bp, dimId);
// return; if (!ev.call())
// } return;
// IF_LISTENED_END(BlockChangedEvent) }
// return original(this, bp, a3, afterBlock, beforeBlock, a6, a7, ac); IF_LISTENED_END(BlockChangedEvent)
// } return original(this, bs, bp, a4, afterBlock, beforeBlock, a7, a8);
}
/////////////////// BlockExploded /////////////////// /////////////////// BlockExploded ///////////////////
// 没有这个符号 // 没有这个符号
@ -1354,7 +1355,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockS
// 没有这个符号 // 没有这个符号
TClasslessInstanceHook(bool, "?_pullInItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@@Z", TClasslessInstanceHook(bool, "?_pullInItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@@Z",
BlockSource* bs, void* container, Vec3* pos) { BlockSource* bs, void* container, Vec3* pos) {
bool isMinecart = dAccess<bool>(this, 5); // IDA Hopper::Hopper bool isMinecart = dAccess<bool>(this, 5); // IDA Hopper::Hopper 未知正确
IF_LISTENED(HopperSearchItemEvent) { IF_LISTENED(HopperSearchItemEvent) {
HopperSearchItemEvent ev{}; HopperSearchItemEvent ev{};
@ -1587,24 +1588,24 @@ TInstanceHook(bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAE
/////////////////// MobHurt /////////////////// /////////////////// MobHurt ///////////////////
// TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z", TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@H_N1@Z",
// Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) { Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) {
// IF_LISTENED(MobHurtEvent) { IF_LISTENED(MobHurtEvent) {
// if (this) { if (this) {
// MobHurtEvent ev{}; MobHurtEvent ev{};
// ev.mMob = this; ev.mMob = this;
// ev.mDamageSource = &src; ev.mDamageSource = &src;
// ev.mDamage = damage; ev.mDamage = damage;
// if (!ev.call()) if (!ev.call())
// return false; return false;
// damage = ev.mDamage;
// }
// }
// IF_LISTENED_END(MobHurtEvent)
// return original(this, src, damage, unk1_1, unk2_0);
// }
damage = ev.mDamage;
}
}
IF_LISTENED_END(MobHurtEvent)
return original(this, src, damage, unk1_1, unk2_0);
}
// 没有这个符号
// TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) { // TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) {
// if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) { // if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) {
// IF_LISTENED(MobHurtEvent) { // IF_LISTENED(MobHurtEvent) {
@ -1625,16 +1626,16 @@ TInstanceHook(bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAE
//////////////// PlayerUseItem & PlayerEat //////////////// //////////////// PlayerUseItem & PlayerEat ////////////////
// #include <MC/ComponentItem.hpp> // #include <MC/ComponentItem.hpp>
// TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) { TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) {
// auto pl = this->getPlayer(); auto pl = this->getPlayer();
// IF_LISTENED(PlayerUseItemEvent) { IF_LISTENED(PlayerUseItemEvent) {
// PlayerUseItemEvent ev{}; PlayerUseItemEvent ev{};
// ev.mPlayer = pl; ev.mPlayer = pl;
// ev.mItemStack = &it; ev.mItemStack = &it;
// if (!ev.call()) if (!ev.call())
// return false; return false;
// } }
// IF_LISTENED_END(PlayerUseItemEvent) IF_LISTENED_END(PlayerUseItemEvent)
// IF_LISTENED(PlayerEatEvent) { // IF_LISTENED(PlayerEatEvent) {
// if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) { // if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) {
// PlayerEatEvent ev{}; // PlayerEatEvent ev{};
@ -1647,37 +1648,37 @@ TInstanceHook(bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAE
// } // }
// } // }
// IF_LISTENED_END(PlayerEatEvent) // IF_LISTENED_END(PlayerEatEvent)
// return original(this, it); return original(this, it);
// } }
// THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) { THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) {
// if (_this->getFullItemName() == "minecraft:milk_bucket") { if (_this->getFullItemName() == "minecraft:milk_bucket") {
// IF_LISTENED(PlayerEatEvent) { IF_LISTENED(PlayerEatEvent) {
// PlayerEatEvent ev{}; PlayerEatEvent ev{};
// ev.mPlayer = a2; ev.mPlayer = a2;
// ev.mFoodItem = a1; ev.mFoodItem = a1;
// if (!ev.call()) { if (!ev.call()) {
// return a1; return a1;
// } }
// } }
// IF_LISTENED_END(PlayerEatEvent) IF_LISTENED_END(PlayerEatEvent)
// } }
// return original(_this, a1, a2); return original(_this, a1, a2);
// } }
// THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) { THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) {
// IF_LISTENED(PlayerEatEvent) { IF_LISTENED(PlayerEatEvent) {
// PlayerEatEvent ev{}; PlayerEatEvent ev{};
// ev.mPlayer = a2; ev.mPlayer = a2;
// ev.mFoodItem = a1; ev.mFoodItem = a1;
// if (!ev.call()) { if (!ev.call()) {
// return a1; return a1;
// } }
// } }
// IF_LISTENED_END(PlayerEatEvent) IF_LISTENED_END(PlayerEatEvent)
// return original(_this, a1, a2); return original(_this, a1, a2);
// } }
/////////////////// MobDie /////////////////// /////////////////// MobDie ///////////////////
TInstanceHook(bool, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob, ActorDamageSource* ads) { TInstanceHook(bool, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob, ActorDamageSource* ads) {
@ -2140,11 +2141,11 @@ TClasslessInstanceHook(void, "?handle@?$PacketHandlerDispatcherInstance@VModalFo
ServerPlayer* sp = handler->getServerPlayer(*id, 0); ServerPlayer* sp = handler->getServerPlayer(*id, 0);
if (sp) { if (sp) {
string data; string data;
auto formId = dAccess<int>(packet, 48); auto formId = dAccess<int>(packet, 48);//未验证
if (!dAccess<bool>(packet, 81)) { if (!dAccess<bool>(packet, 81)) {//未验证
if (dAccess<bool>(packet, 72)) { if (dAccess<bool>(packet, 72)) {//未验证
auto json = dAccess<Json::Value>(packet, 56); auto json = dAccess<Json::Value>(packet, 56);//未验证
data = json.toStyledString(); data = json.toStyledString();
} }
} }

View File

@ -294,6 +294,7 @@ Player* Level::getPlayer(const string& info) {
Player* Level::getPlayer(ActorUniqueID id) { Player* Level::getPlayer(ActorUniqueID id) {
// 裂开,这个符号也没有 // 裂开,这个符号也没有
//根据伪代码重新写实现
Actor* actor = Level::fetchEntity(id,0); Actor* actor = Level::fetchEntity(id,0);
if(actor && actor->hasCategory((ActorCategory)1)) if(actor && actor->hasCategory((ActorCategory)1))
return (Player*)actor; return (Player*)actor;