diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 20f5289..c552594 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -14,7 +14,18 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -59,9 +70,9 @@
-
+
-
+
@@ -118,6 +129,11 @@
+
+
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b991768..34e30bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,8 +36,7 @@ add_library(${MOD_API_NAME} STATIC
api/tools/Message.cpp
api/tools/MsgBuilder.cpp
api/tools/ThreadPool.h
- api/world/LevelChunk.cpp
- "api/tools/noncopyable .h")
+ api/world/LevelChunk.cpp)
target_include_directories(${MOD_API_NAME}
PUBLIC
api
@@ -58,7 +57,7 @@ add_library(${MOD_NAME}
SHARED
mod/dllmain.cpp
mod/TrapdoorMod.cpp
- mod/function/Explosion.cpp
+ mod/function/SingleFunctions.cpp
mod/hopper/HopperCounter.cpp
mod/config/ConfigManager.cpp
mod/village/Village.cpp
diff --git a/api/block/Block.cpp b/api/block/Block.cpp
index 2fc7183..b0d78c8 100644
--- a/api/block/Block.cpp
+++ b/api/block/Block.cpp
@@ -76,7 +76,7 @@ THook(
) {
if (trapdoor::bdsMod && !trapdoor::bdsMod->getPalette()) {
trapdoor::bdsMod->setBlockPalette(palette);
- L_INFO("set block palette");
+ // L_INFO("set block palette");
}
original(palette, id);
}
diff --git a/api/world/Dimension.cpp b/api/world/Dimension.cpp
index d6a0bbb..6f5bcdb 100644
--- a/api/world/Dimension.cpp
+++ b/api/world/Dimension.cpp
@@ -24,4 +24,11 @@ namespace trapdoor {
uint64_t *circuitSystem = reinterpret_cast(this) + 33;
return reinterpret_cast (*circuitSystem + 8);
}
+
+ bool Dimension::isRedstoneTick() {
+ //为1是红石刻2是非红石刻
+ return *((uint32_t *) this + 69) == 1;
+ // auto v2 = *((uint32_t *) this + 68); //恒定为2,也就是多少gt才过一个红石刻
+ // printf("%d %d\n", v1, v2);
+ }
}
diff --git a/api/world/Dimension.h b/api/world/Dimension.h
index 99d1450..2d19213 100644
--- a/api/world/Dimension.h
+++ b/api/world/Dimension.h
@@ -20,8 +20,9 @@ namespace trapdoor {
void printBaseTypeLimit();
CircuitSceneGraph *getGraph();
- };
+ bool isRedstoneTick();
+ };
}
diff --git a/mod/TrapdoorMod.cpp b/mod/TrapdoorMod.cpp
index e924244..1c1a2ec 100644
--- a/mod/TrapdoorMod.cpp
+++ b/mod/TrapdoorMod.cpp
@@ -19,7 +19,6 @@
namespace mod {
void TrapdoorMod::heavyTick() {
-
this->villageHelper.tick();
this->hsaManager.tick();
this->spawnHelper.tick();
@@ -29,7 +28,7 @@ namespace mod {
void TrapdoorMod::lightTick() {
this->hopperChannelManager.tick();
- this->spawnAnalyzer.tick();
+ // this->spawnAnalyzer.tick();
}
//这个函数会在初始化Level对象后执行
@@ -40,7 +39,8 @@ namespace mod {
mod::initBackup();
this->villageHelper.setConfig(this->configManager.getVillageConfig());
get_cpu_usage();
- L_INFO("==== trapdoor init finish ====\n Server Start");
+ this->initFunctionEnable();
+ L_INFO("==== trapdoor init finish ====\nServer Start");
}
void TrapdoorMod::registerCommands() {
@@ -58,46 +58,34 @@ namespace mod {
//功能开关命令
commandManager.registerCmd("func", "开启/关闭部分功能")
->then(ARG("hopper", "开启/关闭漏斗计数器", BOOL, {
- if (!this->configManager.getFunctionConfig().hopperCounter) {
- error(player, "该功能已被关闭,请联系服主");
- return;
- }
this->hopperChannelManager.setAble(holder->getBool());
info(player, "设置漏斗计数器为 %d", holder->getBool());
}))
->then(ARG("spawn", "开启/关闭刷怪指示", BOOL, {
- if (!this->configManager.getFunctionConfig().spawnHelper) {
- error(player, "该功能已被关闭,请联系服主");
- return;
- }
+
this->spawnHelper.setAble(holder->getBool());
info(player, "设置刷怪指示器为 %d", holder->getBool());
}))
->then(ARG("rotate", "开启/关闭转方块", BOOL, {
- if (!configManager.getFunctionConfig().cactusRotation) {
- error(player, "该功能已被关闭,请联系服主");
- return;
- }
this->rotationHelper.setAble(holder->getBool());
info(player, "设置仙人掌转方块为 %d", holder->getBool());
}))
->then(ARG("draw", "开启/关闭区块draw命令", BOOL, {
- if (!configManager.getFunctionConfig().simpleDraw) {
- error(player, "该功能已被关闭,请联系服主");
- return;
- }
this->simpleBuilder.setAble(holder->getBool());
info(player, "设置简单建造为 %d", holder->getBool());
}))
->then(ARG("stat", "开启/关闭玩家行为统计", BOOL, {
- if (!configManager.getFunctionConfig().playerStat) {
- error(player, "该功能已被关闭,请联系服主");
- return;
- }
this->playerStatisticManager.setAble(holder->getBool());
info(player, "设置玩家行为统计为 %d", holder->getBool());
+ }))
+ ->then(ARG("expl", "开启/关闭爆炸破坏地形", BOOL, {
+ this->singleFunctions.preventExplosion = holder->getBool();
+ info(player, "设置爆炸破坏地形 %d", holder->getBool());
+ }))
+ ->then(ARG("ncud", "开启/关闭阻止NE更新", BOOL, {
+ this->singleFunctions.preventNCUpdate = holder->getBool();
+ info(player, "设置阻止NC更新为 %d", holder->getBool());
}));
-
//史莱姆显示
commandManager.registerCmd("slime", "史莱姆区块相关")
->then(ARG("show", "显示史莱姆区块", BOOL, {
@@ -133,12 +121,6 @@ namespace mod {
broadcastMsg("设置玩家[%s]为观察者模式", player->getNameTag().c_str());
});
-// commandManager.registerCmd("o", "test")
-// ->then(ARG("s", "cc", INT, {
-// player->setGameMode(holder->getInt());
-// broadcastMsg("设置玩家[%s]为模式 %d", player->getNameTag().c_str(), holder->getInt());
-// }));
-
commandManager.registerCmd("s", "切换到生存模式")
->EXE({
player->setGameMode(0);
@@ -167,11 +149,11 @@ namespace mod {
}))
->then(ARG("s", "显示铁傀儡刷新区域", BOOL, {
this->villageHelper.setShowGolemSpawnArea(holder->getBool());
- info(player, "设置村庄边框显示为 %d", holder->getBool());
+ info(player, "设置铁傀儡刷怪显示为 %d", holder->getBool());
}))
->then(ARG("c", "显示村庄中心", BOOL, {
this->villageHelper.setShowVillageCenter(holder->getBool());
- info(player, "设置村庄边框显示为 %d", holder->getBool());
+ info(player, "设置村庄中心显示为 %d", holder->getBool());
}))
->then(ARG("v", "显示村民信息", BOOL, {
this->villageHelper.setShowDwellerStatus(holder->getBool());
@@ -208,7 +190,6 @@ namespace mod {
}))
->then(ARG("draw", "draw hsa", NONE, { hsaManager.draw(player); }));
-
commandManager.registerCmd("draw", "简单建造")
->then(ARG("ci", "画圆", INT,
{
@@ -231,6 +212,7 @@ namespace mod {
if (radius < 0) {
error(player, "参数不合法(必须>=1)");
} else {
+ info(player, "已设置最大半径为%d", radius);
this->simpleBuilder.setMaxRadius(radius);
}
}));
@@ -266,7 +248,7 @@ namespace mod {
return;
}
this->playerFunctions.getMeasureData(player->getNameTag()).enableMeasure = holder->getBool();
- info(player, "设置你的测量开启/关闭 %d", holder->getBool());
+ info(player, "设置你的测量w为 %d", holder->getBool());
}))
->then(ARG("rs", "测量", BOOL, {
if (!configManager.getSelfEnableConfig().enableRedstoneStick) {
@@ -274,10 +256,11 @@ namespace mod {
return;
}
this->playerFunctions.setRedstoneHelperAble(player->getNameTag(), holder->getBool());
- info(player, "设置你的信号源提示开启/关闭 %d", holder->getBool());
+ info(player, "设置你的信号源提示为 %d", holder->getBool());
}))
->EXE({ PlayerFunction::printInfo(player); });
+
commandManager.registerCmd("os", "显示服务器信息")
->EXE({ TrapdoorMod::printOSInfo(player); });
}
@@ -293,7 +276,7 @@ namespace mod {
if (slowTime > 1 && slowTime <= 64) {
tick::slowTick(slowTime);
} else {
- error(player, "number must in [2-64]");
+ error(player, "放慢倍数必须在 [2-64] 之间");
}
}))
->then(ARG("acc", "加速世界运行[num]倍速", INT, {
@@ -309,6 +292,9 @@ namespace mod {
}))
->then(ARG("fw", "世界运行步进[num] gt", INT, {
tick::forwardTick(holder->getInt());
+ }))
+ ->then(ARG("q", "查询当前世界状态", NONE, {
+ tick::queryStatus(player);
}));
}
@@ -360,7 +346,6 @@ namespace mod {
}
}
-
CommandPermissionLevel
TrapdoorMod::resetVanillaCommandLevel(const std::string &name, CommandPermissionLevel oldLevel) {
auto lowLevelConfig = this->configManager.getLowLevelCommands();
@@ -401,4 +386,13 @@ namespace mod {
return true;
}
}
+
+ void TrapdoorMod::initFunctionEnable() {
+ auto functionCfg = this->configManager.getFunctionConfig();
+ this->spawnHelper.setAble(functionCfg.spawnHelper);
+ this->rotationHelper.setAble(functionCfg.cactusRotation);
+ 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 75a50aa..22736a2 100644
--- a/mod/TrapdoorMod.h
+++ b/mod/TrapdoorMod.h
@@ -25,8 +25,14 @@ namespace mod {
const std::string modVersion = "trapdoor-0.9.20";
};
+ struct SingleFunction {
+ bool preventExplosion = false;
+ bool preventNCUpdate = false;
+ };
+
class TrapdoorMod : public trapdoor::BDSMod {
private:
+ SingleFunction singleFunctions;
HopperChannelManager hopperChannelManager;
VillageHelper villageHelper;
HsaManager hsaManager;
@@ -41,6 +47,7 @@ namespace mod {
void registerTickCommand();
+ void initFunctionEnable();
public:
ModInfo modeInfo;
@@ -58,6 +65,7 @@ namespace mod {
void useOnHook(Actor *player, const std::string &itemName, BlockPos &pos, unsigned int facing,
const Vec3 &) override;
+
CommandPermissionLevel
resetVanillaCommandLevel(const std::string &name, CommandPermissionLevel oldLevel) override;
@@ -84,7 +92,7 @@ namespace mod {
inline std::string getLevelName() { return this->configManager.getServerConfig().levelName; }
-
+ inline SingleFunction getSingFunction() { return this->singleFunctions; }
};
}
diff --git a/mod/config/ConfigManager.cpp b/mod/config/ConfigManager.cpp
index 8586b5a..30e5c8a 100644
--- a/mod/config/ConfigManager.cpp
+++ b/mod/config/ConfigManager.cpp
@@ -87,7 +87,7 @@ namespace mod {
try {
auto funcConfig = this->configJson["functionsEnable"];
this->functionConfig.hopperCounter = funcConfig["hopperCounter"].get();
- this->functionConfig.explosion = funcConfig["explosion"].get();
+ // this->functionConfig.explosion = funcConfig["explosion"].get();
this->functionConfig.spawnHelper = funcConfig["spawnHelper"].get();
this->functionConfig.cactusRotation = funcConfig["cactusRotate"].get();
this->functionConfig.simpleDraw = funcConfig["simpleDraw"].get();
diff --git a/mod/function/Explosion.cpp b/mod/function/Explosion.cpp
deleted file mode 100644
index 565515e..0000000
--- a/mod/function/Explosion.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//
-// Created by xhy on 2020/12/23.
-//
-#include "lib/mod.h"
-#include "lib/SymHook.h"
-
-
-namespace mod {
- using namespace SymHook;
- THook(
- void,
- MSSYM_B1QA7explodeB1AA9ExplosionB2AAA7QEAAXXZ,
- void * exp
- ) {
- original(exp);
- }
-}
\ No newline at end of file
diff --git a/mod/function/SingleFunctions.cpp b/mod/function/SingleFunctions.cpp
new file mode 100644
index 0000000..0041c06
--- /dev/null
+++ b/mod/function/SingleFunctions.cpp
@@ -0,0 +1,40 @@
+//
+// Created by xhy on 2020/12/23.
+//
+#include "lib/mod.h"
+#include "lib/SymHook.h"
+#include "BDSMod.h"
+#include "TrapdoorMod.h"
+
+namespace mod {
+ using namespace SymHook;
+
+ THook(
+ void,
+ MSSYM_B1QA7explodeB1AA9ExplosionB2AAA7QEAAXXZ,
+ void * exp
+ ) {
+ auto modInstance = trapdoor::bdsMod->asInstance();
+ if (!modInstance->getSingFunction().preventExplosion)
+ original(exp);
+ }
+
+ /**
+ * SYM_CALL(
+ void(*)(BlockSource * self,const BlockPos *pos),
+ MSSYM_B1QE17updateNeighborsAtB1AE11BlockSourceB2AAE17QEAAXAEBVBlockPosB3AAAA1Z,
+ this, pos
+ );
+ */
+
+ THook(
+ void,
+ MSSYM_B1QE17updateNeighborsAtB1AE11BlockSourceB2AAE17QEAAXAEBVBlockPosB3AAAA1Z,
+ trapdoor::BlockSource *source,
+ trapdoor::BlockPos * pos
+ ) {
+ auto modInstance = trapdoor::bdsMod->asInstance();
+ if (!modInstance->getSingFunction().preventNCUpdate)
+ original(source, pos);
+ }
+}
\ No newline at end of file
diff --git a/mod/tick/GameTick.cpp b/mod/tick/GameTick.cpp
index e976544..5b0988c 100644
--- a/mod/tick/GameTick.cpp
+++ b/mod/tick/GameTick.cpp
@@ -35,6 +35,7 @@ namespace mod::tick {
/*
* 这个函数也是每gt执行一次的,但是不经过 TrapdoorMod,因此用static 来表示
*/
+
void staticWork() {
//实体性能分析的更新
if (mod::tick::getActorProfiler().inProfiling) {
@@ -54,9 +55,9 @@ namespace mod::tick {
if (tickStatus != WorldTickStatus::Frozen) {
tickStatus = WorldTickStatus::Frozen;
L_DEBUG("freeze world");
- broadcastMsg("world has frozen!");
+ broadcastMsg("世界运行已停止");
} else {
- broadcastMsg("it's in frozen state now");
+ broadcastMsg("已经是停止状态");
}
}
}
@@ -66,17 +67,17 @@ namespace mod::tick {
tickStatus = WorldTickStatus::Normal;
L_DEBUG("reset world");
}
- broadcastMsg("world has reset to normal status");
+ broadcastMsg("已重置世界运行为正常状态");
}
void wrapTick(size_t speed) {
if (tickStatus == WorldTickStatus::Normal) {
- broadcastMsg("world begin warp");
+ broadcastMsg("世界开始以%zu倍速运行(理论值)", speed);
tickStatus = WorldTickStatus::Wrap;
L_DEBUG("begin wrap world %d", speed);
wrapSpeed = speed;
} else {
- broadcastMsg("this command can only be run in normal mode");
+ broadcastMsg("世界不是正常状态,无法使用加速");
}
}
@@ -85,37 +86,38 @@ namespace mod::tick {
forwardTickNum = tickNum;
lastTickStats = tickStatus;
tickStatus = WorldTickStatus::Forward;
- broadcastMsg("forwarding start, %d tick last", tickNum);
+ if (tickNum > 1200)
+ broadcastMsg("开始前进,还剩 %zu gt", tickNum);
L_DEBUG("begin forward %d tick", tickNum);
} else {
- broadcastMsg("this command can't be run in slow or wrap mode");
+ broadcastMsg("这个指令只能在正常或者暂停状态下运行");
}
}
void slowTick(size_t slowSpeed) {
if (tickStatus == WorldTickStatus::Normal) {
- broadcastMsg("world has slowed %d times\n", slowSpeed);
+ broadcastMsg("世界现在以 %zu 的速度放慢运行", slowSpeed);
L_DEBUG("slow world %d times", slowSpeed);
tickStatus = WorldTickStatus::Slow;
SlowDownTimes = slowSpeed;
} else {
- broadcastMsg("this command must be run at normal status\n");
+ broadcastMsg("现在处于非正常状态,无法减速\n");
}
}
void profileWorld(trapdoor::Actor *player) {
if (gameProfiler.inProfiling) {
- trapdoor::warning(player, "another profiling is running");
+ trapdoor::warning(player, "另外一个分析器在运行中");
return;
}
if (tickStatus != WorldTickStatus::Normal) {
- trapdoor::warning(player, "you are not in normal mode,the result may be wrong");
+ trapdoor::warning(player, "世界不在正常状态,性能分析可能不准确");
}
L_DEBUG("begin profiling");
- info(player, "start profiling...");
+ info(player, "开始分析...");
gameProfiler.inProfiling = true;
gameProfiler.currentRound = gameProfiler.totalRound;
}
@@ -130,18 +132,38 @@ namespace mod::tick {
void profileEntities(trapdoor::Actor *player) {
if (getActorProfiler().inProfiling) {
- trapdoor::warning(player, "another profiling is in running");
+ trapdoor::warning(player, "另外一个分析在运行中");
return;
}
if (tick::getTickStatus() != tick::WorldTickStatus::Normal) {
- trapdoor::warning(player, "you are not in normal mode,the result may be wrong");
+ trapdoor::warning(player, "世界不在正常状态,性能分析可能不准确");
}
L_DEBUG("begin profiling");
- info(player, "start entities profiling...");
+ info(player, "开始实体性能分析...");
getActorProfiler().inProfiling = true;
getActorProfiler().currentRound = getActorProfiler().totalRound;
}
+
+ void queryStatus(trapdoor::Actor *player) {
+ switch (tickStatus) {
+ case Frozen:
+ info(player, "暂停");
+ return;
+ case Normal:
+ info(player, "正常");
+ return;
+ case Slow:
+ info(player, "放慢%d倍", tick::SlowDownTimes);
+ return;
+ case Forward:
+ info(player, "快进");
+ return;
+ case Wrap:
+ info(player, "加速%d倍", tick::wrapSpeed);
+ return;
+ }
+ }
}
using namespace SymHook;
@@ -151,8 +173,6 @@ THook(
MSSYM_B1QA4tickB1AE11ServerLevelB2AAA7UEAAXXZ,
trapdoor::Level * serverLevel
) {
-
-
if (!trapdoor::bdsMod) {
L_ERROR("mod is nullptr");
}
@@ -178,7 +198,8 @@ THook(
if (mod::tick::isMSPTing) {
auto mspt = (double) timeReslut / 1000;
int tps = mspt <= 50 ? 20 : (int) (1000.0 / mspt);
- trapdoor::broadcastMsg("mspt: %.3lf ms tps: %d", mspt, tps);
+ bool isRedstoneTick = modInstance->getLevel()->getDimFromID(0)->isRedstoneTick();
+ trapdoor::broadcastMsg("r:%d mspt: %.3lf ms tps: %d ", isRedstoneTick, mspt, tps);
mod::tick::isMSPTing = false;
}
if (mod::tick::gameProfiler.inProfiling) {
@@ -198,7 +219,6 @@ THook(
}
break;
-
case mod::tick::Slow:
if (mod::tick::slowDownCounter % mod::tick::SlowDownTimes == 0) {
original(serverLevel);
@@ -212,7 +232,7 @@ THook(
original(serverLevel);
modInstance->lightTick();
}
- trapdoor::broadcastMsg("forwarding end\n%d tick passed", mod::tick::forwardTickNum);
+ trapdoor::broadcastMsg("%d gt 过去了", mod::tick::forwardTickNum);
mod::tick::forwardTickNum = 0;
mod::tick::tickStatus = mod::tick::lastTickStats;
break;
@@ -369,8 +389,7 @@ THook(
} else {
original(dim);
}
- // auto v1 = *((int *) globalDimension + 69);
- // auto v2 = *((int *) globalDimension + 68);
+
// printf("69%d 68%d\n", v1, v2);
// printf("69:%d 68:%d\n", v1, v2);
}
diff --git a/mod/tick/GameTick.h b/mod/tick/GameTick.h
index 9af6da2..655c470 100644
--- a/mod/tick/GameTick.h
+++ b/mod/tick/GameTick.h
@@ -39,6 +39,9 @@ namespace mod::tick {
void profileWorld(trapdoor::Actor *player);
void profileEntities(trapdoor::Actor *player);
+
+ void queryStatus(trapdoor::Actor *player);
+
void mspt();
}
diff --git "a/\346\233\264\346\226\260\346\227\245\345\277\227.md" "b/\346\233\264\346\226\260\346\227\245\345\277\227.md"
new file mode 100644
index 0000000..b383857
--- /dev/null
+++ "b/\346\233\264\346\226\260\346\227\245\345\277\227.md"
@@ -0,0 +1,7 @@
+## 1.16.4-0.9.22
+### 新增
+ - 新增 tick q 指令查询当前事件状态
+ - mspt会显示计算的是否为红石刻
+ - func 新增阻止爆炸破坏方块功能(func expl true/false)
+ - func 新增阻止NC更新的功能(func ncud true/false)
+ - 配置文件内的func功能改成设置改功能是否默认开启
\ No newline at end of file