From ed4b68e29304b3c6c549226c384d176d2c7d7f61 Mon Sep 17 00:00:00 2001 From: twoone3 <3197653242@qq.com> Date: Fri, 22 Jul 2022 09:20:47 +0800 Subject: [PATCH] =?UTF-8?q?2.0.5=E6=9B=B4=E6=96=B0=20-=20=E9=80=82?= =?UTF-8?q?=E9=85=8DLL2.4.2=20-=20=E6=9B=B4=E6=96=B0clang-format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-format | 56 ++++++++++++++++++++++++++++++--------------------- Global.cpp | 3 +-- Init.cpp | 10 ++++----- ModuleDef.cpp | 24 ++++++++-------------- SDK | 2 +- 5 files changed, 48 insertions(+), 47 deletions(-) diff --git a/.clang-format b/.clang-format index 8f0c6f3..26f965d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,44 +1,54 @@ -# Visual Studio 生成的 .clang-format 文件 - -# 此文件中的样式选项是通过“工具”>“选项” -# 复制当前 IDE 格式配置的最佳尝试 +# Author: twoone-3 +# Reference: https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormatStyleOptions.html AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign -AllowShortBlocksOnASingleLine: true +AlignArrayOfStructures: Left +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: None +AlignEscapedNewlines: Left +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes BasedOnStyle: LLVM -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterStruct: false - AfterUnion: false - BeforeCatch: true - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false -BreakBeforeBraces: Custom +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Attach ColumnLimit: 0 Cpp11BracedListStyle: true -FixNamespaceComments: false -IndentCaseLabels: false +FixNamespaceComments: true +IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 4 -MaxEmptyLinesToKeep: 10 +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp +MaxEmptyLinesToKeep: 1 NamespaceIndentation: None PointerAlignment: Left SortIncludes: false SortUsingDeclarations: false SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true +SpaceBeforeCtorInitializerColon: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false +Standard: Latest TabWidth: 4 -UseTab: true +UseTab: Always diff --git a/Global.cpp b/Global.cpp index 1104c40..247d1ff 100644 --- a/Global.cpp +++ b/Global.cpp @@ -3,8 +3,7 @@ fifo_json StrToJson(std::string_view str) { try { return fifo_json::parse(str); - } - catch (const std::exception& e) { + } catch (const std::exception& e) { logger.error("\nParsing JSON failed! {}", e.what()); return nullptr; } diff --git a/Init.cpp b/Init.cpp index b9dde2e..5b1155d 100644 --- a/Init.cpp +++ b/Init.cpp @@ -8,8 +8,8 @@ using namespace std; constexpr unsigned PYR_VERSION_MAJOR = 2; constexpr unsigned PYR_VERSION_MINOR = 0; -constexpr unsigned PYR_VERSION_MICRO = 4; -constexpr const char* PYR_VERSION = "v2.0.4"; +constexpr unsigned PYR_VERSION_MICRO = 5; +constexpr const char* PYR_VERSION = "v2.0.5"; void entry() { PY_TRY; @@ -45,8 +45,7 @@ void entry() { if (name.front() == '_') { logger.debug("Ignoring {}", name); continue; - } - else { + } else { PY_TRY; logger.info("Loading {}", name); py::module_::import(name.c_str()); @@ -73,5 +72,6 @@ extern "C" _declspec(dllexport) void onPostInit() { PYR_VERSION_MINOR, PYR_VERSION_MICRO, LL::Version::Release), - {{"Author", "twoone3"}}); + "https://github.com/twoone-3/BDSpyrunner.git", + "GPL v3.0"); } diff --git a/ModuleDef.cpp b/ModuleDef.cpp index 1149b64..8fd0ffc 100644 --- a/ModuleDef.cpp +++ b/ModuleDef.cpp @@ -130,14 +130,10 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { .def("setEnum", &CommandClass::setEnum) .def("setAlias", &CommandClass::setAlias) - .def("mandatory2", py::overload_cast(&CommandClass::mandatory), - "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("mandatory", py::overload_cast(&CommandClass::mandatory), - "name"_a, "type"_a, "description"_a = "", "option"_a = None) - .def("optional2", py::overload_cast(&CommandClass::optional), - "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("optional", py::overload_cast(&CommandClass::optional), - "name"_a, "type"_a, "description"_a = "", "option"_a = None) + .def("mandatory2", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("mandatory", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None) + .def("optional2", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("optional", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None) .def("setSoftEnum", &CommandClass::setSoftEnum) .def("addSoftEnumValues", &CommandClass::addSoftEnumValues) .def("removeSoftEnumValues", &CommandClass::removeSoftEnumValues) @@ -307,8 +303,7 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { .def("hasTag", &PlayerClass::hasTag) .def("getAllTags", &PlayerClass::getAllTags) .def("getEntityFromViewVector", &PlayerClass::getEntityFromViewVector, "max_distance"_a = 5.25f) - .def("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector, - "includeLiquid"_a = false, "solidOnly"_a = false, "maxDistance"_a = 5.25f, "ignoreBorderBlocks"_a = true, "fullOnly"_a = false) + .def("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector, "includeLiquid"_a = false, "solidOnly"_a = false, "maxDistance"_a = 5.25f, "ignoreBorderBlocks"_a = true, "fullOnly"_a = false) .def("removeItem", &PlayerClass::removeItem) .def("setHeadShow", &PlayerClass::setHeadShow) @@ -338,17 +333,14 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { .def("simulateUseItem", py::overload_cast<>(&PlayerClass::simulateUseItem)) .def("simulateUseItem2", py::overload_cast(&PlayerClass::simulateUseItem)) .def("simulateUseItem3", py::overload_cast(&PlayerClass::simulateUseItem)) - .def("simulateUseItem4", py::overload_cast(&PlayerClass::simulateUseItem), - "item"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) - .def("simulateUseItem5", py::overload_cast(&PlayerClass::simulateUseItem), - "slot"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) + .def("simulateUseItem4", py::overload_cast(&PlayerClass::simulateUseItem), "item"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) + .def("simulateUseItem5", py::overload_cast(&PlayerClass::simulateUseItem), "slot"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) .def("simulateStopDestroyingBlock", &PlayerClass::simulateStopDestroyingBlock) .def("simulateStopInteracting", &PlayerClass::simulateStopInteracting) .def("simulateStopMoving", &PlayerClass::simulateStopMoving) .def("simulateStopUsingItem", &PlayerClass::simulateStopUsingItem) .def("simulateStopSneaking", &PlayerClass::simulateStopSneaking); - py::class_(mc_module, "Entity") .def_property("name", &EntityClass::getName, nullptr) .def_property("type", &EntityClass::getType, nullptr) @@ -398,7 +390,7 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { .def_property("name", &ObjectiveClass::getName, nullptr) .def_property("display_name", &ObjectiveClass::getDisplayName, nullptr) - .def("setDisplay", &ObjectiveClass::setDisplay, "slot"_a, "sort"_a=0) + .def("setDisplay", &ObjectiveClass::setDisplay, "slot"_a, "sort"_a = 0) .def("setScore", &ObjectiveClass::setScore) .def("addScore", &ObjectiveClass::addScore) .def("reduceScore", &ObjectiveClass::reduceScore) diff --git a/SDK b/SDK index 76b81ac..1c93926 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit 76b81ac91533bf20fe26ee46a3eb39a712562e4d +Subproject commit 1c93926ad8f4c3e21bcf2fdedc7b819aee581f30