Skip to content

Commit

Permalink
support 1.18.1.02
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohengying committed Dec 5, 2021
1 parent f9bf338 commit da59b6c
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 620,847 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ target_link_libraries(${MOD_API_NAME} ${PROJECT_SOURCE_DIR}/api/lib/detours.lib)

####################这里是具体功能##########################
set(TRAPDOOR_VERSION 0.9.90)
set(MCBE_VERSION 1.18.0.02)
set(BETA ON)
set(MCBE_VERSION 1.18.1.02)
set(BETA OFF)
set(TEST_NUMBER 1)
add_definitions(-DTD_VERSION="${TRAPDOOR_VERSION}")
add_definitions(-DMC_VERSION="${MCBE_VERSION}")
Expand Down
12 changes: 6 additions & 6 deletions api/block/BlockSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
#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});
// return getBlock({x, y, z});
return SYM_CALL(Block * (*)(void *, int, int, int),
BlockSource_getBlock_6df88a51, this, x, y, z);
}

Block *BlockSource::getBlock(const BlockPos &pos) {
flag = true;
auto *b = SYM_CALL(Block * (*)(void *, const BlockPos &),
BlockSource_getBlock_b39e5e5d, this, pos);
return b;
return SYM_CALL(Block * (*)(void *, const BlockPos &),
BlockSource_getBlock_b39e5e5d, this, pos);
// return getBlock(pos.x, pos.y, pos.z);
}

void BlockSource::setBlock(BlockPos *blockPos, Block *block) {
Expand Down
4 changes: 3 additions & 1 deletion api/entity/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ namespace trapdoor {
BlockSource *Actor::getBlockSource() {
//! from Player::tickWorld
// return offset_cast<BlockSource *>(this, 100);
return *((struct BlockSource **)this + off::PLAYER_GET_BLOCKSOURCE);
return SYM_CALL(trapdoor::BlockSource * (*)(trapdoor::Actor *),
Actor_getRegion_757c8f63, this);
// return *((struct BlockSource **)this + off::PLAYER_GET_BLOCKSOURCE);
}

void Actor::setGameMode(int mode) {
Expand Down
170 changes: 90 additions & 80 deletions api/lib/SymHook.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion api/world/Biome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ namespace trapdoor {
using namespace SymHook;

std::string Biome::getBiomeName() {
// char *str = reinterpret_cast<char *>(this) + off::BIOME_GET_NAME;
return "Unknown";
// char *str = reinterpret_cast<char *>(this) + off::BIOME_GET_NAME;
// return std::string(str);
}

int Biome::getBiomeType() {
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.18.1.02-0.9.90
2021-12-05

- 支持 1.18.1.02
- `village list`无法再显示工作过的村民数量
- `self`无法再显示所处群系名称

# 1.1.40.6-0.9.80
2021-11-07

Expand Down
7 changes: 4 additions & 3 deletions mod/TrapdoorMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace mod {
void TrapdoorMod::useOnHook(Actor *player, const std::string &itemName,
BlockPos &pos, unsigned int facing,
const Vec3 &v) {
L_INFO("%.2f %.2f %.2f %s", v.x, v.y, v.z, itemName.c_str());
L_DEBUG("%.2f %.2f %.2f %s", v.x, v.y, v.z, itemName.c_str());
//取消注释这一行可以看到右击地面的是什么东西
if (itemName == "Bone" && this->spawnHelper.isEnable()) {
spawnHelper.updateVerticalSpawnPositions(pos, player);
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace mod {
get_io_bytes(&ioRead, &ioWrite);
std::string stringBuilder;
stringBuilder += trapdoor::format(
"CPU: %d %%\n"
"CPU: %d %%%%\n"
"Mem: " C_INT " MB VMem; " C_INT
" MB\n"
"Read/Write" C_INT "KB / " C_INT " KB",
Expand Down Expand Up @@ -283,7 +283,8 @@ namespace mod {
#else
const char *gameVersion = "unknown_mcbe_version";
#endif
std::string version = std::string(modVersion) + "-" + gameVersion;
std::string version =
"TrapDoor-" + std::string(modVersion) + "-" + gameVersion;
#ifdef BETA
version += "-test";
#endif
Expand Down
4 changes: 1 addition & 3 deletions mod/function/BlockRotationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ namespace mod {
void BlockRotationHelper::rotate(trapdoor::BlockPos &pos,
trapdoor::BlockSource *blockSource) const {
using trapdoor::BlockSource;
auto block = blockSource->getBlock(pos);
printf("%d(%s)", block->getLegacy()->getBlockID(),
block->getName().c_str());
if (!this->enable) return;
auto block = blockSource->getBlock(pos.x, pos.y, pos.z);
auto air = trapdoor::getBlockByID(trapdoor::AIR);
auto variant = block->getVariant();
auto name = block->getName();
Expand Down
4 changes: 2 additions & 2 deletions mod/function/HopperCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ namespace mod {
trapdoor::MessageBuilder builder;
stringBuilder +=
trapdoor::format("channel: " C_INT "\ntotal " C_INT
" items in " C_INT " gt(" C_FLOAT "min)\n",
" items in " C_INT " gt (" C_FLOAT "min)\n",
channel, n, gameTick, gameTick / 1200.0);
for (const auto &i : counterList) {
auto itemName = GetItemLocalName(i.first);
stringBuilder += trapdoor::format(
"- %s " C_INT "(" C_FLOAT "/hour)\n", itemName.c_str(),
"- %s " C_INT " (" C_FLOAT " /hour)\n", itemName.c_str(),
i.second, i.second * 1.0 / gameTick * 72000);
}
trapdoor::info(actor, stringBuilder);
Expand Down
28 changes: 12 additions & 16 deletions mod/function/SingleFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@
namespace mod {
using namespace SymHook;

THook(void,
Explosion_explode_5adcea90, void *exp) {
THook(void, Explosion_explode_5adcea90, void *exp) {
auto modInstance = trapdoor::bdsMod->asInstance<mod::TrapdoorMod>();
if (!modInstance->getSingFunction().preventExplosion)
original(exp);
if (!modInstance->getSingFunction().preventExplosion) original(exp);
}

/**
* SYM_CALL(
void(*)(BlockSource * self,const BlockPos *pos),
MSSYM_B1QE17updateNeighborsAtB1AE11BlockSourceB2AAE17QEAAXAEBVBlockPosB3AAAA1Z,
this, pos
);
*/
/**
* SYM_CALL(
void(*)(BlockSource * self,const BlockPos *pos),
MSSYM_B1QE17updateNeighborsAtB1AE11BlockSourceB2AAE17QEAAXAEBVBlockPosB3AAAA1Z,
this, pos
);
*/

THook(
void,
BlockSource_updateNeighborsAt_4c3f8cf7,
trapdoor::BlockSource *source, trapdoor::BlockPos *pos) {
THook(void, BlockSource_updateNeighborsAt_4c3f8cf7,
trapdoor::BlockSource *source, trapdoor::BlockPos *pos) {
auto modInstance = trapdoor::bdsMod->asInstance<mod::TrapdoorMod>();
if (!modInstance->getSingFunction().preventNCUpdate)
original(source, pos);
}
} // namespace mod
} // namespace mod
11 changes: 4 additions & 7 deletions mod/player/PlayerFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ namespace mod {
auto inSlimeChunk = chunkPos.isSlimeChunk();
Vec3 viewVec{};
player->getViewActor(&viewVec, 1);
// auto biome = player->getBlockSource()->getBiome(&playerBlockPos);
// auto name = biome->getBiomeName();
std::string name = "Unknown";
auto biome = player->getBlockSource()->getBiome(&playerBlockPos);
auto name = biome->getBiomeName();
auto modInstance = trapdoor::bdsMod->asInstance<mod::TrapdoorMod>();

std::string xyz = format("XYZ: %.2f / %.2f / %.2f\n", position->x,
Expand All @@ -62,10 +61,8 @@ namespace mod {
std::string facing = "Facing: " + viewVec.toDirString();
facing +=
format("(%.2f / %.2f / %.2f)\n", viewVec.x, viewVec.y, viewVec.z);
std::string biomeString =
format("Biome: minecraft:%s (%d)\n", name.c_str(),
// biome->getBiomeType()
-1);
std::string biomeString = format("Biome: minecraft:%s (%d)\n",
name.c_str(), biome->getBiomeType());
std::string dimString =
format("Dimension: %s (%d)\n", player->getDimensionName().c_str(),
player->getDimensionID());
Expand Down
Loading

0 comments on commit da59b6c

Please sign in to comment.