From f85694918f2dce7b9301a6cfa84e38433042c4b5 Mon Sep 17 00:00:00 2001 From: xiaohengying <2602645221@qq.com> Date: Sat, 4 Dec 2021 14:22:16 +0800 Subject: [PATCH] ~ --- api/block/BlockSource.cpp | 17 +++++++++++------ mod/TrapdoorMod.cpp | 15 +++++++-------- mod/function/BlockRotationHelper.cpp | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/api/block/BlockSource.cpp b/api/block/BlockSource.cpp index 62d7668..dda1f21 100644 --- a/api/block/BlockSource.cpp +++ b/api/block/BlockSource.cpp @@ -7,7 +7,7 @@ #include "lib/SymHook.h" #include "lib/mod.h" #include "world/Biome.h" - +bool flag = false; namespace trapdoor { using namespace SymHook; @@ -15,15 +15,15 @@ namespace trapdoor { return getBlock({x, y, z}); } - Block *BlockSource::getBlock(const BlockPos &blockPos) { - printf("%d %d %d)", blockPos.x, blockPos.y, blockPos.z); - return SYM_CALL(Block * (*)(void *, const BlockPos &), - BlockSource_getBlock_b39e5e5d, this, blockPos); + Block *BlockSource::getBlock(const BlockPos &pos) { + flag = true; + auto *b = SYM_CALL(Block * (*)(void *, const BlockPos &), + BlockSource_getBlock_b39e5e5d, this, pos); + return b; } void BlockSource::setBlock(BlockPos *blockPos, Block *block) { SYM_CALL(void (*)(void *, int, int, int, Block *, int), - BlockSource_setBlock_71ce9a25, this, blockPos->x, blockPos->y, blockPos->z, block, 3); } @@ -45,3 +45,8 @@ namespace trapdoor { BlockSource_getBiome_967864de, this, pos); } } // namespace trapdoor +// using namespace SymHook; +// THook(trapdoor::Block *, BlockSource_getBlock_b39e5e5d, +// trapdoor::BlockSource *source, const trapdoor::BlockPos &pos) { +// return trapdoor::getBlockByID(trapdoor::DIAMOND_BLOCK); +// } diff --git a/mod/TrapdoorMod.cpp b/mod/TrapdoorMod.cpp index 89ba682..058cc8f 100644 --- a/mod/TrapdoorMod.cpp +++ b/mod/TrapdoorMod.cpp @@ -234,14 +234,13 @@ namespace mod { get_memory_usage(&memory, &virtualMemory); get_io_bytes(&ioRead, &ioWrite); std::string stringBuilder; - stringBuilder += - trapdoor::format("CPU " C_INT - "%%%%" - "Mem: " C_INT " MB VMem; " C_INT - " MB\n" - "Read/Write" C_INT "KB / " C_INT " KB", - CPUUsage, memory >> 20u, virtualMemory >> 20u, - ioRead >> 10u, ioWrite >> 10u); + stringBuilder += trapdoor::format( + "CPU: %d %%\n" + "Mem: " C_INT " MB VMem; " C_INT + " MB\n" + "Read/Write" C_INT "KB / " C_INT " KB", + CPUUsage, memory >> 20u, virtualMemory >> 20u, ioRead >> 10u, + ioWrite >> 10u); trapdoor::info(player, stringBuilder); } diff --git a/mod/function/BlockRotationHelper.cpp b/mod/function/BlockRotationHelper.cpp index e38a676..3084928 100644 --- a/mod/function/BlockRotationHelper.cpp +++ b/mod/function/BlockRotationHelper.cpp @@ -14,10 +14,10 @@ namespace mod { void BlockRotationHelper::rotate(trapdoor::BlockPos &pos, trapdoor::BlockSource *blockSource) const { using trapdoor::BlockSource; - if (!this->enable) return; auto block = blockSource->getBlock(pos); printf("%d(%s)", block->getLegacy()->getBlockID(), block->getName().c_str()); + if (!this->enable) return; auto air = trapdoor::getBlockByID(trapdoor::AIR); auto variant = block->getVariant(); auto name = block->getName();