Skip to content

Commit

Permalink
~
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohengying committed Dec 4, 2021
1 parent d093297 commit f856949
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
17 changes: 11 additions & 6 deletions api/block/BlockSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
#include "lib/SymHook.h"
#include "lib/mod.h"
#include "world/Biome.h"

bool flag = false;
namespace trapdoor {
using namespace SymHook;

Block *BlockSource::getBlock(int x, int y, int z) {
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);
}
Expand All @@ -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);
// }
15 changes: 7 additions & 8 deletions mod/TrapdoorMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion mod/function/BlockRotationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f856949

Please sign in to comment.