diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..1c3513b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,55 @@ +name: Bug Report +description: Create a report to help us improve +title: "[Bug]: " +labels: ["bug"] +body: + - type: textarea + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + + - type: textarea + attributes: + label: To Reproduce + description: Steps to reproduce the behavior. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain your problem. + + - type: input + attributes: + label: Platform + description: The platform you are using. (e.g. Windows 10) + + - type: input + attributes: + label: BDS Version + description: The version of BDS you are using. (e.g. 1.20.32.1) + + - type: input + attributes: + label: LeviLamina Version + description: The version of LeviLamina you are using. (e.g. 1.0.0) + + - type: input + attributes: + label: Version + description: The version of the plugin you are using. (e.g. 1.0.0) + + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report_zh.yml b/.github/ISSUE_TEMPLATE/bug_report_zh.yml new file mode 100644 index 0000000..966b79d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_zh.yml @@ -0,0 +1,55 @@ +name: 漏洞反馈 +description: 如果插件存在漏洞,请在此反馈。 +title: "标题:漏洞反馈" +labels: ["type: bug"] +body: + - type: textarea + attributes: + label: 简述漏洞 + description: 发生了什么问题? + validations: + required: true + + - type: textarea + attributes: + label: 复现方案 + description: 给出具体的复现步骤。 + validations: + required: true + + - type: textarea + attributes: + label: 预期结果 + description: 简述预期结果是什么! + validations: + required: true + + - type: textarea + attributes: + label: 日志或截图 + description: 如果有条件请给出日志或截图来帮助我们修复漏洞 + + - type: input + attributes: + label: 操作系统 + description: 你所使用的操作系统 (例如: Windows 10) + + - type: input + attributes: + label: BDS 版本 + description: 你所使用的 BDS 版本 (例如: 1.20.32.1) + + - type: input + attributes: + label: LeviLamina 版本 + description: 你所使用的 LeviLamina 版本 (例如: 1.0.0) + + - type: input + attributes: + label: GMLIB 版本 + description: 你所使用的 GMLIB 版本 (例如: 1.0.0) + + - type: textarea + attributes: + label: 更多信息 + description: 如果还有更多相关信息,请提供。 diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..b0f4b33 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,28 @@ +name: Feature request +description: Suggest an idea for this project +title: "[Feature]: " +labels: ["enhancement"] +body: + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + validations: + required: true + + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request_zh.yml b/.github/ISSUE_TEMPLATE/feature_request_zh.yml new file mode 100644 index 0000000..c6554f9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request_zh.yml @@ -0,0 +1,28 @@ +name: 新功能建议 +description: 如果需要更多API,请给出你的建议。 +title: "标题:新功能建议" +labels: ["type: enhancement"] +body: + - type: textarea + attributes: + label: 您的新功能建议是否与问题有关?请描述。 + description: 简述你在开发过程中遇到了什么问题? + validations: + required: true + + - type: textarea + attributes: + label: 你想要的接口 + description: 简述你需要的API,以及具体功能。 + validations: + required: true + + - type: textarea + attributes: + label: 你曾经使用过的替代方案 + description: 简述你对于此问题使用过的替代方案。 + + - type: textarea + attributes: + label: 更多信息 + description: 给出更多信息帮助我们解决你的问题。 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..58da313 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +## What does this PR do? + + + +## Which issues does this PR resolve? + + + +## Checklist before merging + +Thank you for your contribution to the repository. +Before submitting this PR, please make sure: + +- [ ] Your code builds clean without any errors or warnings +- [ ] Your code follows [LeviLamina C++ Style Guide](https://github.com/LiteLDev/LeviLamina/wiki/CPP-Style-Guide) +- [ ] You have tested all functions +- [ ] You have not used code without license +- [ ] You have added statement for third-party code diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..60e9a2c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +on: + pull_request: + push: + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: xmake-io/github-action-setup-xmake@v1 + + - run: | + xmake repo -u + + - run: | + xmake f -a x64 -m release -p windows -v -y + + - run: | + xmake -w -y + + - uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: | + bin/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..42bf5e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +on: + release: + types: + - published + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: xmake-io/github-action-setup-xmake@v1 + + - run: | + xmake repo -u + + - run: | + xmake f -a x64 -m release -p windows -v -y + + - run: | + xmake -w -y + + - uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: | + bin/ + + upload-to-release: + needs: + - build + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: release/ + + - run: | + cp LICENSE README.md release/ + + - name: Archive release + run: | + cd release + zip -r ../${{ github.event.repository.name }}-windows-x64.zip * + cd .. + + - uses: softprops/action-gh-release@v1 + with: + append_body: true + files: | + ${{ github.event.repository.name }}-windows-x64.zip diff --git a/manifest.json b/manifest.json index 6827888..edd34e8 100644 --- a/manifest.json +++ b/manifest.json @@ -5,6 +5,9 @@ "dependencies": [ { "name": "GMLIB" + }, + { + "name": "LegacyRemoteCall" } ] } \ No newline at end of file diff --git a/src/LegacyModApi.cpp b/src/LegacyModApi.cpp index 6895f6d..24d4e4c 100644 --- a/src/LegacyModApi.cpp +++ b/src/LegacyModApi.cpp @@ -1,103 +1,108 @@ #include "Global.h" void ExportGMLib_ModAPI() { - //合成表部分 - RemoteCall::exportAs("GMLib_ModAPI", "registerShapelessRecipe", [](std::string recipe_id, std::vector ingredients, std::string result, int count, std::string unlock) -> void { - std::vector types; - for (auto ing : ingredients) { - RecipeItem key = {ing}; - types.push_back(key); - } - RecipeItem res = {result, 0, count}; - RecipeItem unl = {unlock}; - GMLib_Mod::addShapelessCraftingTableRecipe(recipe_id, types, res, {unl}); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerShapedRecipe", [](std::string recipe_id, std::vector shape, std::vector ingredients, std::string result, int count, std::string unlock) -> void { - std::vector types; - for (auto ing : ingredients) { - RecipeItem key = {ing}; - types.push_back(key); - } - RecipeItem res = {result, 0, count}; - RecipeItem unl = {unlock}; - GMLib_Mod::addShapedCraftingTableRecipe(recipe_id, shape, types, res, {unl}); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerFurnaceRecipe", [](std::string recipe_id, std::string input, std::string output, std::vector tags) -> void { - RecipeItem inp = {input}; - RecipeItem outp = {output}; - GMLib_Mod::addFurnaceRecipe(recipe_id, inp, outp, tags); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerBrewingMixRecipe", [](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void { - RecipeItem rea = {reagent}; - GMLib_Mod::addBrewingMixRecipe(recipe_id, input, output, rea); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerBrewingContainerRecipe", [](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void { - RecipeItem inp = {input}; - RecipeItem outp = {output}; - RecipeItem rea = {reagent}; - GMLib_Mod::addBrewingContainerRecipe(recipe_id, inp, outp, rea); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerSmithingTransformRecipe", [](std::string recipe_id, std::string smithing_template, std::string base, std::string addition, std::string result) -> void { - GMLib_Mod::addSmithingTransformRecipe(recipe_id, smithing_template, base, addition, result); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerSmithingTrimRecipe", [](std::string recipe_id, std::string smithing_template, std::string base, std::string addition) -> void { - GMLib_Mod::addSmithingTrimRecipe(recipe_id, smithing_template, base, addition); - }); - RemoteCall::exportAs("GMLib_ModAPI", "registerStoneCutterRecipe", [](std::string recipe_id, std::string input, int input_data, std::string output, int output_data, int output_count) -> void { - RecipeItem inp = {input, input_data}; - RecipeItem outp = {output, output_data, output_count}; - GMLib_Mod::addStoneCutterRecipe(recipe_id, inp, outp); - }); + /* + //合成表部分 + RemoteCall::exportAs("GMLib_ModAPI", "registerShapelessRecipe", [](std::string recipe_id, + std::vector ingredients, std::string result, int count, std::string unlock) -> void { + std::vector types; + for (auto ing : ingredients) { + RecipeItem key = {ing}; + types.push_back(key); + } + RecipeItem res = {result, 0, count}; + RecipeItem unl = {unlock}; + GMLib_Mod::addShapelessCraftingTableRecipe(recipe_id, types, res, {unl}); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerShapedRecipe", [](std::string recipe_id, std::vector + shape, std::vector ingredients, std::string result, int count, std::string unlock) -> void { + std::vector types; + for (auto ing : ingredients) { + RecipeItem key = {ing}; + types.push_back(key); + } + RecipeItem res = {result, 0, count}; + RecipeItem unl = {unlock}; + GMLib_Mod::addShapedCraftingTableRecipe(recipe_id, shape, types, res, {unl}); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerFurnaceRecipe", [](std::string recipe_id, std::string input, + std::string output, std::vector tags) -> void { RecipeItem inp = {input}; RecipeItem outp = + {output}; GMLib_Mod::addFurnaceRecipe(recipe_id, inp, outp, tags); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerBrewingMixRecipe", [](std::string recipe_id, std::string input, + std::string output, std::string reagent) -> void { RecipeItem rea = {reagent}; + GMLib_Mod::addBrewingMixRecipe(recipe_id, input, output, rea); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerBrewingContainerRecipe", [](std::string recipe_id, std::string + input, std::string output, std::string reagent) -> void { RecipeItem inp = {input}; RecipeItem outp = {output}; + RecipeItem rea = {reagent}; + GMLib_Mod::addBrewingContainerRecipe(recipe_id, inp, outp, rea); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerSmithingTransformRecipe", [](std::string recipe_id, std::string + smithing_template, std::string base, std::string addition, std::string result) -> void { + GMLib_Mod::addSmithingTransformRecipe(recipe_id, smithing_template, base, addition, result); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerSmithingTrimRecipe", [](std::string recipe_id, std::string + smithing_template, std::string base, std::string addition) -> void { GMLib_Mod::addSmithingTrimRecipe(recipe_id, + smithing_template, base, addition); + }); + RemoteCall::exportAs("GMLib_ModAPI", "registerStoneCutterRecipe", [](std::string recipe_id, std::string input, + int input_data, std::string output, int output_data, int output_count) -> void { RecipeItem inp = {input, + input_data}; RecipeItem outp = {output, output_data, output_count}; GMLib_Mod::addStoneCutterRecipe(recipe_id, + inp, outp); + }); - //伤害类型 - RemoteCall::exportAs("GMLib_ModAPI", "registerDamageCause", [](int vanilla_cause, std::string cause_name, std::string direct_killer_type, std::string die_type) -> void { - GMLib_Mod::addDamageCause((ActorDamageCause)vanilla_cause, cause_name, direct_killer_type, die_type); - }); - RemoteCall::exportAs("GMLib_ModAPI", "translateResourcePack", [](std::string key1, std::vector key2) -> std::string { - return GMLib_Mod::i18nTranslate(key1, key2); - }); + //伤害类型 + RemoteCall::exportAs("GMLib_ModAPI", "registerDamageCause", [](int vanilla_cause, std::string cause_name, + std::string direct_killer_type, std::string die_type) -> void { + GMLib_Mod::addDamageCause((ActorDamageCause)vanilla_cause, cause_name, direct_killer_type, die_type); + }); + RemoteCall::exportAs("GMLib_ModAPI", "translateResourcePack", [](std::string key1, std::vector key2) + -> std::string { return GMLib_Mod::i18nTranslate(key1, key2); + }); - //物品定义 - RemoteCall::exportAs("GMLib_ModAPI", "addFireImmuneItem", [](std::string id) -> void { - GMLib_Mod::addFireImmuneItem(id); - }); - RemoteCall::exportAs("GMLib_ModAPI", "addExplosionImmuneItem", [](std::string id) -> void { - GMLib_Mod::addExplosionImmuneItem(id); - }); - RemoteCall::exportAs("GMLib_ModAPI", "setArmorToughness", [](std::string id, double value) -> void { - GMLib_Mod::addArmorToughnessDefinition(id, value); - }); + //物品定义 + RemoteCall::exportAs("GMLib_ModAPI", "addFireImmuneItem", [](std::string id) -> void { + GMLib_Mod::addFireImmuneItem(id); + }); + RemoteCall::exportAs("GMLib_ModAPI", "addExplosionImmuneItem", [](std::string id) -> void { + GMLib_Mod::addExplosionImmuneItem(id); + }); + RemoteCall::exportAs("GMLib_ModAPI", "setArmorToughness", [](std::string id, double value) -> void { + GMLib_Mod::addArmorToughnessDefinition(id, value); + }); - //错误方块清理 - RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", [](bool value) -> void { - GMLib_Mod::setUnknownBlockCleaner(value); - }); + //错误方块清理 + RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", [](bool value) -> void { + GMLib_Mod::setUnknownBlockCleaner(value); + }); - //生物定义 - RemoteCall::exportAs("GMLib_ModAPI", "setFixUndeadMobs", []() -> void { - GMLib_Mod::setFixUndeadMobs(); - }); + //生物定义 + RemoteCall::exportAs("GMLib_ModAPI", "setFixUndeadMobs", []() -> void { + GMLib_Mod::setFixUndeadMobs(); + }); - //实验性 - RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { - if (ExperimentsList.count(experiment_id)) { - GMLib_Mod::addExperimentsRequire((AllExperiments)experiment_id); - } - else Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); - }); - RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void { - if (ExperimentsList.count(experiment_id)) { - GMLib_Mod::setExperimentEnabled(((AllExperiments)experiment_id), value); - } - else Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); - }); - RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool { - if (ExperimentsList.count(experiment_id)) { - return GMLib_Mod::getExperimentEnabled(((AllExperiments)experiment_id)); - } - else { - Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); - return false; - } - }); + //实验性 + RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { + if (ExperimentsList.count(experiment_id)) { + GMLib_Mod::addExperimentsRequire((AllExperiments)experiment_id); + } + else Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); + }); + RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void { + if (ExperimentsList.count(experiment_id)) { + GMLib_Mod::setExperimentEnabled(((AllExperiments)experiment_id), value); + } + else Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); + }); + RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool { + if (ExperimentsList.count(experiment_id)) { + return GMLib_Mod::getExperimentEnabled(((AllExperiments)experiment_id)); + } + else { + Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); + return false; + } + }); + */ } \ No newline at end of file diff --git a/src/LegacyServerApi.cpp b/src/LegacyServerApi.cpp index e3ccc07..07647b7 100644 --- a/src/LegacyServerApi.cpp +++ b/src/LegacyServerApi.cpp @@ -1,47 +1,47 @@ #include "Global.h" void ExportGMLib_ServerAPI() { - RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", [](bool value) -> void { - GMLib_Server::setEducationFeatureEnabled(value); + RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void { + GMLIB_Level::addEducationEditionRequired(); }); RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void { - GMLib_Server::registerAbilityCommand(); + GMLIB_Level::forceEnableAbilityCommand(); }); - RemoteCall::exportAs("GMLib_ServerAPI", "sendAddFloatingTextPacket", [](std::string text, Vec3 pos, int dimid) -> int { - return GMLib_Server::sendAddFloatingTextPacket(text, pos, dimid); + RemoteCall::exportAs("GMLib_ServerAPI", "addFloatingTextPacket", [](std::string text, std::pair pos, int dimid) -> int { + auto ft = new FloatingText(text, pos.first, pos.second); + return ft->mRuntimeId; }); - RemoteCall::exportAs("GMLib_ServerAPI", "sendAddFloatingTextPacketToPlayer", [](std::string text, Vec3 pos, int dimid, Player* pl) -> int { - return GMLib_Server::sendAddFloatingTextPacketToPlayer(text, pos, dimid, (Player*)pl); - }); - RemoteCall::exportAs("GMLib_ServerAPI", "sendDeleteFloatingTextPacket", [](int id) -> void { - GMLib_Server::sendDeleteFloatingTextPacket(id); + RemoteCall::exportAs("GMLib_ServerAPI", "deleteFloatingTextPacket", [](int id) -> void { + FloatingText::deleteFloatingText(id); }); RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void { - GMLib_Server::setEnableAchievement(); + GMLIB_Level::setForceAchievementsEnabled(); }); RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { - GMLib_Server::setForceTrustSkins(); + GMLIB_Level::setForceTrustSkin(); }); RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { - GMLib_Server::enableCoResourcePack(); + GMLIB_Level::setCoResourcePack(); }); RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string { - return GMLib_Server::getLevelName(); + return GMLIB_Level::getLevel()->getLevelName(); }); RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void { - GMLib_Server::setLevelName(name); + GMLIB_Level::getLevel()->setLevelName(name); }); RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void { - GMLib_Server::setFakeSeed(seed); + GMLIB_Level::getLevel()->setFakeSeed(seed); }); - RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](Vec3 pos, int dimid, std::string name) -> Actor* { - return GMLib_Server::spawnActor(pos, dimid, name); + RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](std::pair pos, std::string name) -> Actor* { + return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name); }); RemoteCall::exportAs("GMLib_ServerAPI", "shootProjectile", [](Actor* owner, std::string name, float speed, float offset) -> Actor* { - return GMLib_Server::shootProjectile((Actor*)owner, name, speed, offset); + auto ac = (GMLIB_Actor*)owner; + return ac->shootProjectile(name, speed, offset); }); - RemoteCall::exportAs("GMLib_ServerAPI", "throwEntity", [](Actor* owner, Actor* actor, float speed, float offset) -> bool { - return GMLib_Server::throwEntity((Actor*)owner, (Actor*)actor, speed, offset); + RemoteCall::exportAs("GMLib_ServerAPI", "throwEntity", [](Actor* owner, Actor* actor, float speed, float offset) -> bool { + auto ac = (GMLIB_Actor*)owner; + return ac->throwEntity(actor, speed, offset); }); RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player;