From 5710878d29d95713f35bf0788eb2cc9e84ba93da Mon Sep 17 00:00:00 2001 From: Qiuzhizhe <42761326+quizhizhe@users.noreply.github.com> Date: Sun, 2 Oct 2022 01:14:35 -0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=AC=A6=E5=90=88=E7=9A=84EventAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Header/MC/ActorDefinitionIdentifier.hpp | 5 + LiteLoader/Kernel/EventAPI.cpp | 397 +++++++++--------- 2 files changed, 202 insertions(+), 200 deletions(-) diff --git a/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp b/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp index b927c94..cf787fd 100644 --- a/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp +++ b/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp @@ -16,6 +16,11 @@ std::string identifier; // 32 std::string event; // 64 std::string fullname; // 96 HashedString canonicalHash; // 128 + +public: + inline const std::string getCanonicalName(){ + return this->canonicalHash.getString(); + } #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONIDENTIFIER public: diff --git a/LiteLoader/Kernel/EventAPI.cpp b/LiteLoader/Kernel/EventAPI.cpp index a8b000a..6d46d00 100644 --- a/LiteLoader/Kernel/EventAPI.cpp +++ b/LiteLoader/Kernel/EventAPI.cpp @@ -321,7 +321,6 @@ TClasslessInstanceHook(void, "?sendLoginMessageLocal@ServerNetworkHandler@@QEAAX /////////////////// PlayerJoin /////////////////// -//没有这个符号 TInstanceHook(bool, "?onReady_ClientGeneration@ServerNetworkHandler@@QEAAXAEAVPlayer@@AEBVNetworkIdentifier@@@Z", ServerNetworkHandler,Player* player,NetworkIdentifier *net) { IF_LISTENED(PlayerJoinEvent) { @@ -397,23 +396,23 @@ public: std::unique_ptr mAgentTag; }; -//没有这个符号 -// TClasslessInstanceHook(bool, "?requestPlayerChangeDimension@Level@@UEAAXAEAVPlayer@@V?$unique_ptr@VChangeDimensionRequest@@U?$default_delete@VChangeDimensionRequest@@@std@@@std@@@Z", -// Player* sp, std::unique_ptr request) { +// 更换符号 + TClasslessInstanceHook(bool, "?requestPlayerChangeDimension@Level@@QEAAXAEAVPlayer@@V?$unique_ptr@VChangeDimensionRequest@@U?$default_delete@VChangeDimensionRequest@@@std@@@std@@@Z", + Player* sp, std::unique_ptr request) { -// if (request->mToDimensionId == sp->getDimensionId()) -// return original(this, sp, std::move(request)); + if (request->mToDimensionId == sp->getDimensionId()) + return original(this, sp, std::move(request)); -// IF_LISTENED(PlayerChangeDimEvent) { -// PlayerChangeDimEvent ev{}; -// ev.mPlayer = sp; -// ev.mToDimensionId = request->mToDimensionId; -// if (!ev.call()) -// return false; -// } -// IF_LISTENED_END(PlayerChangeDimEvent) -// return original(this, sp, std::move(request)); -// } + IF_LISTENED(PlayerChangeDimEvent) { + PlayerChangeDimEvent ev{}; + ev.mPlayer = sp; + ev.mToDimensionId = request->mToDimensionId; + if (!ev.call()) + return false; + } + IF_LISTENED_END(PlayerChangeDimEvent) + return original(this, sp, std::move(request)); + } int num = 0; /////////////////// PlayerJump /////////////////// @@ -428,40 +427,39 @@ TInstanceHook(void, "?jumpFromGround@Player@@UEAAXXZ", Player) { } /////////////////// PlayerSneak /////////////////// -//没有这个符号 -// TClasslessInstanceHook(void, "?sendActorSneakChanged@ActorEventCoordinator@@QEAAXAEAVActor@@_N@Z", -// Actor* ac, bool isSneaking) { -// IF_LISTENED(PlayerSneakEvent) { -// PlayerSneakEvent ev{}; -// ev.mPlayer = (Player*)ac; -// ev.mIsSneaking = isSneaking; -// ev.call(); +//不清楚这个符合能不能正常触发 + TClasslessInstanceHook(void, "?onActorSneakChanged@ScriptServerActorEventListener@@UEAA?AW4EventResult@@AEAVActor@@_N@Z", + Actor* ac, bool isSneaking) { + IF_LISTENED(PlayerSneakEvent) { + PlayerSneakEvent ev{}; + ev.mPlayer = (Player*)ac; + ev.mIsSneaking = isSneaking; + ev.call(); -// isSneaking = ev.mIsSneaking; -// } -// IF_LISTENED_END(PlayerSneakEvent) -// return original(this, ac, isSneaking); -// } + isSneaking = ev.mIsSneaking; + } + IF_LISTENED_END(PlayerSneakEvent) + return original(this, ac, isSneaking); + } /////////////////// PlayerAttackEntity /////////////////// -//没有这个符号 -// TInstanceHook(bool, "?attack@Player@@UEAA_NAEAVActor@@AEBW4ActorDamageCause@@@Z", -// Player, Actor* ac, int* damageCause) { -// IF_LISTENED(PlayerAttackEvent) { -// PlayerAttackEvent ev{}; -// ev.mPlayer = this; -// ev.mTarget = ac; -// ev.mAttackDamage = *damageCause; -// if (!ev.call()) -// return false; +//同名函数没有了伤害原因参数 + TInstanceHook(bool, "?attack@Player@@UEAA_NAEAVActor@@@Z", + Player, Actor* ac) { + IF_LISTENED(PlayerAttackEvent) { + PlayerAttackEvent ev{}; + ev.mPlayer = this; + ev.mTarget = ac; + ev.mAttackDamage = this->calculateAttackDamage(*ac); + if (!ev.call()) + return false; -// ac = ev.mTarget; -// *damageCause = ev.mAttackDamage; -// } -// IF_LISTENED_END(PlayerAttackEvent) -// return original(this, ac, damageCause); -// } + ac = ev.mTarget; + } + IF_LISTENED_END(PlayerAttackEvent) + return original(this, ac); + } /////////////////// PlayerAttackBlock /////////////////// //没有这个符号 @@ -557,18 +555,18 @@ TInstanceHook(void, "?onEffectRemoved@ServerPlayer@@MEAAXAEAVMobEffectInstance@@ return original(this, effect); } // update -// 没有这个符号 -// TInstanceHook(void, "?onEffectUpdated@ServerPlayer@@MEAAXAEAVMobEffectInstance@@@Z", Player, MobEffectInstance* effect) { -// IF_LISTENED(PlayerEffectChangedEvent) { -// PlayerEffectChangedEvent ev{}; -// ev.mPlayer = this; -// ev.mEventType = PlayerEffectChangedEvent::EventType::Update; -// ev.mEffect = effect; -// ev.call(); -// } -// IF_LISTENED_END(PlayerEffectChangedEvent) -// return original(this, effect); -// } +// 更换符号 + TInstanceHook(void, "?onEffectUpdated@ServerPlayer@@MEAAXAEBVMobEffectInstance@@@Z", Player, MobEffectInstance* effect) { + IF_LISTENED(PlayerEffectChangedEvent) { + PlayerEffectChangedEvent ev{}; + ev.mPlayer = this; + ev.mEventType = PlayerEffectChangedEvent::EventType::Update; + ev.mEffect = effect; + ev.call(); + } + IF_LISTENED_END(PlayerEffectChangedEvent) + return original(this, effect); + } /////////////////// PlayerStartDestroyBlock /////////////////// @@ -587,24 +585,24 @@ TInstanceHook(void, "?onEffectRemoved@ServerPlayer@@MEAAXAEAVMobEffectInstance@@ /////////////////// PlayerPlaceBlock /////////////////// #include -// 没有这个符号 -// TInstanceHook(char, "?checkBlockPermissions@BlockSource@@QEAA_NAEAVActor@@AEBVBlockPos@@EAEBVItemStackBase@@_N@Z", -// BlockSource, Actor* ac, BlockPos* bp, unsigned __int8 facing, ItemStackBase* item, bool a6) { -// if (ac->isPlayer()) { -// IF_LISTENED(PlayerPlaceBlockEvent) { -// auto pl = (Player*)ac; -// PlayerPlaceBlockEvent ev{}; -// ev.mPlayer = pl; -// ev.mBlockInstance = this->getBlockInstance(*bp); -// if (!ev.call()) { // this pointer is not used. -// ((ItemUseInventoryTransaction*)nullptr)->resendBlocksAroundArea(*pl, *bp, facing); -// return false; -// } -// } -// IF_LISTENED_END(PlayerPlaceBlockEvent) -// } -// return original(this, ac, bp, facing, item, a6); -// } +// 符号变更 + TInstanceHook(char, "?checkBlockPermissions@BlockSource@@QEAA_NAEAVActor@@AEBVBlockPos@@EAEBVItemStack@@_N@Z", + BlockSource, Actor* ac, BlockPos* bp, unsigned __int8 facing, ItemStackBase* item, bool a6) { + if (ac->isPlayer()) { + IF_LISTENED(PlayerPlaceBlockEvent) { + auto pl = (Player*)ac; + PlayerPlaceBlockEvent ev{}; + ev.mPlayer = pl; + ev.mBlockInstance = this->getBlockInstance(*bp); + if (!ev.call()) { // this pointer is not used. + ((ItemUseInventoryTransaction*)nullptr)->resendBlocksAroundArea(*pl, *bp, facing); + return false; + } + } + IF_LISTENED_END(PlayerPlaceBlockEvent) + } + return original(this, ac, bp, facing, item, a6); + } /////////////////// BlockPlacedByPlayerEvent /////////////////// TClasslessInstanceHook(void, "?sendBlockPlacedByPlayer@BlockEventCoordinator@@QEAAXAEAVPlayer@@AEBVBlock@@AEBVBlockPos@@_N@Z", @@ -895,23 +893,22 @@ TInstanceHook(bool, "?useOn@SeedItemComponentLegacy@@QEAA_NAEAVItemStack@@AEAVAc */ /////////////////// PlayerOpenContainer /////////////////// -// 没有这个符号 -// TClasslessInstanceHook(__int64, "?onEvent@VanillaServerGameplayEventListener@@UEAA?AW4EventResult@@AEBUPlayerOpenContainerEvent@@@Z", void* a2) { -// Actor* pl = SymCall("??$tryUnwrap@VActor@@$$V@WeakEntityRef@@QEBAPEAVActor@@XZ", Actor*, void*)(a2); -// if (pl->isPlayer()) { -// IF_LISTENED(PlayerOpenContainerEvent) { -// BlockPos bp = dAccess(a2, 28); -// PlayerOpenContainerEvent ev{}; -// ev.mPlayer = (Player*)pl; -// ev.mBlockInstance = Level::getBlockInstance(bp, pl->getDimensionId()); -// ev.mContainer = ev.mBlockInstance.getContainer(); -// if (!ev.call()) -// return 0; -// } -// IF_LISTENED_END(PlayerOpenContainerEvent) -// } -// return original(this, a2); -// } +// 符号更换 + TClasslessInstanceHook(__int64, "?onPlayerOpenContainer@VanillaServerGameplayEventListener@@UEAA?AW4EventResult@@AEAVPlayer@@W4ContainerType@@AEBVBlockPos@@UActorUniqueID@@@Z", + Player* pl, ContainerType type, BlockPos *pos,ActorUniqueID actorUniqueId) { + if (pl->isPlayer()) { + IF_LISTENED(PlayerOpenContainerEvent) { + PlayerOpenContainerEvent ev{}; + ev.mPlayer = pl; + ev.mBlockInstance = Level::getBlockInstance(pos, pl->getDimensionId()); + ev.mContainer = ev.mBlockInstance.getContainer(); + if (!ev.call()) + return 0; + } + IF_LISTENED_END(PlayerOpenContainerEvent) + } + return original(this, pl,type,pos,actorUniqueId); + } /////////////////// PlayerCloseContainer /////////////////// // chest @@ -934,7 +931,7 @@ TInstanceHook(bool, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z", TClasslessInstanceHook(bool, "?stopOpen@BarrelBlockActor@@UEAAXAEAVPlayer@@@Z", Player* pl) { IF_LISTENED(PlayerCloseContainerEvent) { - BlockActor* ba = (BlockActor*)((char*)this - 240); // IDA ChestBlockActor::stopOpen + BlockActor* ba = (BlockActor*)((char*)this - 248); // IDA ChestBlockActor::stopOpen BlockPos bp = ba->getPosition(); PlayerCloseContainerEvent ev{}; @@ -965,20 +962,20 @@ TInstanceHook(void, "?inventoryChanged@Player@@UEAAXAEAVContainer@@HAEBVItemStac } /////////////////// PlayerMove /////////////////// -// 没有这个符号 -// TClasslessInstanceHook(void, "?sendPlayerMove@PlayerEventCoordinator@@QEAAXAEAVPlayer@@@Z", -// Player* pl) { -// IF_LISTENED(PlayerMoveEvent) { -// if (pl->isMoving()) { -// PlayerMoveEvent ev{}; -// ev.mPlayer = pl; -// ev.mPos = pl->getPosition(); -// ev.call(); -// } -// } -// IF_LISTENED_END(PlayerMoveEvent) -// return original(this, pl); -// } +// 更改符号 +TInstanceHook(void, "?move@Player@@UEAAXAEBVVec3@@@Z", + Player, Vec3* pos) { + IF_LISTENED(PlayerMoveEvent) { + if (this->isMoving()) { + PlayerMoveEvent ev{}; + ev.mPlayer = this; + ev.mPos = *pos; + ev.call(); + } + } + IF_LISTENED_END(PlayerMoveEvent) + return original(this, pos); + } /////////////////// PlayerSprint /////////////////// TInstanceHook(void, "?setSprinting@Mob@@UEAAX_N@Z", @@ -1286,7 +1283,7 @@ TClasslessInstanceHook(bool, "?mayPlace@FireBlock@@UEBA_NAEAVBlockSource@@AEBVBl /////////////////// RedStoneUpdate /////////////////// -// 红石�?? +// 红石粉 TClasslessInstanceHook(void, "?onRedstoneUpdate@RedStoneWireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1318,7 +1315,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@RedstoneTorchBlock@@UEBAXAEAVBlo IF_LISTENED_END(RedStoneUpdateEvent) return original(this, bs, bp, level, isActive); } -// 红石中继�?? +// 红石中继器 TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1334,7 +1331,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource IF_LISTENED_END(RedStoneUpdateEvent) return original(this, bs, bp, level, isActive); } -// 红石比较�?? +// 红石比较器 TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1354,26 +1351,26 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockS /////////////////// HopperSearchItem /////////////////// // 没有这个符号 -// TClasslessInstanceHook(bool, "?_tryPullInItemsFromAboveContainer@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@@Z", -// BlockSource* bs, void* container, Vec3* pos) { -// bool isMinecart = dAccess(this, 5); // IDA Hopper::Hopper + TClasslessInstanceHook(bool, "?_pullInItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@@Z", + BlockSource* bs, void* container, Vec3* pos) { + bool isMinecart = dAccess(this, 5); // IDA Hopper::Hopper -// IF_LISTENED(HopperSearchItemEvent) { -// HopperSearchItemEvent ev{}; -// if (isMinecart) { -// ev.isMinecart = true; -// ev.mMinecartPos = *pos; -// } else { -// ev.isMinecart = false; -// ev.mHopperBlock = Level::getBlockInstance(pos->toBlockPos(), bs); -// } -// ev.mDimensionId = bs->getDimensionId(); -// if (!ev.call()) -// return false; -// } -// IF_LISTENED_END(HopperSearchItemEvent) -// return original(this, bs, container, pos); -// } + IF_LISTENED(HopperSearchItemEvent) { + HopperSearchItemEvent ev{}; + if (isMinecart) { + ev.isMinecart = true; + ev.mMinecartPos = *pos; + } else { + ev.isMinecart = false; + ev.mHopperBlock = Level::getBlockInstance(pos->toBlockPos(), bs); + } + ev.mDimensionId = bs->getDimensionId(); + if (!ev.call()) + return false; + } + IF_LISTENED_END(HopperSearchItemEvent) + return original(this, bs, container, pos); + } /////////////////// HopperPushOut /////////////////// TClasslessInstanceHook(bool, "?_pushOutItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@H@Z", @@ -1440,20 +1437,20 @@ TClasslessInstanceHook(void, "?transformOnFall@FarmBlock@@UEBAXAEAVBlockSource@@ /////////////////// PlayerUseFrameBlockEvent /////////////////// -// 没有这个符号 -// TClasslessInstanceHook(bool, "?use@ItemFrameBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", -// Player* a2, BlockPos* a3) { -// IF_LISTENED(PlayerUseFrameBlockEvent) { -// PlayerUseFrameBlockEvent ev{}; -// ev.mType = PlayerUseFrameBlockEvent::Type::Use; -// ev.mBlockInstance = Level::getBlockInstance(a3, a2->getDimensionId()); -// ev.mPlayer = a2; -// if (!ev.call()) -// return false; -// } -// IF_LISTENED_END(PlayerUseFrameBlockEvent) -// return original(this, a2, a3); -// } +// 符号变更 + TClasslessInstanceHook(bool, "?use@ItemFrameBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@@Z", + Player* a2, BlockPos* a3) { + IF_LISTENED(PlayerUseFrameBlockEvent) { + PlayerUseFrameBlockEvent ev{}; + ev.mType = PlayerUseFrameBlockEvent::Type::Use; + ev.mBlockInstance = Level::getBlockInstance(a3, a2->getDimensionId()); + ev.mPlayer = a2; + if (!ev.call()) + return false; + } + IF_LISTENED_END(PlayerUseFrameBlockEvent) + return original(this, a2, a3); + } TClasslessInstanceHook(bool, "?attack@ItemFrameBlock@@UEBA_NPEAVPlayer@@AEBVBlockPos@@@Z", Player* a2, BlockPos* a3) { @@ -1776,39 +1773,39 @@ TClasslessInstanceHook(void, "?explode@Explosion@@QEAAXXZ") { ////////////// WitherBossDestroy ////////////// // 没有这个符号 -// TInstanceHook(void, "?_destroyBlocks@WitherBoss@@AEAAXAEAVLevel@@AEBVAABB@@AEAVBlockSource@@HW4WitherAttackType@1@@Z", -// Actor, Level* a2, AABB* aabb, BlockSource* a4, int a5, unsigned int a6) { -// IF_LISTENED(WitherBossDestroyEvent) { -// WitherBossDestroyEvent ev{}; -// ev.mWitherBoss = (WitherBoss*)this; -// ev.mDestroyRange = *aabb; -// if (!ev.call()) -// return; + THook(void, "?destroyBlocks@@YAXAEAVLevel@@AEBVAABB@@AEAVBlockSource@@H@Z", + Level* level, AABB* aabb, BlockSource* bs, int range) { + IF_LISTENED(WitherBossDestroyEvent) { + WitherBossDestroyEvent ev{}; + ev.mWitherBoss = dAccess(level,-102); // WitherBoss::newServerAiStep Line515 + ev.mDestroyRange = *aabb; + if (!ev.call()) + return; -// *aabb = ev.mDestroyRange; -// } -// IF_LISTENED_END(WitherBossDestroyEvent) -// original(this, a2, aabb, a4, a5, a6); -// } + *aabb = ev.mDestroyRange; + } + IF_LISTENED_END(WitherBossDestroyEvent) + original(level, aabb, bs, range); + } ////////////// EntityRide ////////////// // 没有这个符号 -// TInstanceHook(bool, "?canAddPassenger@Actor@@UEBA_NAEAV1@@Z", -// Actor, Actor* a2) { -// auto rtn = original(this, a2); -// if (!rtn) -// return false; -// IF_LISTENED(EntityRideEvent) { -// EntityRideEvent ev{}; -// ev.mRider = a2; -// ev.mVehicle = this; -// if (!ev.call()) -// return false; -// } -// IF_LISTENED_END(EntityRideEvent) -// return rtn; -// } + TInstanceHook(bool, "?canAddRider@Actor@@UEBA_NAEAV1@@Z", + Actor, Actor* a2) { + auto rtn = original(this, a2); + if (!rtn) + return false; + IF_LISTENED(EntityRideEvent) { + EntityRideEvent ev{}; + ev.mRider = a2; + ev.mVehicle = this; + if (!ev.call()) + return false; + } + IF_LISTENED_END(EntityRideEvent) + return rtn; + } ////////////// EntityStepOnPressurePlate ////////////// @@ -1981,25 +1978,25 @@ TClasslessInstanceHook(void, "?onScoreChanged@ServerScoreboard@@UEAAXAEBUScorebo #include ////////////// ServerStarted ////////////// // 没有这个符号 -// TClasslessInstanceHook(void, "?sendServerThreadStarted@ServerInstanceEventCoordinator@@QEAAXAEAVServerInstance@@@Z", -// class ServerInstance& ins) { -// if(!LL::isDebugMode()) -// _set_se_translator(seh_exception::TranslateSEHtoCE); + TClasslessInstanceHook(void, "?onServerThreadStarted@MinecraftServerScriptEngine@@UEAA?AW4EventResult@@AEAVServerInstance@@@Z", + class ServerInstance& ins) { + if(!LL::isDebugMode()) + _set_se_translator(seh_exception::TranslateSEHtoCE); -// LL::globalConfig.tickThreadId = std::this_thread::get_id(); -// Global = Global->getLevel(); -// Global = (ServerLevel*)Global->getLevel(); -// // Global = Global->getServerNetworkHandler(); -// LL::globalConfig.serverStatus = LL::LLServerStatus::Running; + LL::globalConfig.tickThreadId = std::this_thread::get_id(); + Global = Global->getLevel(); + Global = (ServerLevel*)Global->getLevel(); + // Global = Global->getServerNetworkHandler(); + LL::globalConfig.serverStatus = LL::LLServerStatus::Running; -// IF_LISTENED(ServerStartedEvent) { -// ServerStartedEvent ev{}; -// ev.call(); -// } -// IF_LISTENED_END(ServerStartedEvent) + IF_LISTENED(ServerStartedEvent) { + ServerStartedEvent ev{}; + ev.call(); + } + IF_LISTENED_END(ServerStartedEvent) -// original(this, ins); -// } + original(this, ins); + } ////////////// ServerStopped ////////////// TClasslessInstanceHook(void, "??1DedicatedServer@@UEAA@XZ") { @@ -2118,19 +2115,19 @@ TInstanceHook(int, "?startSleepInBed@Player@@UEAA?AW4BedSleepingResult@@AEBVBloc #include ////////////// MobSpawn ////////////// -// TInstanceHook(Mob*, "?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", -// Spawner, BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3& a5, bool a6, bool a7, bool a8) { -// IF_LISTENED(MobSpawnEvent) { -// MobSpawnEvent ev{}; -// ev.mTypeName = a3->getCanonicalName(); -// ev.mPos = a5; -// ev.mDimensionId = a2->getDimensionId(); -// if (!ev.call()) -// return nullptr; -// } -// IF_LISTENED_END(MobSpawnEvent) -// return original(this, a2, a3, a4, a5, a6, a7, a8); -// } + TInstanceHook(Mob*, "?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", + Spawner, BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3& a5, bool a6, bool a7, bool a8) { + IF_LISTENED(MobSpawnEvent) { + MobSpawnEvent ev{}; + ev.mTypeName = a3->getCanonicalName(); + ev.mPos = a5; + ev.mDimensionId = a2->getDimensionId(); + if (!ev.call()) + return nullptr; + } + IF_LISTENED_END(MobSpawnEvent) + return original(this, a2, a3, a4, a5, a6, a7, a8); + } #include "Impl/FormPacketHelper.h" #include