From 84ca688196744476a5da055522a1be5d45e4cbaf Mon Sep 17 00:00:00 2001 From: twoone3l <3197653242@qq.com> Date: Thu, 19 Aug 2021 19:07:15 +0800 Subject: [PATCH] =?UTF-8?q?1.7.1=E6=9B=B4=E6=96=B0=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DonSneak=E5=8F=82=E6=95=B0=E4=B8=8D=E5=AF=B9=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=AF=8F=E4=B8=AA?= =?UTF-8?q?hook=E7=9A=84=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BF=AE=E6=94=B9readm?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BDSpyrunner/Source File/mod.cpp | 120 ++++++++++++++++---------------- README.md | 3 +- README_ZH.md | 3 +- 3 files changed, 62 insertions(+), 64 deletions(-) diff --git a/BDSpyrunner/Source File/mod.cpp b/BDSpyrunner/Source File/mod.cpp index 8bd23d23..bba43afb 100644 --- a/BDSpyrunner/Source File/mod.cpp +++ b/BDSpyrunner/Source File/mod.cpp @@ -14,11 +14,11 @@ #include #include -#define VERSION_1 1 -#define VERSION_2 7 -#define VERSION_3 0 -#define PLUGIN_PATH "plugins/py" -#define MODULE_NAME "mc" +constexpr auto VERSION_1 = 1; +constexpr auto VERSION_2 = 7; +constexpr auto VERSION_3 = 1; +constexpr auto PLUGIN_PATH = L"plugins/py"; +constexpr auto MODULE_NAME = "mc"; using namespace std; #pragma region Function Define @@ -87,41 +87,43 @@ HOOK(Level_tick, void, "?tick@Level@@UEAAXXZ", original(_this); } #endif +//将Python解释器初始化插入bds主函数 HOOK(BDS_Main, int, "main", int argc, char* argv[], char* envp[]) { init(); // 执行 main 函数 return original(argc, argv, envp); } - +//Level的构造函数 HOOK(Level_construct, Level*, "??0Level@@QEAA@AEBV?$not_null@V?$NonOwnerPointer@VSoundPlayerInterface@@@Bedrock@@@gsl@@V?$unique_ptr@VLevelStorage@@U?$default_delete@VLevelStorage@@@std@@@std@@V?$unique_ptr@VLevelLooseFileStorage@@U?$default_delete@VLevelLooseFileStorage@@@std@@@4@AEAVIMinecraftEventing@@_NEAEAVScheduler@@V?$not_null@V?$NonOwnerPointer@VStructureManager@@@Bedrock@@@2@AEAVResourcePackManager@@AEBV?$not_null@V?$NonOwnerPointer@VIEntityRegistryOwner@@@Bedrock@@@2@V?$WeakRefT@UEntityRefTraits@@@@V?$unique_ptr@VBlockComponentFactory@@U?$default_delete@VBlockComponentFactory@@@std@@@4@V?$unique_ptr@VBlockDefinitionGroup@@U?$default_delete@VBlockDefinitionGroup@@@std@@@4@@Z", Level* _this, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10, uintptr_t a11, uintptr_t a12, uintptr_t a13) { return g_level = original(_this, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); } - +//SPSCQueue的构造函数 HOOK(SPSCQueue_construct, SPSCQueue*, "??0?$SPSCQueue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$0CAA@@@QEAA@_K@Z", SPSCQueue* _this) { return g_command_queue = original(_this); } - +//RakPeer的构造函数 HOOK(RakPeer_construct, RakPeer*, "??0RakPeer@RakNet@@QEAA@XZ", RakPeer* _this) { + //会构造两次,取第一次值 if (g_rak_peer == nullptr) return g_rak_peer = original(_this); return original(_this); } - +//ServerNetworkHandler的构造函数 HOOK(ServerNetworkHandler_construct, uintptr_t, "??0ServerNetworkHandler@@QEAA@AEAVGameCallbacks@@AEBV?$NonOwnerPointer@VILevel@@@Bedrock@@AEAVNetworkHandler@@AEAVPrivateKeyManager@@AEAVServerLocator@@AEAVPacketSender@@AEAVAllowList@@PEAVPermissionsFile@@AEBVUUID@mce@@H_NAEBV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HAEAVMinecraftCommands@@AEAVIMinecraftApp@@AEBV?$unordered_map@UPackIdVersion@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$hash@UPackIdVersion@@@3@U?$equal_to@UPackIdVersion@@@3@V?$allocator@U?$pair@$$CBUPackIdVersion@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@3@@std@@AEAVScheduler@@V?$NonOwnerPointer@VTextFilteringProcessor@@@3@@Z", ServerNetworkHandler* _this, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10, uintptr_t a11, uintptr_t a12, uintptr_t a13, uintptr_t a14, uintptr_t a15, uintptr_t a16, uintptr_t a17, uintptr_t a18, uintptr_t a19, uintptr_t a20) { g_server_network_handler = _this; return original(_this, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); } - +//Scoreboard的构造函数 HOOK(ServerScoreboard_construct, Scoreboard*, "??0ServerScoreboard@@QEAA@VCommandSoftEnumRegistry@@PEAVLevelStorage@@@Z", - uintptr_t _this, uintptr_t a2, uintptr_t a3) { + Scoreboard* _this, uintptr_t a2, uintptr_t a3) { return g_scoreboard = original(_this, a2, a3); } - +//改变设置命令的建立,用于注册命令 HOOK(ChangeSettingCommand_setup, void, "?setup@ChangeSettingCommand@@SAXAEAVCommandRegistry@@@Z", uintptr_t _this) { for (auto& [cmd, des] : g_commands) { @@ -130,7 +132,7 @@ HOOK(ChangeSettingCommand_setup, void, "?setup@ChangeSettingCommand@@SAXAEAVComm } original(_this); } - +//控制台输出,实际上是cout<_getServerPlayer(id, pkt); @@ -177,13 +179,13 @@ HOOK(onPlayerJoin, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifi } original(_this, id, pkt); } - +//玩家退出 HOOK(onPlayerLeft, void, "?_onPlayerLeft@ServerNetworkHandler@@AEAAXPEAVServerPlayer@@_N@Z", uintptr_t _this, Player* p, char v3) { EventCallBack(EventCode::onPlayerLeft, "O", PyEntity_FromEntity(p)); return original(_this, p, v3); } - +//使用物品 HOOK(onUseItem, bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAEBVVec3@@PEBVBlock@@@Z", uintptr_t _this, ItemStack* item, BlockPos* bp, char a4, uintptr_t a5, Block* b) { Player* p = FETCH(Player*, _this + 8); @@ -207,7 +209,7 @@ HOOK(onUseItem, bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@E else return false; } - +//放置方块 HOOK(onPlaceBlock, bool, "?mayPlace@BlockSource@@QEAA_NAEBVBlock@@AEBVBlockPos@@EPEAVActor@@_N@Z", BlockSource* _this, Block* b, BlockPos* bp, unsigned char a4, Actor* p, bool _bool) { if (isPlayer(p)) { @@ -225,7 +227,7 @@ HOOK(onPlaceBlock, bool, "?mayPlace@BlockSource@@QEAA_NAEBVBlock@@AEBVBlockPos@@ } return original(_this, b, bp, a4, p, _bool); } - +//破坏方块 HOOK(onDestroyBlock, bool, "?checkBlockDestroyPermissions@BlockSource@@QEAA_NAEAVActor@@AEBVBlockPos@@AEBVItemStackBase@@_N@Z", BlockSource* _this, Actor* p, BlockPos* bp, ItemStack* a3, bool a4) { #if 0//测试获取结构 @@ -257,7 +259,7 @@ HOOK(onDestroyBlock, bool, "?checkBlockDestroyPermissions@BlockSource@@QEAA_NAEA } return original(_this, p, bp, a3, a4); } - +//开箱 HOOK(onOpenChest, bool, "?use@ChestBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", uintptr_t _this, Player* p, BlockPos* bp) { if (EventCallBack(EventCode::onOpenChest, @@ -268,7 +270,7 @@ HOOK(onOpenChest, bool, "?use@ChestBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", return original(_this, p, bp); return false; } - +//开桶,不能拦截,到方块交互才能拦截,不知道mojang员工在想什么 HOOK(onOpenBarrel, bool, "?use@BarrelBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", uintptr_t _this, Player* p, BlockPos* bp) { if (EventCallBack(EventCode::onOpenBarrel, @@ -279,7 +281,7 @@ HOOK(onOpenBarrel, bool, "?use@BarrelBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z" return original(_this, p, bp); return false; } - +//关箱 HOOK(onCloseChest, void, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z", uintptr_t _this, Player* p) { auto bp = (BlockPos*)(_this - 204); @@ -290,7 +292,7 @@ HOOK(onCloseChest, void, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z", ); original(_this, p); } - +//关桶 HOOK(onCloseBarrel, void, "?stopOpen@BarrelBlockActor@@UEAAXAEAVPlayer@@@Z", uintptr_t _this, Player* p) { auto bp = (BlockPos*)(_this - 204); @@ -301,7 +303,7 @@ HOOK(onCloseBarrel, void, "?stopOpen@BarrelBlockActor@@UEAAXAEAVPlayer@@@Z", ); original(_this, p); } - +//放入取出物品,实际上是容器改变 HOOK(onContainerChange, void, "?containerContentChanged@LevelContainerModel@@UEAAXH@Z", uintptr_t _this, unsigned slot) { Player* p = FETCH(Player*, _this + 208);//IDA LevelContainerModel::_getContainer line 15 25 v3 @@ -329,7 +331,7 @@ HOOK(onContainerChange, void, "?containerContentChanged@LevelContainerModel@@UEA } original(_this, slot); } - +//玩家攻击 HOOK(onAttack, bool, "?attack@Player@@UEAA_NAEAVActor@@AEBW4ActorDamageCause@@@Z", Player* p, Actor* a, struct ActorDamageCause* c) { if (EventCallBack(EventCode::onPlayerAttack, @@ -340,7 +342,7 @@ HOOK(onAttack, bool, "?attack@Player@@UEAA_NAEAVActor@@AEBW4ActorDamageCause@@@Z return original(p, a, c); return false; } - +//切换纬度 HOOK(onChangeDimension, bool, "?_playerChangeDimension@Level@@AEAA_NPEAVPlayer@@AEAVChangeDimensionRequest@@@Z", uintptr_t _this, Player* p, uintptr_t req) { bool result = original(_this, p, req); @@ -349,7 +351,7 @@ HOOK(onChangeDimension, bool, "?_playerChangeDimension@Level@@AEAA_NPEAVPlayer@@ } return result; } - +//生物死亡 HOOK(onMobDie, void, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob* _this, uintptr_t dmsg) { char v72; @@ -362,7 +364,7 @@ HOOK(onMobDie, void, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", ); if (res) original(_this, dmsg); } - +//生物受伤 HOOK(onMobHurt, bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@H_N1@Z", Mob* _this, uintptr_t dmsg, int a3, bool a4, bool a5) { g_damage = a3;//将生物受伤的值设置为可调整 @@ -378,13 +380,13 @@ HOOK(onMobHurt, bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@H_N1@Z", return original(_this, dmsg, g_damage, a4, a5); return false; } - +//玩家重生 HOOK(onRespawn, void, "?respawn@Player@@UEAAXXZ", Player* p) { EventCallBack(EventCode::onRespawn, "O", PyEntity_FromEntity(p)); original(p); } - +//聊天,消息title msg w等... HOOK(onChat, void, "?fireEventPlayerMessage@MinecraftEventing@@AEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@000@Z", uintptr_t _this, string& sender, string& target, string& msg, string& style) { EventCallBack(EventCode::onChat, @@ -396,7 +398,7 @@ HOOK(onChat, void, "?fireEventPlayerMessage@MinecraftEventing@@AEAAXAEBV?$basic_ ); original(_this, sender, target, msg, style); } - +//玩家输入文本 HOOK(onInputText, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVTextPacket@@@Z", ServerNetworkHandler* _this, uintptr_t id, /*TextPacket*/uintptr_t pkt) { Player* p = _this->_getServerPlayer(id, pkt); @@ -411,7 +413,7 @@ HOOK(onInputText, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifie } if (res)original(_this, id, pkt); } - +//玩家输入命令 HOOK(onInputCommand, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVCommandRequestPacket@@@Z", ServerNetworkHandler* _this, uintptr_t id, /*CommandRequestPacket*/uintptr_t pkt) { Player* p = _this->_getServerPlayer(id, pkt); @@ -434,7 +436,7 @@ HOOK(onInputCommand, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdenti if (res)original(_this, id, pkt); } } - +//玩家选择表单 HOOK(onSelectForm, void, "?handle@?$PacketHandlerDispatcherInstance@VModalFormResponsePacket@@$0A@@@UEBAXAEBVNetworkIdentifier@@AEAVNetEventCallback@@AEAV?$shared_ptr@VPacket@@@std@@@Z", uintptr_t _this, uintptr_t id, ServerNetworkHandler* handle,/*ModalFormResponsePacket*/uintptr_t* ppkt) { uintptr_t pkt = *ppkt; @@ -452,7 +454,7 @@ HOOK(onSelectForm, void, "?handle@?$PacketHandlerDispatcherInstance@VModalFormRe } original(_this, id, handle, ppkt); } - +//命令方块更新 HOOK(onCommandBlockUpdate, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVCommandBlockUpdatePacket@@@Z", ServerNetworkHandler* _this, uintptr_t id, /*CommandBlockUpdatePacket*/uintptr_t pkt) { bool res = true; @@ -481,7 +483,7 @@ HOOK(onCommandBlockUpdate, void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetwork } if (res)original(_this, id, pkt); } - +//爆炸 HOOK(onLevelExplode, bool, "?explode@Level@@UEAAXAEAVBlockSource@@PEAVActor@@AEBVVec3@@M_N3M3@Z", Level* _this, BlockSource* bs, Actor* a3, Vec3 pos, float a5, bool a6, bool a7, float a8, bool a9) { if (EventCallBack(EventCode::onLevelExplode, @@ -494,7 +496,7 @@ HOOK(onLevelExplode, bool, "?explode@Level@@UEAAXAEAVBlockSource@@PEAVActor@@AEB return original(_this, bs, a3, pos, a5, a6, a7, a8, a9); return false; } - +//命令方块执行 HOOK(onCommandBlockPerform, bool, "?_execute@CommandBlock@@AEBAXAEAVBlockSource@@AEAVCommandBlockActor@@AEBVBlockPos@@_N@Z", uintptr_t _this, BlockSource* a2, uintptr_t a3, BlockPos* bp, bool a5) { //脉冲:0,重复:1,链:2 @@ -514,13 +516,13 @@ HOOK(onCommandBlockPerform, bool, "?_execute@CommandBlock@@AEBAXAEAVBlockSource@ return original(_this, a2, a3, bp, a5); return false; } - +//玩家移动 HOOK(onMove, void, "??0MovePlayerPacket@@QEAA@AEAVPlayer@@W4PositionMode@1@HH@Z", uintptr_t _this, Player* p, char a3, int a4, int a5) { EventCallBack(EventCode::onMove, "O", PyEntity_FromEntity(p)); original(_this, p, a3, a4, a5); } - +//玩家穿戴 HOOK(onSetArmor, void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", Player* p, unsigned slot, ItemStack* i) { if (!EventCallBack(EventCode::onSetArmor, @@ -535,7 +537,7 @@ HOOK(onSetArmor, void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", return; return original(p, slot, i); } - +//计分板改变监听 HOOK(onScoreChanged, void, "?onScoreChanged@ServerScoreboard@@UEAAXAEBUScoreboardId@@AEBVObjective@@@Z", Scoreboard* _this, ScoreboardId* a1, Objective* a2) { /* @@ -553,7 +555,7 @@ HOOK(onScoreChanged, void, "?onScoreChanged@ServerScoreboard@@UEAAXAEBUScoreboar ); original(_this, a1, a2); } - +//耕地破坏 HOOK(onFallBlockTransform, void, "?transformOnFall@FarmBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@PEAVActor@@M@Z", uintptr_t _this, BlockSource* a1, BlockPos* a2, Actor* p, uintptr_t a4) { if (isPlayer(p)) { @@ -567,7 +569,7 @@ HOOK(onFallBlockTransform, void, "?transformOnFall@FarmBlock@@UEBAXAEAVBlockSour } original(_this, a1, a2, p, a4); } - +//使用重生锚 HOOK(onUseRespawnAnchorBlock, bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z", Player* p, BlockPos* a2, BlockSource* a3, Level* a4) { if (isPlayer(p)) { @@ -581,7 +583,7 @@ HOOK(onUseRespawnAnchorBlock, bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPl } return original(p, a2, a3, a4); } - +//活塞推 HOOK(onPistonPush, bool, "?_attachedBlockWalker@PistonBlockActor@@AEAA_NAEAVBlockSource@@AEBVBlockPos@@EE@Z", BlockActor* _this, BlockSource* bs, BlockPos* bp, unsigned a3, unsigned a4) { BlockLegacy* blg = bs->getBlock(bp)->getBlockLegacy(); @@ -599,20 +601,20 @@ HOOK(onPistonPush, bool, "?_attachedBlockWalker@PistonBlockActor@@AEAA_NAEAVBloc return original(_this, bs, bp, a3, a4); return false; } - +//末影人随机传送(没人会用吧?) HOOK(onEndermanRandomTeleport, bool, "?randomTeleport@TeleportComponent@@QEAA_NAEAVActor@@@Z", uintptr_t _this, Actor* a1) { if (EventCallBack(EventCode::onEndermanRandomTeleport, "O", PyEntity_FromEntity(a1))) return original(_this, a1); return false; } - +//服务器开完 HOOK(onServerStarted, void, "?startServerThread@ServerInstance@@QEAAXXZ", void* _this) { EventCallBack(EventCode::onServerStarted, nullptr); original(_this); } - +//丢物品 HOOK(onDropItem, bool, "?drop@Player@@UEAA_NAEBVItemStack@@_N@Z", Player* _this, ItemStack* a2, bool a3) { if (EventCallBack(EventCode::onDropItem, @@ -626,7 +628,7 @@ HOOK(onDropItem, bool, "?drop@Player@@UEAA_NAEBVItemStack@@_N@Z", return original(_this, a2, a3); return false; } - +//拿物品 HOOK(onTakeItem, bool, "?take@Player@@QEAA_NAEAVActor@@HH@Z", Player* _this, Actor* actor, int a2, int a3) { if (EventCallBack(EventCode::onTakeItem, @@ -637,7 +639,7 @@ HOOK(onTakeItem, bool, "?take@Player@@QEAA_NAEAVActor@@HH@Z", return original(_this, actor, a2, a3); return false; } - +//骑 HOOK(onRide, bool, "?canAddRider@Actor@@UEBA_NAEAV1@@Z", Actor* a1, Actor* a2) { if (EventCallBack(EventCode::onRide, @@ -648,7 +650,7 @@ HOOK(onRide, bool, "?canAddRider@Actor@@UEBA_NAEAV1@@Z", return original(a1, a2); return false; } - +//放入取出物品展示框的物品(未测试) HOOK(onUseFrameBlock, bool, "?use@ItemFrameBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", void* _this, Player* a2, BlockPos* a3) { if (EventCallBack(EventCode::onUseFrameBlock, @@ -660,7 +662,7 @@ HOOK(onUseFrameBlock, bool, "?use@ItemFrameBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos return original(_this, a2, a3); return false; } - +//点击物品展示框(未测试) HOOK(onUseFrameBlocka, bool, "?attack@ItemFrameBlock@@UEBA_NPEAVPlayer@@AEBVBlockPos@@@Z", void* _this, Player* a2, BlockPos* a3) { if (EventCallBack(EventCode::onUseFrameBlock, @@ -672,19 +674,19 @@ HOOK(onUseFrameBlocka, bool, "?attack@ItemFrameBlock@@UEBA_NPEAVPlayer@@AEBVBloc return original(_this, a2, a3); return false; } - +//玩家跳跃 HOOK(onJump, void, "?jumpFromGround@Player@@UEAAXXZ", Player* _this) { if (EventCallBack(EventCode::onJump, "O", PyEntity_FromEntity(_this))) return original(_this); } - +//玩家潜行 HOOK(onSneak, void, "?sendActorSneakChanged@ActorEventCoordinator@@QEAAXAEAVActor@@_N@Z", - Player* _this) { - if (EventCallBack(EventCode::onSneak, "O", PyEntity_FromEntity(_this))) - return original(_this); + uintptr_t _this, Actor* a1, bool a2) { + if (EventCallBack(EventCode::onSneak, "O", PyEntity_FromEntity(a1))) + return original(_this, a1, a2); } - +//火势蔓延(未测试) HOOK(onFireSpread, bool, "?_trySpawnBlueFire@FireBlock@@AEBA_NAEAVBlockSource@@AEBVBlockPos@@@Z", void* _this, BlockSource* bs, BlockPos* bp) { BlockLegacy* bl = bs->getBlock(bp)->getBlockLegacy(); @@ -698,7 +700,7 @@ HOOK(onFireSpread, bool, "?_trySpawnBlueFire@FireBlock@@AEBA_NAEAVBlockSource@@A return original(_this, bs, bp); return false; } - +//方块交互(除箱子,工作台) HOOK(onBlockInteracted, void, "?onBlockInteractedWith@VanillaServerGameplayEventListener@@UEAA?AW4EventResult@@AEAVPlayer@@AEBVBlockPos@@@Z", void* _this, Player* pl, BlockPos* bp) { BlockSource* bs = g_level->getBlockSource(pl->getDimensionId()); @@ -713,7 +715,7 @@ HOOK(onBlockInteracted, void, "?onBlockInteractedWith@VanillaServerGameplayEvent )) return original(_this, pl, bp); } - +//方块爆炸(未测试) HOOK(onBlockExploded, void, "?onExploded@Block@@QEBAXAEAVBlockSource@@AEBVBlockPos@@PEAVActor@@@Z", Block* _this, BlockSource* bs, BlockPos* bp, Actor* actor) { BlockLegacy* bl = bs->getBlock(bp)->getBlockLegacy(); @@ -992,9 +994,7 @@ void init() { if (!exists(PLUGIN_PATH)) create_directories(PLUGIN_PATH); //将plugins/py加入模块搜索路径 - wstring py_path(PLUGIN_PATH L";"); - py_path += Py_GetPath(); - Py_SetPath(py_path.c_str()); + Py_SetPath((wstring(PLUGIN_PATH) + L';' + Py_GetPath()).c_str()); #if 0 #pragma region 预初始化3.8+ //PyPreConfig cfg; diff --git a/README.md b/README.md index 46648715..375fe88c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ It greatly reduces the threshold for plug-in development and effectively simplif 2. Put the dll into the `./plugins` folder, run BDS, the py folder will be automatically generated, if you see `[BDSpyrunner] x.x.x loaded.`, the pyr has been loaded successfully. 7. Put the plug-in into `./plugins/py`, run BDS again, you can use it normally. # Documents -* [API](https://github.com/twoone-3/BDSpyrunner/wiki/API) -* [Listener](https://github.com/twoone-3/BDSpyrunner/wiki/Listener) +* [Wiki](https://github.com/twoone-3/BDSpyrunner/wiki/) # Contact us QQ group : 1167270197 diff --git a/README_ZH.md b/README_ZH.md index 8be08bd2..88216919 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -15,7 +15,6 @@ 2. 将dll放入 `./plugins`文件夹,运行BDS,会自动生成py文件夹,如果看到`[BDSpyrunner] x.x.x loaded.`,则pyr加载成功了 7. 将插件放入 `./plugins/py`,再次运行BDS,就可以正常使用了 # 文档 -* [API接口](https://github.com/twoone-3/BDSpyrunner/wiki/API) -* [监听器](https://github.com/twoone-3/BDSpyrunner/wiki/Listener) +* [Wiki](https://github.com/twoone-3/BDSpyrunner/wiki/) # 联系我们 QQ 群 : 1167270197