Skip to content

Commit

Permalink
support 1.17.11.01
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohengying committed Aug 15, 2021
1 parent de3aae8 commit 6cf35b2
Show file tree
Hide file tree
Showing 104 changed files with 4,586 additions and 4,853 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Language: Cpp
BasedOnStyle: Google
UseTab: Never
IndentWidth: 4
NamespaceIndentation: All
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ log/
/trapdoor-0.9.50-1.17.1.01.vcxproj.filters
/trapdoor-0.9.50-1.17.1.01.vcxproj
*.zip
/vsbuild
/vsbuild
/sym
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ add_library(${MOD_API_NAME} STATIC
api/block/BlockLegacy.cpp
api/block/BlockSource.cpp
api/block/VanillaBlockType.cpp
api/block/CircuitComponent.cpp
api/commands/CommandNode.cpp
api/commands/Command.cpp
api/commands/CommandManager.cpp
Expand All @@ -43,7 +42,6 @@ add_library(${MOD_API_NAME} STATIC
api/tools/MsgBuilder.cpp
api/tools/ThreadPool.h
api/lib/Remotery.c
api/world/LevelChunk.cpp
api/language/I18nManager.cpp
api/language/I18nManager.h
api/tools/CastHelper.h
Expand All @@ -65,8 +63,8 @@ target_include_directories(${MOD_API_NAME}
target_link_libraries(${MOD_API_NAME} ${PROJECT_SOURCE_DIR}/api/lib/detours.lib)

####################这里是具体功能##########################
set(TRAPDOOR_VERSION 0.9.71)
set(MCBE_VERSION 1.17.10.04)
set(TRAPDOOR_VERSION 0.9.73)
set(MCBE_VERSION 1.17.11.01)
set(BETA OFF)
set(TEST_NUMBER 3)
add_definitions(-DTD_VERSION="${TRAPDOOR_VERSION}")
Expand Down Expand Up @@ -120,7 +118,7 @@ target_include_directories(
mod/dirtyLitematica
mod/eval
mod/fakePlayer

api
api/block
api/commands
Expand Down
126 changes: 64 additions & 62 deletions api/BDSMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,86 @@
//

#include "BDSMod.h"

#include "SymHook.h"
#include "lib/mod.h"
#include "tools/DirtyLogger.h"
#include "tools/Message.h"

namespace trapdoor {
//全局模组对象
BDSMod *bdsMod = nullptr;

void initializeMod(BDSMod *BDSMod) {
L_DEBUG("create BDS mod instance");
trapdoor::bdsMod = BDSMod;
}
//全局模组对象
BDSMod *bdsMod = nullptr;

Level *BDSMod::getLevel() { return this->serverLevel; }
void initializeMod(BDSMod *BDSMod) {
L_DEBUG("create BDS mod instance");
trapdoor::bdsMod = BDSMod;
}

void BDSMod::setCommandRegistry(void *registry) {
L_DEBUG("set commandRegistry");
this->commandRegistry = registry;
}
Level *BDSMod::getLevel() { return this->serverLevel; }

void *BDSMod::getCommandRegistry() { return this->commandRegistry; }
void BDSMod::setCommandRegistry(void *registry) {
L_DEBUG("set commandRegistry");
this->commandRegistry = registry;
}

void BDSMod::setLevel(Level *level) {
L_DEBUG("init server level");
this->serverLevel = level;
}
void *BDSMod::getCommandRegistry() { return this->commandRegistry; }

CommandManager &BDSMod::getCommandManager() { return this->commandManager; }
void BDSMod::setLevel(Level *level) {
L_DEBUG("init server level");
this->serverLevel = level;
}

void BDSMod::registerCommands() {
CommandManager &BDSMod::getCommandManager() { return this->commandManager; }

if (!this->commandRegistry) {
L_ERROR("fail to register command!![commandRegistry is null ptr]");
void BDSMod::registerCommands() {
if (!this->commandRegistry) {
L_ERROR("fail to register command!![commandRegistry is null ptr]");
}
L_DEBUG("begin register command");
this->registerLangCommand();
getCommandManager()
.registerCmd("apicfg", "command.apicfg.desc")
->then(ARG(
"pvd", "command.apicfg.pvd.desc", INT,
{ this->getCfg().particleViewDistance = holder->getInt(); }))
->then(ARG("pm", "command.apicfg.pm.desc", BOOL, {
this->getCfg().particlePerformanceMode = holder->getBool();
}));
}
L_DEBUG("begin register command");
this->registerLangCommand();
getCommandManager()
.registerCmd("apicfg", "command.apicfg.desc")
->then(ARG("pvd", "command.apicfg.pvd.desc", INT,
{ this->getCfg().particleViewDistance = holder->getInt(); }))
->then(ARG("pm", "command.apicfg.pm.desc", BOOL, {
this->getCfg().particlePerformanceMode = holder->getBool();
}));
}

std::map<std::string, PlayerBuffer> &BDSMod::getPlayerBuffer() {
return this->playerCache;
}
std::map<std::string, PlayerBuffer> &BDSMod::getPlayerBuffer() {
return this->playerCache;
}

void BDSMod::initialize() {
L_DEBUG("init thread pool");
this->threadPool = new ThreadPool(std::thread::hardware_concurrency());
}
void BDSMod::initialize() {
L_DEBUG("init thread pool");
this->threadPool = new ThreadPool(std::thread::hardware_concurrency());
}

trapdoor::Actor *BDSMod::fetchEntity(int64_t id, bool b) {
using namespace SymHook;
return SYM_CALL(
Actor * (*)(Level *, int64_t, bool),
MSSYM_B1QE11fetchEntityB1AA5LevelB2AAE13UEBAPEAVActorB2AAE14UActorUniqueIDB3AAUA1NB1AA1Z,
this->getLevel(), id, b);
}
trapdoor::Actor *BDSMod::fetchEntity(int64_t id, bool b) {
using namespace SymHook;
return SYM_CALL(Actor * (*)(Level *, int64_t, bool),
SymHook::Level_fetchEntity_ff3466ce, this->getLevel(),
id, b);
}

void BDSMod::registerLangCommand() {
this->commandManager.registerCmd("lang", "command.lang.desc")
->then(ARG(
"list", "command.lang.list.desc", NONE,
{ trapdoor::info(player, this->i18NManager.getAllLanguages()); }))
->then(ARG("set", "command.lang.set.desc", STR, {
auto result =
this->i18NManager.tryChangeLanguage(holder->getString());
if (result) {
info(player, LANG("command.lang.set.success"));
} else {
info(player, LANG("command.lang.set.failure"));
}
}));
}
void BDSMod::registerLangCommand() {
this->commandManager.registerCmd("lang", "command.lang.desc")
->then(ARG("list", "command.lang.list.desc", NONE,
{
trapdoor::info(player,
this->i18NManager.getAllLanguages());
}))
->then(ARG("set", "command.lang.set.desc", STR, {
auto result =
this->i18NManager.tryChangeLanguage(holder->getString());
if (result) {
info(player, LANG("command.lang.set.success"));
} else {
info(player, LANG("command.lang.set.failure"));
}
}));
}

void BDSMod::tick() { ++this->trapdoorTick; }
} // namespace trapdoor
void BDSMod::tick() { ++this->trapdoorTick; }
} // namespace trapdoor
38 changes: 18 additions & 20 deletions api/BDSMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
#ifndef TRAPDOOR_TRAPDOOR_H
#define TRAPDOOR_TRAPDOOR_H

#include <set>
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include "commands/CommandManager.h"
#include "world/Level.h"

#include "PlayerBuffer.h"
#include "commands/CommandManager.h"
#include "language/I18nManager.h"
#include "tools/ThreadPool.h"
#include "tools/noncopyable .h"
#include "language/I18nManager.h"
#include "world/Level.h"

namespace trapdoor {


class BDSMod : public noncopyable {
public:
public:
struct ModConfig {
size_t particleViewDistance = 256;
bool particlePerformanceMode = false;
};

void registerLangCommand();

protected:
protected:
typedef void CommandRegistry;
Level *serverLevel{};
CommandRegistry *commandRegistry{};
Expand All @@ -42,8 +42,7 @@ namespace trapdoor {
I18nManager i18NManager;
size_t trapdoorTick = 0;

public:

public:
void tick();

inline size_t getTrapdoorTick() { return this->trapdoorTick; }
Expand All @@ -52,7 +51,6 @@ namespace trapdoor {

void setLevel(Level *level);


CommandRegistry *getCommandRegistry();

void setCommandRegistry(CommandRegistry *registry);
Expand All @@ -65,27 +63,27 @@ namespace trapdoor {

virtual void registerCommands();


virtual void useOnHook(Actor *player, const std::string &itemName, BlockPos &pos,
unsigned int facing,
virtual void useOnHook(Actor *player, const std::string &itemName,
BlockPos &pos, unsigned int facing,
const Vec3 &) = 0;

virtual bool attackEntityHook(Actor *player, Actor *entity) = 0;

virtual CommandPermissionLevel
resetVanillaCommandLevel(const std::string &name, CommandPermissionLevel oldLevel) { return oldLevel; }
virtual CommandPermissionLevel resetVanillaCommandLevel(
const std::string &name, CommandPermissionLevel oldLevel) {
return oldLevel;
}

std::map<std::string, PlayerBuffer> &getPlayerBuffer();

template<typename Mod>
template <typename Mod>
Mod *asInstance() {
return reinterpret_cast<Mod *>(this);
}

ModConfig &getCfg() { return this->config; }


public:
public:
trapdoor::Actor *fetchEntity(int64_t id, bool b);

inline I18nManager &getI18NManager() { return this->i18NManager; }
Expand All @@ -94,6 +92,6 @@ namespace trapdoor {
void initializeMod(BDSMod *bdsMod);

extern BDSMod *bdsMod;
}
} // namespace trapdoor

#endif //TRAPDOOR_TRAPDOOR_H
#endif // TRAPDOOR_TRAPDOOR_H
Loading

0 comments on commit 6cf35b2

Please sign in to comment.