diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml
index 4e5d17b..06f119a 100644
--- a/.github/workflows/cmake-build.yml
+++ b/.github/workflows/cmake-build.yml
@@ -3,7 +3,7 @@ name: CMake
on:
push:
branches:
- - 1.16.4-main
+ - 1.16.201
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
@@ -62,9 +62,9 @@ jobs:
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
-# upload_url: ${{ steps.create_release.outputs.upload_url }}
+# upload_url: https://github.com/quizhizhe/TrapDoor/releases/tag/1.16.4
# asset_path: ${{github.workspace}}/build/Release/trapdoor-mod.dll
-# asset_name: trapdoor-mod.dll
+# asset_name: trapdoor-v0.9.20-1.16.201.dll
# asset_content_type: application/dll
#
## - name: Test
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 288a846..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c93b0e..20bfbb6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,7 +50,6 @@ target_include_directories(${MOD_API_NAME}
)
target_link_libraries(${MOD_API_NAME} ${PROJECT_SOURCE_DIR}/api/lib/detours.lib)
-target_link_libraries(${MOD_API_NAME} ${PROJECT_SOURCE_DIR}/api/lib/sqlite3.lib)
diff --git a/mod/TrapdoorMod.cpp b/mod/TrapdoorMod.cpp
index 5b5c27d..95796d7 100644
--- a/mod/TrapdoorMod.cpp
+++ b/mod/TrapdoorMod.cpp
@@ -36,7 +36,7 @@ namespace mod {
void TrapdoorMod::initialize() {
BDSMod::initialize();
this->commandManager.setCommandConfig(this->configManager.getCommandsConfig());
- this->playerStatisticManager.init("trapdoor.db");
+// this->playerStatisticManager.init("trapdoor.db");
mod::initBackup();
this->initFunctionEnable();
this->villageHelper.setConfig(this->configManager.getVillageConfig());
@@ -74,7 +74,9 @@ namespace mod {
->then(ARG("draw", "开启/关闭区块draw命令", BOOL, {
this->simpleBuilder.setAble(holder->getBool());
info(player, "设置简单建造为 %d", holder->getBool());
- }))
+ }));
+/*
+ //commented out fully player statistics manager
->then(ARG("stat", "开启/关闭玩家行为统计", BOOL, {
if (!configManager.getFunctionConfig().playerStat) {
error(player, "该功能已被关闭,请联系服主");
@@ -83,6 +85,7 @@ namespace mod {
this->playerStatisticManager.setAble(holder->getBool());
info(player, "设置玩家行为统计为 %d", holder->getBool());
}));
+*/
//史莱姆显示
commandManager.registerCmd("slime", "史莱姆区块相关")
@@ -386,7 +389,7 @@ namespace mod {
auto functionCfg = this->configManager.getFunctionConfig();
this->spawnHelper.setAble(functionCfg.spawnHelper);
this->rotationHelper.setAble(functionCfg.cactusRotation);
- this->playerStatisticManager.setAble(functionCfg.playerStat);
+// this->playerStatisticManager.setAble(functionCfg.playerStat);
this->simpleBuilder.setAble(functionCfg.simpleDraw);
this->hopperChannelManager.setAble(functionCfg.hopperCounter);
}
diff --git a/mod/TrapdoorMod.h b/mod/TrapdoorMod.h
index 2eeaf18..ea2a4e9 100644
--- a/mod/TrapdoorMod.h
+++ b/mod/TrapdoorMod.h
@@ -16,13 +16,13 @@
#include "player/PlayerFunction.h"
#include "player/SimpleBuilder.h"
#include "SlimeChunkHelper.h"
-#include "player/PlayerStatisticManager.h"
+//#include "player/PlayerStatisticManager.h"
namespace mod {
struct ModInfo {
- const std::string minecraftVersion = "1.16.4.02";
- const std::string modVersion = "trapdoor-0.9.20";
+ const std::string minecraftVersion = "1.16.201";
+ const std::string modVersion = "trapdoor-0.9.21";
};
class TrapdoorMod : public trapdoor::BDSMod {
@@ -37,7 +37,7 @@ namespace mod {
PlayerFunction playerFunctions;
SimpleBuilder simpleBuilder;
SlimeChunkHelper slimeChunkHelper;
- PlayerStatisticManager playerStatisticManager;
+// PlayerStatisticManager playerStatisticManager;
void registerTickCommand();
@@ -81,7 +81,7 @@ namespace mod {
inline SpawnAnalyzer &getSpawnAnalyzer() { return this->spawnAnalyzer; }
- inline PlayerStatisticManager &getPlayerStatisticManager() { return this->playerStatisticManager; }
+// inline PlayerStatisticManager &getPlayerStatisticManager() { return this->playerStatisticManager; }
inline std::string getLevelName() { return this->configManager.getServerConfig().levelName; }
@@ -89,4 +89,4 @@ namespace mod {
};
}
-#endif //MOD_TRAPDOORMOD_H
\ No newline at end of file
+#endif //MOD_TRAPDOORMOD_H
diff --git a/mod/player/Player.cpp b/mod/player/Player.cpp
index e15c177..9fb5221 100644
--- a/mod/player/Player.cpp
+++ b/mod/player/Player.cpp
@@ -17,43 +17,43 @@
//player place block
using namespace SymHook;
-
-THook(
- int64_t,
- MSSYM_B1QE21onBlockPlacedByPlayerB1AE34VanillaServerGameplayEventListenerB2AAA4UEAAB1QE14AW4EventResultB2AAE10AEAVPlayerB2AAA9AEBVBlockB2AAE12AEBVBlockPosB3AAUA1NB1AA1Z,
- void *self,
- trapdoor::Actor *player,
- trapdoor::Block &block,
- const trapdoor::BlockPos &pos,
- bool flag
-) {
- auto modInstance = trapdoor::bdsMod->asInstance();
- modInstance->getPlayerStatisticManager().insetPlayerAction(player->getNameTag(), pos,
- mod::PlayerStatisticManager::PLACE_BLOCK,
- player->getDimensionID(),
- block.getName());
-
- return original(self, player, block, pos, flag);
-}
+//
+//THook(
+// int64_t,
+// MSSYM_B1QE21onBlockPlacedByPlayerB1AE34VanillaServerGameplayEventListenerB2AAA4UEAAB1QE14AW4EventResultB2AAE10AEAVPlayerB2AAA9AEBVBlockB2AAE12AEBVBlockPosB3AAUA1NB1AA1Z,
+// void *self,
+// trapdoor::Actor *player,
+// trapdoor::Block &block,
+// const trapdoor::BlockPos &pos,
+// bool flag
+//) {
+// auto modInstance = trapdoor::bdsMod->asInstance();
+// modInstance->getPlayerStatisticManager().insetPlayerAction(player->getNameTag(), pos,
+// mod::PlayerStatisticManager::PLACE_BLOCK,
+// player->getDimensionID(),
+// block.getName());
+//
+// return original(self, player, block, pos, flag);
+//}
//player destroy block
-
-THook(
- void,
- MSSYM_B2QUE20destroyBlockInternalB1AA8GameModeB2AAA4AEAAB1UE13NAEBVBlockPosB2AAA1EB1AA1Z,
- uint64_t *self,
- const trapdoor::BlockPos *pos,
- int64_t a3,
- int a4
-) {
- uint64_t *ptr = self + 1;
- auto player = reinterpret_cast(*ptr);
- auto modInstance = trapdoor::bdsMod->asInstance();
- auto block = player->getBlockSource()->getBlock(pos->x, pos->y, pos->z);
- modInstance->getPlayerStatisticManager().insetPlayerAction(player->getNameTag(), *pos,
- mod::PlayerStatisticManager::DESTROY_BLOCK,
- player->getDimensionID(),
- block->getName());
- original(self, pos, a3, a4);
-}
+//
+//THook(
+// void,
+// MSSYM_B2QUE20destroyBlockInternalB1AA8GameModeB2AAA4AEAAB1UE13NAEBVBlockPosB2AAA1EB1AA1Z,
+// uint64_t *self,
+// const trapdoor::BlockPos *pos,
+// int64_t a3,
+// int a4
+//) {
+// uint64_t *ptr = self + 1;
+// auto player = reinterpret_cast(*ptr);
+// auto modInstance = trapdoor::bdsMod->asInstance();
+// auto block = player->getBlockSource()->getBlock(pos->x, pos->y, pos->z);
+// modInstance->getPlayerStatisticManager().insetPlayerAction(player->getNameTag(), *pos,
+// mod::PlayerStatisticManager::DESTROY_BLOCK,
+// player->getDimensionID(),
+// block->getName());
+// original(self, pos, a3, a4);
+//}
diff --git a/mod/player/PlayerStatisticManager.cpp b/mod/player/PlayerStatisticManager.cpp
index 46a4f38..e71254b 100644
--- a/mod/player/PlayerStatisticManager.cpp
+++ b/mod/player/PlayerStatisticManager.cpp
@@ -8,53 +8,53 @@
#include "tools/MsgBuilder.h"
namespace mod {
- int mod::PlayerStatisticManager::createPlayerActionTable() {
- const std::string playerActionTableSQL =
- R"(
- create table if not exists player_acton(
- action_id integer primary key autoincrement,
- player_id VARCHAR(128) not null,
- action_time timestamp not null default (datetime('now','localtime')),
- action_type int,
- action_dim int,
- action_p_x int,
- action_p_y int,
- action_p_z int,
- action_string VARCHAR(512)
- )
- )";
- return this->executeSQL(playerActionTableSQL);
- }
-
- int PlayerStatisticManager::executeSQL(const std::string &sql) {
- char *errorMsg;
- auto rc = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, &errorMsg);
- if (rc != SQLITE_OK) {
- L_DEBUG("SQL error: %s\n", errorMsg);
- sqlite3_free(errorMsg);
- }
- return rc;
- }
-
- void PlayerStatisticManager::insetPlayerAction(const std::string &playerName, const trapdoor::BlockPos &pos,
- PlayerStatisticManager::PLAYER_ACTION playerAction, int dim,
- const std::string &msg) {
-
- auto sql = trapdoor::format(
- "insert into player_acton(player_id,action_type,action_dim,action_p_x,action_p_y,action_p_z,action_string)\n"
- " VALUES ('%s', %d,%d,%d,%d,%d, '%s')",
- playerName.c_str(), playerAction, dim, pos.x, pos.y, pos.z, msg.c_str()
- );
- this->executeSQL(sql);
- }
-
- void PlayerStatisticManager::init(const std::string &dbName) {
- L_INFO("begin init player statistic database");
- sqlite3_open(dbName.c_str(), &this->db);
- if (this->createPlayerActionTable() != 0) {
- L_ERROR("create table failure");
- } else {
- L_INFO("success create table");
- }
- }
+// int mod::PlayerStatisticManager::createPlayerActionTable() {
+// const std::string playerActionTableSQL =
+// R"(
+// create table if not exists player_acton(
+// action_id integer primary key autoincrement,
+// player_id VARCHAR(128) not null,
+// action_time timestamp not null default (datetime('now','localtime')),
+// action_type int,
+// action_dim int,
+// action_p_x int,
+// action_p_y int,
+// action_p_z int,
+// action_string VARCHAR(512)
+// )
+// )";
+// return this->executeSQL(playerActionTableSQL);
+// }
+//
+// int PlayerStatisticManager::executeSQL(const std::string &sql) {
+// char *errorMsg;
+// auto rc = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, &errorMsg);
+// if (rc != SQLITE_OK) {
+// L_DEBUG("SQL error: %s\n", errorMsg);
+// sqlite3_free(errorMsg);
+// }
+// return rc;
+// }
+//
+// void PlayerStatisticManager::insetPlayerAction(const std::string &playerName, const trapdoor::BlockPos &pos,
+// PlayerStatisticManager::PLAYER_ACTION playerAction, int dim,
+// const std::string &msg) {
+//
+// auto sql = trapdoor::format(
+// "insert into player_acton(player_id,action_type,action_dim,action_p_x,action_p_y,action_p_z,action_string)\n"
+// " VALUES ('%s', %d,%d,%d,%d,%d, '%s')",
+// playerName.c_str(), playerAction, dim, pos.x, pos.y, pos.z, msg.c_str()
+// );
+// this->executeSQL(sql);
+// }
+//
+// void PlayerStatisticManager::init(const std::string &dbName) {
+// L_INFO("begin init player statistic database");
+// sqlite3_open(dbName.c_str(), &this->db);
+// if (this->createPlayerActionTable() != 0) {
+// L_ERROR("create table failure");
+// } else {
+// L_INFO("success create table");
+// }
+// }
}
diff --git a/mod/player/PlayerStatisticManager.h b/mod/player/PlayerStatisticManager.h
index 3653762..34479f4 100644
--- a/mod/player/PlayerStatisticManager.h
+++ b/mod/player/PlayerStatisticManager.h
@@ -11,31 +11,31 @@
#include "tools/noncopyable .h"
namespace mod {
-
- class PlayerStatisticManager : noncopyable {
- sqlite3 *db = nullptr;
- bool enable = false;
-
- int executeSQL(const std::string &sql);
-
- int createPlayerActionTable();
-
- public:
- enum PLAYER_ACTION {
- DESTROY_BLOCK,
- PLACE_BLOCK
- };
-
- inline void setAble(bool able) { this->enable = able; }
-
- inline bool isEnable() const { return this->enable; }
-
- void init(const std::string &dbName);
-
- void insetPlayerAction(const std::string &playerName, const trapdoor::BlockPos &pos,
- PLAYER_ACTION playerAction, int dim, const std::string &msg
- );
- };
+//
+// class PlayerStatisticManager : noncopyable {
+// sqlite3 *db = nullptr;
+// bool enable = false;
+//
+// int executeSQL(const std::string &sql);
+//
+// int createPlayerActionTable();
+//
+// public:
+// enum PLAYER_ACTION {
+// DESTROY_BLOCK,
+// PLACE_BLOCK
+// };
+//
+// inline void setAble(bool able) { this->enable = able; }
+//
+// inline bool isEnable() const { return this->enable; }
+//
+// void init(const std::string &dbName);
+//
+// void insetPlayerAction(const std::string &playerName, const trapdoor::BlockPos &pos,
+// PLAYER_ACTION playerAction, int dim, const std::string &msg
+// );
+// };
}
diff --git a/mod/spawn/HsaManager.cpp b/mod/spawn/HsaManager.cpp
index b59aee7..502450b 100644
--- a/mod/spawn/HsaManager.cpp
+++ b/mod/spawn/HsaManager.cpp
@@ -2,6 +2,7 @@
// Created by xhy on 2020/12/27.
//
+
#include "HsaManager.h"
#include
#include "BDSMod.h"
@@ -31,27 +32,37 @@ namespace mod {
hsaBoundingBox.minPos = firsthsa.boundingBox.minPos;
hsaBoundingBox.maxPos = firsthsa.boundingBox.maxPos;
for (const auto &hsa : this->hsaList) {
- hsaBoundingBox.minPos.x = min(hsaBoundingBox.minPos.x, hsa.boundingBox.minPos.x);
- hsaBoundingBox.minPos.y = min(hsaBoundingBox.minPos.y, hsa.boundingBox.minPos.y);
- hsaBoundingBox.minPos.z = min(hsaBoundingBox.minPos.z, hsa.boundingBox.minPos.z);
- hsaBoundingBox.maxPos.x = max(hsaBoundingBox.maxPos.x, hsa.boundingBox.maxPos.x);
- hsaBoundingBox.maxPos.y = max(hsaBoundingBox.maxPos.y, hsa.boundingBox.maxPos.y);
- hsaBoundingBox.maxPos.z = max(hsaBoundingBox.maxPos.z, hsa.boundingBox.maxPos.z);
+ hsaBoundingBox.minPos.x =
+ min(hsaBoundingBox.minPos.x, hsa.boundingBox.minPos.x);
+ hsaBoundingBox.minPos.y =
+ min(hsaBoundingBox.minPos.y, hsa.boundingBox.minPos.y);
+ hsaBoundingBox.minPos.z =
+ min(hsaBoundingBox.minPos.z, hsa.boundingBox.minPos.z);
+ hsaBoundingBox.maxPos.x =
+ max(hsaBoundingBox.maxPos.x, hsa.boundingBox.maxPos.x);
+ hsaBoundingBox.maxPos.y =
+ max(hsaBoundingBox.maxPos.y, hsa.boundingBox.maxPos.y);
+ hsaBoundingBox.maxPos.z =
+ max(hsaBoundingBox.maxPos.z, hsa.boundingBox.maxPos.z);
}
info(player, "%s %s", hsaBoundingBox.minPos.toString().c_str(),
hsaBoundingBox.maxPos.toString().c_str());
info(player, "%d", firsthsa.dimensionID);
int points = 0, maxPoints = 0;
trapdoor::BlockPos pos;
- for (int x = hsaBoundingBox.minPos.x - 44; x <= hsaBoundingBox.maxPos.x + 44; x++)
+ for (int x = hsaBoundingBox.minPos.x - 44;
+ x <= hsaBoundingBox.maxPos.x + 44; x++)
for (int y = max(hsaBoundingBox.minPos.y - 44, 0);
- y <= min(hsaBoundingBox.maxPos.y + 44, 127 + firsthsa.dimensionID == 1 ? 0 : 128);
+ y <= min(hsaBoundingBox.maxPos.y + 44,
+ 127 + firsthsa.dimensionID == 1 ? 0 : 128);
y++)
- for (int z = hsaBoundingBox.minPos.z - 44; z <= hsaBoundingBox.maxPos.z + 44; z++) {
+ for (int z = hsaBoundingBox.minPos.z - 44;
+ z <= hsaBoundingBox.maxPos.z + 44; z++) {
points = 0;
for (const auto &hsa : this->hsaList) {
- float dis = hsa.boundingBox.getCenter().distanceTo(
- trapdoor::BlockPos(x, y, z));
+ float dis = hsa.boundingBox.getSpawnArea()
+ .getCenter()
+ .distanceTo({x, y, z});
if (dis >= 24.0 && dis <= 44.0) {
points += 1;
}
@@ -70,7 +81,8 @@ namespace mod {
auto block = player->getBlockSource()->getBlock(standPos.x, standPos.y,
standPos.z);
for (const auto &hsa : this->hsaList) {
- trapdoor::BlockPos pos = hsa.boundingBox.getCenter();
+ trapdoor::BlockPos pos =
+ hsa.boundingBox.getSpawnArea().getCenter().toBlockPos();
player->getBlockSource()->setBlock(&pos, block);
}
}
@@ -111,13 +123,14 @@ namespace mod {
void HsaManager::list(Actor *player) {
// todo
- info(player, "developing");
+ info(player, "Developing...");
}
+
} // namespace mod
using namespace SymHook;
-//HSA collector
+// HSA collector
THook(
void,
MSSYM_B2QUE17spawnStructureMobB1AA7SpawnerB2AAE20AEAAXAEAVBlockSourceB2AAE12AEBVBlockPosB2AAE25AEBUHardcodedSpawningAreaB1AE10LevelChunkB2AAE19AEBVSpawnConditionsB3AAAA1Z,
@@ -153,4 +166,4 @@ THook(
blockSource->getBiome(blockPos);
modInstance->getHsaManager().insert(info);
-}
\ No newline at end of file
+}