From 5822ea91125c30a8ddb4a34f69f588589e2003a6 Mon Sep 17 00:00:00 2001 From: CuteKitten <94376005+Lovelylavender4@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:50:43 +0800 Subject: [PATCH 01/14] chore: update CHANGELOG.md --- CHANGELOG.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a97574b47d..da34e1d8cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,15 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- **Adapted to BDS version *1.21.5x*** @OEOTYAN @ddf8196 @Dofes @dreamguxiang @futrime @KawaiiNahida @Lovelylavender4 @PA733 @Pd233 @RimuruChan @ShrBox @wu-vincent -- **Added support for *Windows* platform *clients*** @OEOTYAN @ddf8196 @Dofes +- **Adapted to BDS version *1.21.50*** @OEOTYAN @ddf8196 @Dofes @dreamguxiang @futrime @KawaiiNahida @Lovelylavender4 @PA733 @Pd233 @RimuruChan @ShrBox @wu-vincent - Added the missing field to CommandRegistry::Overload @wu-vincent -- Added last member variable of ChunkSource @xNotTozic - Added StdoutRedirector @OEOTYAN - Added imgui and some relate codes @ddf8196 @OEOTYAN - Added function definitions for ItemStackBase::getTypeName, ItemStackBase::getDescriptionName, ItemStackBase::getDamageValue to the source file @Dofes - Added some headers for ui @Dofes -- Added compiler specific defines for clang @Redbeanw44602 - Added clang/gcc virtualDetector @OEOTYAN - Added hints for double enable/disable @OEOTYAN - Added new signature resolver @OEOTYAN @@ -40,14 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added TypedStorage @OEOTYAN - Added initializer_list for CompoundTagVariant @OEOTYAN - Adaptted to new preloader @OEOTYAN -- Completes OreFeature, BlockDescriptor @Lovelylavender4 -- Completes the FertilizerType enum class @zimuya4153 -- Completes GameRulesIndex @KobeBryant114514 -- Completes BookEditAction and EmotePacket::Flags @zimuya4153 -- Completes ItemReleaseInventoryTransaction and ItemUseInventoryTransaction and ItemUseOnActorInventoryTransaction member variables @xNotTozic -- Completes DirtyTicksCounter and SubChunk and SubChunkStorage and Dimension and BuildInfo member variables @OEOTYAN -- Completes InteractPacket::Action @xNotTozic -- Completes ReplaceRule member variables @Lovelylavender4 +- Completes some class member @Lovelylavender4 @zimuya4153 @KobeBryant114514 @OEOTYAN - Moved concepts to internal @OEOTYAN - Filled sim::LookDuration @ShrBox - Resolved [#1519] @OEOTYAN From 6dd80b7670db5c1d381fcbc437e90e34d4497991 Mon Sep 17 00:00:00 2001 From: Zijian Zhang Date: Sun, 5 Jan 2025 09:45:33 +0800 Subject: [PATCH 02/14] docs: fix lip links --- docs/main/developer_guides/create_your_first_mod.md | 2 +- docs/main/developer_guides/create_your_first_mod.zh.md | 2 +- docs/main/developer_guides/publish_your_first_mod.md | 4 ++-- docs/main/developer_guides/publish_your_first_mod.zh.md | 4 ++-- docs/main/developer_guides/publish_your_first_pack.md | 4 ++-- docs/main/developer_guides/publish_your_first_pack.zh.md | 4 ++-- docs/main/player_guides/install.md | 4 ++-- docs/main/player_guides/install.zh.md | 4 ++-- docs/main/quickstart.md | 4 ++-- docs/main/quickstart.zh.md | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/main/developer_guides/create_your_first_mod.md b/docs/main/developer_guides/create_your_first_mod.md index 433a2b3f8f..8bd36370d3 100644 --- a/docs/main/developer_guides/create_your_first_mod.md +++ b/docs/main/developer_guides/create_your_first_mod.md @@ -22,7 +22,7 @@ This tutorial covers the following topics: - Calling Minecraft functions !!! info - All the source code for this tutorial can be found at [futrime/better-suicide](https://github.com/futrime/better-suicide). We recommend that you look at the source code while reading the tutorial. If you have installed [lip](https://lip.futrime.com), you can also run the following code to install the mod implemented in this tutorial in the LeviLamina instance environment. + All the source code for this tutorial can be found at [futrime/better-suicide](https://github.com/futrime/better-suicide). We recommend that you look at the source code while reading the tutorial. If you have installed [lip](https://futrime.github.io/lip), you can also run the following code to install the mod implemented in this tutorial in the LeviLamina instance environment. ```shell lip install github.com/futrime/better-suicide diff --git a/docs/main/developer_guides/create_your_first_mod.zh.md b/docs/main/developer_guides/create_your_first_mod.zh.md index fa9d295a87..bbeba3949d 100644 --- a/docs/main/developer_guides/create_your_first_mod.zh.md +++ b/docs/main/developer_guides/create_your_first_mod.zh.md @@ -22,7 +22,7 @@ - 调用Minecraft函数 !!! info - 本教程的所有源码可以在[futrime/better-suicide](https://github.com/futrime/better-suicide)找到。我们建议你一边看源码一边看教程。如果你已经安装了[lip](https://lip.futrime.com),你还可以直接运行以下代码在LeviLamina实例环境中安装本教程中实现的模组。 + 本教程的所有源码可以在[futrime/better-suicide](https://github.com/futrime/better-suicide)找到。我们建议你一边看源码一边看教程。如果你已经安装了[lip](https://futrime.github.io/lip),你还可以直接运行以下代码在LeviLamina实例环境中安装本教程中实现的模组。 ```shell lip install github.com/futrime/better-suicide diff --git a/docs/main/developer_guides/publish_your_first_mod.md b/docs/main/developer_guides/publish_your_first_mod.md index 6cf9eb6c7f..9f667671b5 100644 --- a/docs/main/developer_guides/publish_your_first_mod.md +++ b/docs/main/developer_guides/publish_your_first_mod.md @@ -4,7 +4,7 @@ In the tutorial [Create Your First Mod](create_your_first_mod.md), we created a ### Prerequisites -First, make sure you have installed [lip](https://github.com/lippkg/lip). +First, make sure you have installed [lip](https://github.com/futrime/lip). You should also have followed the steps in [Create Your First Mod](create_your_first_mod.md) to create a mod, where the exported mod directory has a structure similar to the following: @@ -65,7 +65,7 @@ Replace the value of the `tooth` field with the GitHub repository address of you !!! note The `dependencies` section automatically installs the required mods when installing the mod and uninstalls them when uninstalling the mod. However, the `prerequisites` section does not automatically install the required mods; instead, it throws an error if the dependencies are missing. Generally, the mods listed in the `prerequisites` section should be fundamental and framework-level packages, such as `github.com/LiteLDev/LeviLamina`, to avoid accidentally uninstalling them during the mod uninstallation process. -For more information about `tooth.json`, please refer to . +For more information about `tooth.json`, please refer to . ### Try Packing and Installing the Mod diff --git a/docs/main/developer_guides/publish_your_first_mod.zh.md b/docs/main/developer_guides/publish_your_first_mod.zh.md index 16c236c55e..d139e1bfa5 100644 --- a/docs/main/developer_guides/publish_your_first_mod.zh.md +++ b/docs/main/developer_guides/publish_your_first_mod.zh.md @@ -4,7 +4,7 @@ ### 前置条件 -首先,你应当确保你安装了[lip](https://github.com/lippkg/lip)。 +首先,你应当确保你安装了[lip](https://github.com/futrime/lip)。 你还应当按照[创建你的第一个模组](create_your_first_mod.md)中的步骤创建了一个模组,其中模组导出目录有类似如下的结构: @@ -65,7 +65,7 @@ !!! note `dependencies`在安装模组时,会自动安装依赖的模组,在卸载模组时,会自动卸载依赖的模组。但是`prerequisites`不会自动安装,而是在缺少依赖时报错。一般来说,`prerequisites`中的模组应当是一些基础性的、框架级别的包,例如`github.com/LiteLDev/LeviLamina`,以避免模组的卸载过程中误卸载了这些包。 -更多关于`tooth.json`的信息,请参考。 +更多关于`tooth.json`的信息,请参考。 ### 尝试打包和安装模组 diff --git a/docs/main/developer_guides/publish_your_first_pack.md b/docs/main/developer_guides/publish_your_first_pack.md index 94a6f4ebb5..bc8658c842 100644 --- a/docs/main/developer_guides/publish_your_first_pack.md +++ b/docs/main/developer_guides/publish_your_first_pack.md @@ -1,6 +1,6 @@ # Publishing your first pack -First, you should ensure that you have installed [lip](https://github.com/lippkg/lip). +First, you should ensure that you have installed [lip](https://github.com/futrime/lip). ## Creating a Repository @@ -36,7 +36,7 @@ Replace the value of the `tooth` field with the GitHub repository address, repla In the `dependencies` section, specify LeviLamina and any other packages to be integrated. -For more information about `tooth.json`, please refer to . +For more information about `tooth.json`, please refer to . ### Trying to Pack and Install the Pack diff --git a/docs/main/developer_guides/publish_your_first_pack.zh.md b/docs/main/developer_guides/publish_your_first_pack.zh.md index b94dd2e284..445444de63 100644 --- a/docs/main/developer_guides/publish_your_first_pack.zh.md +++ b/docs/main/developer_guides/publish_your_first_pack.zh.md @@ -1,6 +1,6 @@ # 发布你的第一个整合包 -首先,你应当确保你安装了[lip](https://github.com/lippkg/lip)。 +首先,你应当确保你安装了[lip](https://github.com/futrime/lip)。 ## 创建一个仓库 @@ -35,7 +35,7 @@ 在`dependencies`中填写LeviLamina和要整合的一切包。 -更多关于`tooth.json`的信息,请参考。 +更多关于`tooth.json`的信息,请参考。 ### 尝试打包和安装整合包 diff --git a/docs/main/player_guides/install.md b/docs/main/player_guides/install.md index 43afad424f..7f55fc2c2c 100644 --- a/docs/main/player_guides/install.md +++ b/docs/main/player_guides/install.md @@ -27,11 +27,11 @@ You can install LeviLamina in different ways, depending on your needs: ### Install via LipUI -Simply download and run [LipUI](https://github.com/lippkg/LipUI), and then install LeviLamina from the package index. +Simply download and run [LipUI](https://github.com/futrime/lipui), and then install LeviLamina from the package index. ### Install via lip -If you have not installed lip, you can install it following the instructions in [lip installation guide](https://lip.futrime.com/install/). +If you have not installed lip, you can install it following the instructions in [lip installation guide](https://futrime.github.io/lip/install/). After installing lip, you can install LeviLamina by running the following command: diff --git a/docs/main/player_guides/install.zh.md b/docs/main/player_guides/install.zh.md index bb29ee834a..03778368b8 100644 --- a/docs/main/player_guides/install.zh.md +++ b/docs/main/player_guides/install.zh.md @@ -27,11 +27,11 @@ ### 通过 lipUI 安装 -只需要下载并运行[LipUI](https://github.com/lippkg/LipUI)并在包市场中选择LeviLamina安装即可。 +只需要下载并运行[LipUI](https://github.com/futrime/lipui)并在包市场中选择LeviLamina安装即可。 ### 通过 lip 安装 -如果你还没有安装 lip,你可以按照[lip 安装指南](https://lip.futrime.com/zh/install/)中的说明进行安装。 +如果你还没有安装 lip,你可以按照[lip 安装指南](https://futrime.github.io/lip/zh/install/)中的说明进行安装。 安装 lip 后,你可以通过运行以下命令来安装 LeviLamina: diff --git a/docs/main/quickstart.md b/docs/main/quickstart.md index 82367b2be0..9a453b0e34 100644 --- a/docs/main/quickstart.md +++ b/docs/main/quickstart.md @@ -2,12 +2,12 @@ ## Before You Begin -We strongly recommend using [lip](https://lip.futrime.com/install/) for mod installation. If you have not installed it locally yet, please go ahead and check it out. +We strongly recommend using [lip](https://futrime.github.io/lip/install/) for mod installation. If you have not installed it locally yet, please go ahead and check it out. The following content is for a quick start with using lip. !!! tip - Not accustomed to using command-line tools? You can use [LipUI](https://github.com/lippkg/LipUI). + Not accustomed to using command-line tools? You can use [LipUI](https://github.com/futrime/lipui). ## Installing LeviLamina diff --git a/docs/main/quickstart.zh.md b/docs/main/quickstart.zh.md index af61337d30..8a2d5006e3 100644 --- a/docs/main/quickstart.zh.md +++ b/docs/main/quickstart.zh.md @@ -2,12 +2,12 @@ ## 开始之前 -我们强烈推荐你使用 [lip](https://lip.futrime.com/zh/install/) 来进行模组安装。如果您尚未在本地安装,请前往查看。 +我们强烈推荐你使用 [lip](https://futrime.github.io/lip/zh/install/) 来进行模组安装。如果您尚未在本地安装,请前往查看。 以下内容针对使用 lip 的情况下进行快速入门。 !!! tip - 不习惯使用命令行工具?你可以使用[LipUI](https://github.com/lippkg/LipUI)。 + 不习惯使用命令行工具?你可以使用[LipUI](https://github.com/futrime/lipui)。 ## 配置代理或镜像 From 67451c15ff3d953bc3b18d06b078c13766bb6fa7 Mon Sep 17 00:00:00 2001 From: Lovelylavender4 Date: Sun, 5 Jan 2025 11:33:54 +0800 Subject: [PATCH 03/14] docs: changed some links --- docs/main/developer_guides/publish_your_first_mod.md | 2 +- docs/main/developer_guides/publish_your_first_mod.zh.md | 2 +- docs/main/developer_guides/publish_your_first_pack.md | 2 +- docs/main/developer_guides/publish_your_first_pack.zh.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/main/developer_guides/publish_your_first_mod.md b/docs/main/developer_guides/publish_your_first_mod.md index 9f667671b5..529548819c 100644 --- a/docs/main/developer_guides/publish_your_first_mod.md +++ b/docs/main/developer_guides/publish_your_first_mod.md @@ -4,7 +4,7 @@ In the tutorial [Create Your First Mod](create_your_first_mod.md), we created a ### Prerequisites -First, make sure you have installed [lip](https://github.com/futrime/lip). +First, make sure you have installed [lip](https://futrime.github.io/lip). You should also have followed the steps in [Create Your First Mod](create_your_first_mod.md) to create a mod, where the exported mod directory has a structure similar to the following: diff --git a/docs/main/developer_guides/publish_your_first_mod.zh.md b/docs/main/developer_guides/publish_your_first_mod.zh.md index d139e1bfa5..51d1c9e8dd 100644 --- a/docs/main/developer_guides/publish_your_first_mod.zh.md +++ b/docs/main/developer_guides/publish_your_first_mod.zh.md @@ -4,7 +4,7 @@ ### 前置条件 -首先,你应当确保你安装了[lip](https://github.com/futrime/lip)。 +首先,你应当确保你安装了[lip](https://futrime.github.io/lip)。 你还应当按照[创建你的第一个模组](create_your_first_mod.md)中的步骤创建了一个模组,其中模组导出目录有类似如下的结构: diff --git a/docs/main/developer_guides/publish_your_first_pack.md b/docs/main/developer_guides/publish_your_first_pack.md index bc8658c842..43904a4e78 100644 --- a/docs/main/developer_guides/publish_your_first_pack.md +++ b/docs/main/developer_guides/publish_your_first_pack.md @@ -1,6 +1,6 @@ # Publishing your first pack -First, you should ensure that you have installed [lip](https://github.com/futrime/lip). +First, you should ensure that you have installed [lip](https://futrime.github.io/lip). ## Creating a Repository diff --git a/docs/main/developer_guides/publish_your_first_pack.zh.md b/docs/main/developer_guides/publish_your_first_pack.zh.md index 445444de63..a1440548bb 100644 --- a/docs/main/developer_guides/publish_your_first_pack.zh.md +++ b/docs/main/developer_guides/publish_your_first_pack.zh.md @@ -1,6 +1,6 @@ # 发布你的第一个整合包 -首先,你应当确保你安装了[lip](https://github.com/futrime/lip)。 +首先,你应当确保你安装了[lip](https://futrime.github.io/lip)。 ## 创建一个仓库 From 3b25e13773d129da100de163a33a556ab61415ef Mon Sep 17 00:00:00 2001 From: Lovelylavender4 Date: Sun, 5 Jan 2025 11:57:52 +0800 Subject: [PATCH 04/14] chore: remove redundancy from the readme --- README.md | 14 +------------- README.zh.md | 12 +----------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 9142dd7c36..8096a18436 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,7 @@ For more information, please refer to [the documentation](https://lamina.levimc. ## Security > [!WARNING] -> Before installing and using LeviLamina, please be sure to read and understand the following disclaimer. - -LeviLamina (hereinafter referred to as "this software") is developed and provided by Levimc (hereinafter referred to as "the developer"). This software is designed to enable users to extend the functionality of Minecraft Bedrock Edition (hereinafter referred to as "MCBE") by loading mods. This software is not affiliated with Mojang Studios (hereinafter referred to as "Mojang") or Microsoft Corporation (hereinafter referred to as "Microsoft"). The developer is not responsible for any content, quality, functionality, security or legality of any mods loaded by this software. Users should use this software at their own discretion and assume all related risks. - -The developer does not guarantee the stability, reliability, accuracy or completeness of this software. The developer is not liable for any defects, errors, viruses or other harmful components that may exist in this software. The developer is not liable for any direct or indirect damages (including but not limited to data loss, device damage, profit loss etc.) caused by the use of this software. - -The developer reserves the right to modify, update or terminate this software and its related services at any time without prior notice to users. Users should back up important data and check regularly for updates of this software. - -Users should comply with relevant laws and regulations when using this software, respect the intellectual property rights and privacy rights of others, and not use this software for any illegal or infringing activities. If users violate the above provisions and cause any damage to any third party or are claimed by any third party, the developer does not bear any responsibility. +> **As a developer, you should carefully read and adhere to our [EULA](EULA.en.md) and [usage guidelines](docs/main/common_guides/usage_guidelines.en.md).** If you have any questions or comments about this disclaimer, please contact the developer. @@ -63,10 +55,6 @@ This project exists thanks to all the people who contribute. ![Contributors](https://contrib.rocks/image?repo=LiteLDev/LeviLamina) -## End(er)-User License Agreement (EULA) - -**As a developer, you should carefully read and adhere to our [EULA](EULA.en.md) and [usage guidelines](docs/main/common_guides/usage_guidelines.en.md).** - ## License Copyright © 2024 LeviMC, All rights reserved. diff --git a/README.zh.md b/README.zh.md index 8ecff0ebf4..258b6950f1 100644 --- a/README.zh.md +++ b/README.zh.md @@ -23,13 +23,7 @@ LeviLamina是一个非官方的模组加载器,旨在为Minecraft Bedrock Edit ## 安全 > [!WARNING] -> 在安装和使用LeviLamina前,请务必阅读并理解以下免责声明。 - -LeviLamina(以下简称“本软件”)由Levimc(以下简称“开发者”)开发和提供。本软件的设计目的是使用户能够通过加载模组来扩展Minecraft Bedrock Edition(以下简称“MCBE”)的功能。本软件与Mojang Studios(以下简称“Mojang”)或Microsoft Corporation(以下简称“Microsoft”)没有任何关联。开发者对本软件加载的任何模组的内容、质量、功能、安全性或合法性不承担任何责任。用户应自行判断并承担所有相关风险。 - -开发者不保证本软件的稳定性、可靠性、准确性或完整性。开发者不对本软件中可能存在的任何缺陷、错误、病毒或其他有害组件负责。开发者不对用户使用本软件造成的任何直接或间接损害(包括但不限于数据丢失、设备损坏、利润损失等)负责。 - -开发者保留随时修改、更新或终止本软件及其相关服务的权利,无需事先通知用户。用户应备份重要数据并定期检查本软件的更新。用户在使用本软件时应遵守相关法律法规,尊重他人的知识产权和隐私权,不得将本软件用于任何非法或侵权活动。如果用户违反上述规定,给任何第三方造成任何损害或被任何第三方索赔,开发者不承担任何责任。如果您对本免责声明有任何疑问或意见,请联系开发者。 +> **作为一个开发者,你应该仔细阅读并遵守我们的[EULA](EULA.zh.md)与[使用准则](docs/main/common_guides/usage_guidelines.zh.md)。** ## 安装和使用 @@ -60,10 +54,6 @@ LeviLamina遵循[Code of Conduct](https://www.contributor-covenant.org/version/2 ![贡献者](https://contrib.rocks/image?repo=LiteLDev/LeviLamina) -## 最终用户许可协议 (EULA) - -**作为一个开发者,你应该仔细阅读并遵守我们的[EULA](EULA.zh.md)与[使用准则](docs/main/common_guides/usage_guidelines.zh.md)。** - ## 许可证 版权所有 © 2024 LeviMC, 保留所有权利. From 17195780c86e0753c37747905f8322124b626891 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 16:51:49 +0800 Subject: [PATCH 05/14] chore: remove some internal functions from api header --- src-client/ll/core/main_win.cpp | 7 +++++++ src-server/ll/core/main_win.cpp | 6 ++++++ src/ll/api/i18n/I18n.h | 2 -- src/ll/api/service/GamingStatus.h | 2 -- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src-client/ll/core/main_win.cpp b/src-client/ll/core/main_win.cpp index bb1451c9ac..0d9d42e5e0 100644 --- a/src-client/ll/core/main_win.cpp +++ b/src-client/ll/core/main_win.cpp @@ -24,6 +24,13 @@ #include "windows.h" namespace ll { + +void setGamingStatus(GamingStatus); + +namespace i18n { +std::string& defaultLocaleCode(); +} + void leviLaminaMain() { error_utils::initExceptionTranslator(); diff --git a/src-server/ll/core/main_win.cpp b/src-server/ll/core/main_win.cpp index 9d6637cbf6..7249eef442 100644 --- a/src-server/ll/core/main_win.cpp +++ b/src-server/ll/core/main_win.cpp @@ -153,6 +153,12 @@ void unixSignalHandler(int signum) { } } +void setGamingStatus(GamingStatus); + +namespace i18n { +std::string& defaultLocaleCode(); +} + void leviLaminaMain() { error_utils::initExceptionTranslator(); diff --git a/src/ll/api/i18n/I18n.h b/src/ll/api/i18n/I18n.h index 51d8329987..7f0ddbd730 100644 --- a/src/ll/api/i18n/I18n.h +++ b/src/ll/api/i18n/I18n.h @@ -18,8 +18,6 @@ namespace ll::i18n { -std::string& defaultLocaleCode(); - LLNDAPI std::string_view getDefaultLocaleCode(); class I18n { diff --git a/src/ll/api/service/GamingStatus.h b/src/ll/api/service/GamingStatus.h index d6fd36584d..78be544d53 100644 --- a/src/ll/api/service/GamingStatus.h +++ b/src/ll/api/service/GamingStatus.h @@ -13,6 +13,4 @@ enum class GamingStatus : int { LLNDAPI GamingStatus getGamingStatus(); -void setGamingStatus(GamingStatus); - } // namespace ll From 7039f757953ffa5ec1e7225ec562185d0c91e6f3 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 18:25:57 +0800 Subject: [PATCH 06/14] chore: add member functions for some template --- .../world/level/block/states/BlockStateVariant.h | 16 +++++++++------- .../block/states/BuiltInBlockStateVariant.h | 12 +++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/mc/world/level/block/states/BlockStateVariant.h b/src/mc/world/level/block/states/BlockStateVariant.h index c2555a3b3b..a9b68cf1a1 100644 --- a/src/mc/world/level/block/states/BlockStateVariant.h +++ b/src/mc/world/level/block/states/BlockStateVariant.h @@ -6,16 +6,18 @@ template class BlockStateVariant : public ::BlockState { public: - // prevent constructor by default - BlockStateVariant& operator=(BlockStateVariant const&); - BlockStateVariant(BlockStateVariant const&); - BlockStateVariant(); + using Type = T0; +public: + // virtual functions // NOLINTBEGIN - virtual ~BlockStateVariant(); + // vIndex: 0 + virtual ~BlockStateVariant() /*override*/ = default; - virtual void toNBT(class CompoundTag&, int) const; + // vIndex: 1 + virtual void toNBT(::CompoundTag&, int) const /*override*/; - virtual bool fromNBT(class CompoundTag const&, int&) const; + // vIndex: 2 + virtual bool fromNBT(::CompoundTag const&, int&) const /*override*/; // NOLINTEND }; diff --git a/src/mc/world/level/block/states/BuiltInBlockStateVariant.h b/src/mc/world/level/block/states/BuiltInBlockStateVariant.h index 207391ccd4..0accb29817 100644 --- a/src/mc/world/level/block/states/BuiltInBlockStateVariant.h +++ b/src/mc/world/level/block/states/BuiltInBlockStateVariant.h @@ -1,12 +1,14 @@ #pragma once #include "mc/_HeaderOutputPredefine.h" +#include "mc/world/level/block/states/BlockStateVariant.h" template -class BuiltInBlockStateVariant { +class BuiltInBlockStateVariant : public ::BlockStateVariant { public: - // prevent constructor by default - BuiltInBlockStateVariant& operator=(BuiltInBlockStateVariant const&); - BuiltInBlockStateVariant(BuiltInBlockStateVariant const&); - BuiltInBlockStateVariant(); + // virtual functions + // NOLINTBEGIN + // vIndex: 0 + virtual ~BuiltInBlockStateVariant() /*override*/ = default; + // NOLINTEND }; From ac1b00e2d55dd271513d750468453e9475c0109f Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 18:32:24 +0800 Subject: [PATCH 07/14] fix: fix Player::sendMessage broadcast --- src/mc/network/packet/Packet.cpp | 4 ++-- src/mc/network/packet/Packet.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mc/network/packet/Packet.cpp b/src/mc/network/packet/Packet.cpp index d2dfd6255f..5166e98fcd 100644 --- a/src/mc/network/packet/Packet.cpp +++ b/src/mc/network/packet/Packet.cpp @@ -4,11 +4,11 @@ #include "mc/network/NetworkIdentifierWithSubId.h" #include "mc/network/packet/Packet.h" #include "mc/server/ServerLevel.h" -#include "mc/server/ServerPlayer.h" #include "mc/world/Minecraft.h" +#include "mc/world/actor/player/Player.h" #include "mc/world/level/dimension/Dimension.h" -void Packet::sendTo(ServerPlayer const& player) const { +void Packet::sendTo(Player const& player) const { sendToClient(player.getNetworkIdentifier(), player.getClientSubId()); } diff --git a/src/mc/network/packet/Packet.h b/src/mc/network/packet/Packet.h index f3a2bd790d..612da42c40 100644 --- a/src/mc/network/packet/Packet.h +++ b/src/mc/network/packet/Packet.h @@ -20,7 +20,6 @@ class ReadOnlyBinaryStream; // clang-format on class Player; -class ServerPlayer; class Actor; class BlockPos; struct NetworkIdentifierWithSubId; @@ -43,7 +42,7 @@ class Packet { * * @param player The server player to send the packet to. */ - LLAPI void sendTo(ServerPlayer const& player) const; + LLAPI void sendTo(Player const& player) const; /** * Send the packet to all relevant players in a 2D plane at a position in a given dimension. From 811d71c013cbb601bd3fe4327c0990199ff8c6a4 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 18:41:40 +0800 Subject: [PATCH 08/14] chore: change some weird concept --- src/ll/api/reflection/Reflection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ll/api/reflection/Reflection.h b/src/ll/api/reflection/Reflection.h index dc9c87a22b..dbb4087105 100644 --- a/src/ll/api/reflection/Reflection.h +++ b/src/ll/api/reflection/Reflection.h @@ -21,7 +21,7 @@ namespace ll::reflection { template constexpr bool is_reflectable_v = - std::is_aggregate_v> && !requires { typename std::remove_cvref_t::size_type; }; + std::is_aggregate_v> && !traits::is_std_array_v>; template concept Reflectable = is_reflectable_v; From 4ec94bf8994a44deafa5a3bc962e61d6a8e47b14 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 19:19:41 +0800 Subject: [PATCH 09/14] chore: remove some explicit --- src/mc/util/MolangScriptArg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mc/util/MolangScriptArg.h b/src/mc/util/MolangScriptArg.h index 5643d02ebe..db7fe1ad22 100644 --- a/src/mc/util/MolangScriptArg.h +++ b/src/mc/util/MolangScriptArg.h @@ -60,17 +60,17 @@ struct MolangScriptArg { // NOLINTBEGIN MCAPI MolangScriptArg(); - MCAPI explicit MolangScriptArg(::MolangMatrix const&); + MCAPI MolangScriptArg(::MolangMatrix const&); MCAPI MolangScriptArg(::MolangScriptArg&&); MCAPI MolangScriptArg(::MolangScriptArg const&); - MCAPI explicit MolangScriptArg(float value); + MCAPI MolangScriptArg(float value); - MCAPI explicit MolangScriptArg(::MolangActorIdArrayPtr const&); + MCAPI MolangScriptArg(::MolangActorIdArrayPtr const&); - MCAPI explicit MolangScriptArg(::MolangMemberArray const&); + MCAPI MolangScriptArg(::MolangMemberArray const&); MCAPI ::MolangMemberArray* getAsNonConstMolangMemberArray(); From cdeb1ded658216a3ee96ca748f217864b4e6d16a Mon Sep 17 00:00:00 2001 From: Dofes <91889957+Dofes@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:59:23 +0800 Subject: [PATCH 10/14] feat: add block state setter and getter --- src/mc/world/level/block/Block.h | 21 +++++++ src/mc/world/level/block/BlockLegacy.h | 58 +++++++++++++++++++ .../level/block/states/BlockStateInstance.h | 21 +++---- 3 files changed, 90 insertions(+), 10 deletions(-) diff --git a/src/mc/world/level/block/Block.h b/src/mc/world/level/block/Block.h index c3d7f24e6f..07e6dae7e5 100644 --- a/src/mc/world/level/block/Block.h +++ b/src/mc/world/level/block/Block.h @@ -90,6 +90,27 @@ class Block { ::ll::TypedStorage<1, 1, bool> mHasRuntimeId; // NOLINTEND +public: + template + T getState(uint64 id) const { + return mLegacyBlock->get()->getState(id, mData); + } + + template + T getState(BlockState const& state) const { + return mLegacyBlock->get()->getState(state, mData); + } + + template + optional_ref setState(uint64 id, T value) const { + return mLegacyBlock->get()->trySetState(id, value, mData); + } + + template + optional_ref setState(BlockState const& state, T value) const { + return mLegacyBlock->get()->trySetState(state, value, mData); + } + public: // virtual functions // NOLINTBEGIN diff --git a/src/mc/world/level/block/BlockLegacy.h b/src/mc/world/level/block/BlockLegacy.h index ef1a1be457..ccbe97421f 100644 --- a/src/mc/world/level/block/BlockLegacy.h +++ b/src/mc/world/level/block/BlockLegacy.h @@ -1,6 +1,8 @@ #pragma once #include "mc/_HeaderOutputPredefine.h" +#include "mc/world/level/block/states/BlockState.h" +#include "mc/world/level/block/states/BlockStateInstance.h" // auto generated inclusion list #include "mc/common/WeakPtr.h" @@ -331,6 +333,62 @@ class BlockLegacy { LLNDAPI static optional_ref tryGetFromRegistry(std::string_view name); LLNDAPI static optional_ref tryGetFromRegistry(uint legacyBlockID); + template + T getState(uint64 id, ushort data) const { + auto it = mStates->lower_bound(id); + + if (it == mStates->end() || it->first != id) { + std::optional result = _tryLookupAlteredStateCollection(id, data); + if (result.has_value()) { + return static_cast(result.value()); + } else { + return T{}; + } + } + + return it->second.get(data); + } + + template + T getState(BlockState const& stateType, ushort data) const { + return getState(stateType.mID, data); + } + + template + Block const* trySetState(uint64 id, T val, ushort data) { + auto it = mStates->lower_bound(id); + + if (it != mStates->end() && it->first == id) { + auto& stateInstance = it->second; + + if (static_cast(val) < stateInstance.mVariationCount) { + ushort maskedData = (data & ~stateInstance.mMask) + | (static_cast(val) << (stateInstance.mEndBit - stateInstance.mNumBits + 1)); + + if (maskedData < mBlockPermutations->size()) { + return mBlockPermutations->at(maskedData).get(); + } + return nullptr; + } + } + + Block const* alteredStateBlock = _trySetStateFromAlteredStateCollection(id, static_cast(val), data); + if (alteredStateBlock) { + return alteredStateBlock; + } + + if (mReturnDefaultBlockOnUnidentifiedBlockState) { + return &getDefaultState(); + } + + return nullptr; + } + + template + Block const* trySetState(BlockState const& stateType, T val, ushort data) { + return trySetState(stateType.mID, val, data); + } + public: // member variables // NOLINTBEGIN diff --git a/src/mc/world/level/block/states/BlockStateInstance.h b/src/mc/world/level/block/states/BlockStateInstance.h index a4fc777f1d..af857943bb 100644 --- a/src/mc/world/level/block/states/BlockStateInstance.h +++ b/src/mc/world/level/block/states/BlockStateInstance.h @@ -11,19 +11,20 @@ class BlockStateInstance { public: // member variables // NOLINTBEGIN - ::ll::UntypedStorage<4, 4> mUnkeee94f; - ::ll::UntypedStorage<4, 4> mUnk58db0e; - ::ll::UntypedStorage<4, 4> mUnk3e3d8a; - ::ll::UntypedStorage<4, 4> mUnk787411; - ::ll::UntypedStorage<1, 1> mUnk163307; - ::ll::UntypedStorage<8, 8> mUnkd127d6; + ::ll::TypedStorage<4, 4, uint> mEndBit; + ::ll::TypedStorage<4, 4, uint> mNumBits; + ::ll::TypedStorage<4, 4, uint> mVariationCount; + ::ll::TypedStorage<4, 4, uint> mMask; + ::ll::TypedStorage<1, 1, bool> mInitialized; + ::ll::TypedStorage<8, 8, ::BlockState const*> mState; // NOLINTEND public: - // prevent constructor by default - BlockStateInstance& operator=(BlockStateInstance const&); - BlockStateInstance(BlockStateInstance const&); - BlockStateInstance(); + template + T get(ushort data) const { + if (sizeof(T) * 8 < mNumBits) return T{}; + return static_cast((data >> (mEndBit - mNumBits + 1)) & ((1 << mNumBits) - 1)); + } public: // member functions From 4b3125524c36fb93da1e8b3c881d2faab98c9a5d Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sun, 5 Jan 2025 20:16:45 +0800 Subject: [PATCH 11/14] fix: fix MolangScriptArg --- src/ll/api/base/Alias.h | 14 ++++++ src/mc/util/MolangLoopBreak.h | 4 -- src/mc/util/MolangLoopContinue.h | 4 -- src/mc/util/MolangScriptArg.h | 85 ++++++++++++++++++++------------ src/mc/util/MolangScriptArgPOD.h | 13 +++++ 5 files changed, 81 insertions(+), 39 deletions(-) diff --git a/src/ll/api/base/Alias.h b/src/ll/api/base/Alias.h index 19f539a8d8..a0fbbd833c 100644 --- a/src/ll/api/base/Alias.h +++ b/src/ll/api/base/Alias.h @@ -55,12 +55,26 @@ struct TypedStorageImpl { std::construct_at(this->operator->(), std::forward(args)...); } + TypedStorageImpl(TypedStorageImpl const& other) { std::construct_at(this->operator->(), other.get()); } + + TypedStorageImpl(TypedStorageImpl&& other) { std::construct_at(this->operator->(), std::move(other.get())); } + template constexpr T& operator=(U&& u) { get().operator=(std::forward(u)); return get(); } + T& operator=(TypedStorageImpl const& u) { + get().operator=(u.get()); + return get(); + } + + T& operator=(TypedStorageImpl&& u) { + get().operator=(std::move(u.get())); + return get(); + } + constexpr ~TypedStorageImpl() { std::destroy_at(this->operator->()); } [[nodiscard]] T* operator->() { return reinterpret_cast(data); } diff --git a/src/mc/util/MolangLoopBreak.h b/src/mc/util/MolangLoopBreak.h index 3567db8f27..4c43ed2e66 100644 --- a/src/mc/util/MolangLoopBreak.h +++ b/src/mc/util/MolangLoopBreak.h @@ -4,8 +4,4 @@ struct MolangLoopBreak { public: - // prevent constructor by default - MolangLoopBreak& operator=(MolangLoopBreak const&); - MolangLoopBreak(MolangLoopBreak const&); - MolangLoopBreak(); }; diff --git a/src/mc/util/MolangLoopContinue.h b/src/mc/util/MolangLoopContinue.h index 73191a71e1..50bfa24e66 100644 --- a/src/mc/util/MolangLoopContinue.h +++ b/src/mc/util/MolangLoopContinue.h @@ -4,8 +4,4 @@ struct MolangLoopContinue { public: - // prevent constructor by default - MolangLoopContinue& operator=(MolangLoopContinue const&); - MolangLoopContinue(MolangLoopContinue const&); - MolangLoopContinue(); }; diff --git a/src/mc/util/MolangScriptArg.h b/src/mc/util/MolangScriptArg.h index db7fe1ad22..8a12647468 100644 --- a/src/mc/util/MolangScriptArg.h +++ b/src/mc/util/MolangScriptArg.h @@ -1,6 +1,24 @@ #pragma once +#include "ll/api/base/Concepts.h" #include "mc/_HeaderOutputPredefine.h" +#include "mc/deps/minecraft_renderer/renderer/MaterialVariants.h" +#include "mc/util/MolangActorArrayPtr.h" +#include "mc/util/MolangActorIdArrayPtr.h" +#include "mc/util/MolangArrayVariable.h" +#include "mc/util/MolangClientTextureSet.h" +#include "mc/util/MolangContextVariable.h" +#include "mc/util/MolangDataDrivenGeometry.h" +#include "mc/util/MolangEntityVariable.h" +#include "mc/util/MolangGeometryVariable.h" +#include "mc/util/MolangMaterialVariable.h" +#include "mc/util/MolangMatrix.h" +#include "mc/util/MolangMemberAccessor.h" +#include "mc/util/MolangMemberArray.h" +#include "mc/util/MolangQueryFunctionPtr.h" +#include "mc/util/MolangScriptArgPOD.h" +#include "mc/util/MolangTempVariable.h" +#include "mc/util/MolangTextureVariable.h" // auto generated inclusion list #include "mc/util/MolangScriptArgType.h" @@ -27,32 +45,45 @@ union MolangScriptArgPOD; // clang-format on struct MolangScriptArg { +public: + using MolangScriptArgData = std::variant< + ::MolangMatrix, + ::MaterialVariants, + ::MolangActorArrayPtr, + ::MolangActorIdArrayPtr, + ::MolangArrayVariable, + ::MolangClientTextureSet, + ::MolangContextVariable, + ::MolangDataDrivenGeometry, + ::MolangEntityVariable, + ::MolangGeometryVariable, + ::MolangMaterialVariable, + ::MolangMemberAccessor, + ::MolangMemberArray, + ::MolangQueryFunctionPtr, + ::MolangTempVariable, + ::MolangTextureVariable>; + + MolangScriptArg(MolangLoopBreak loopBreak) : mType(MolangScriptArgType::MolangLoopBreak), mPOD(loopBreak) {} + MolangScriptArg(MolangLoopContinue loopContinue) + : mType(MolangScriptArgType::MolangLoopContinue), + mPOD(loopContinue) {} + MolangScriptArg(Actor const& actor) : mType(MolangScriptArgType::MolangActorPtr), mPOD(std::addressof(actor)) {} + MolangScriptArg(ActorUniqueID actorId) : mType(MolangScriptArgType::MolangActorIdPtr), mPOD(actorId) {} + MolangScriptArg(ItemStackBase const& item) + : mType(MolangScriptArgType::MolangItemStackBasePtr), + mPOD(std::addressof(item)) {} + + template T> + MolangScriptArg(T const& val) : mType(MolangScriptArgType::Variant), + mData(val) {} + public: // member variables // NOLINTBEGIN - ::ll::TypedStorage<4, 4, ::MolangScriptArgType> mType; - ::ll::TypedStorage<8, 8, ::MolangScriptArgPOD> mPOD; - ::ll::TypedStorage< - 8, - 72, - ::std::variant< - ::MolangMatrix, - ::MaterialVariants, - ::MolangActorArrayPtr, - ::MolangActorIdArrayPtr, - ::MolangArrayVariable, - ::MolangClientTextureSet, - ::MolangContextVariable, - ::MolangDataDrivenGeometry, - ::MolangEntityVariable, - ::MolangGeometryVariable, - ::MolangMaterialVariable, - ::MolangMemberAccessor, - ::MolangMemberArray, - ::MolangQueryFunctionPtr, - ::MolangTempVariable, - ::MolangTextureVariable>> - mData; + ::MolangScriptArgType mType; + ::MolangScriptArgPOD mPOD; + MolangScriptArgData mData; // NOLINTEND public: @@ -60,26 +91,18 @@ struct MolangScriptArg { // NOLINTBEGIN MCAPI MolangScriptArg(); - MCAPI MolangScriptArg(::MolangMatrix const&); - MCAPI MolangScriptArg(::MolangScriptArg&&); MCAPI MolangScriptArg(::MolangScriptArg const&); MCAPI MolangScriptArg(float value); - MCAPI MolangScriptArg(::MolangActorIdArrayPtr const&); - - MCAPI MolangScriptArg(::MolangMemberArray const&); - MCAPI ::MolangMemberArray* getAsNonConstMolangMemberArray(); MCAPI ::MolangScriptArgType getBaseType() const; MCAPI bool isEqual(::MolangScriptArg const& rhs) const; - MCAPI ::MolangScriptArg& operator=(::MolangMemberArray const&); - MCAPI ::MolangScriptArg& operator=(::MolangScriptArg const&); MCAPI ::MolangScriptArg& operator=(::MolangScriptArg&&); diff --git a/src/mc/util/MolangScriptArgPOD.h b/src/mc/util/MolangScriptArgPOD.h index a55e937eea..36972f5f3b 100644 --- a/src/mc/util/MolangScriptArgPOD.h +++ b/src/mc/util/MolangScriptArgPOD.h @@ -1,6 +1,9 @@ #pragma once #include "mc/_HeaderOutputPredefine.h" +#include "mc/common/ActorUniqueID.h" +#include "mc/util/MolangLoopBreak.h" +#include "mc/util/MolangLoopContinue.h" // auto generated forward declare list // clang-format off @@ -13,6 +16,16 @@ struct MolangLoopContinue; union MolangScriptArgPOD { public: constexpr ~MolangScriptArgPOD() {} + constexpr MolangScriptArgPOD() : _mData(0) {}; + constexpr MolangScriptArgPOD(float val) : mFloat(val) {}; + constexpr MolangScriptArgPOD(uint64 val) : mHashType64(val) {}; + constexpr MolangScriptArgPOD(MolangLoopBreak val) : mLoopBreak(val) {}; + constexpr MolangScriptArgPOD(MolangLoopContinue val) : mLoopContinue(val) {}; + constexpr MolangScriptArgPOD(Actor const* val) : mActorPtr(const_cast(val)) {}; + constexpr MolangScriptArgPOD(ActorUniqueID val) : mActorId(val.rawID) {}; + constexpr MolangScriptArgPOD(ItemStackBase const* val) : mItemStackBasePtr(const_cast(val)) {}; + constexpr bool operator==(MolangScriptArgPOD const& rhs) const { return _mData == rhs._mData; } + void clear() { _mData = 0; } public: // member variables From 317b1ea1bcef8e7d7cef33a773108e7906420bb4 Mon Sep 17 00:00:00 2001 From: Dofes <91889957+Dofes@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:00:25 +0800 Subject: [PATCH 12/14] fix(doc): fix eula format --- EULA.en.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/EULA.en.md b/EULA.en.md index 0cba6e9fec..74d1c0926c 100644 --- a/EULA.en.md +++ b/EULA.en.md @@ -92,9 +92,7 @@ If you provide a suggestion for *LeviLamina*, it is offered freely, and we are * If you wish to notify us about intellectual property infringement in our services, please submit a notification here. We reserve the right to remove any content at our discretion. -If you violate this E - -ULA, the consequences are **entirely your responsibility**, whether as an individual, organization, or company. Levimc **does not bear any legal responsibility** and **is not liable** for these consequences. Please read and follow this EULA carefully to avoid unnecessary issues. +If you violate this EULA, the consequences are **entirely your responsibility**, whether as an individual, organization, or company. Levimc **does not bear any legal responsibility** and **is not liable** for these consequences. Please read and follow this EULA carefully to avoid unnecessary issues. ## Contact Information @@ -108,4 +106,4 @@ Our Official Email: contact@levimc.org - 2025.01.04 Completed the first official version @Lovelylavender4 - 2024.12.11 Corrected the name of the first draft file @Lovelylavender4 -- 2024.11.03 Completed the first draft @Lovelylavender4 \ No newline at end of file +- 2024.11.03 Completed the first draft @Lovelylavender4 From 6c88e84051b3c225808de7bedddc1d23b0ca602c Mon Sep 17 00:00:00 2001 From: ShrBox Date: Mon, 6 Jan 2025 17:22:21 +0800 Subject: [PATCH 13/14] chore: update CHANGELOG.md --- CHANGELOG.md | 23 +++++++++++++++++++++-- README.md | 8 ++++---- README.zh.md | 8 ++++---- tooth.json | 4 ++-- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da34e1d8cb..50d57dfce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.0-rc.2] - 2025-01-06 + +### Added + +- Add block state setter and getter @Dofes + +### Changed + +- Remove some internal functions from api header @OEOTYAN +- Add member functions for some template @OEOTYAN +- Change some weird concept @OEOTYAN +- Remove some explicit @OEOTYAN + +### Fixed + +- Fix Player::sendMessage broadcast @OEOTYAN +- Fix MolangScriptArg @OEOTYAN + ## [1.0.0-rc.1] - 2025-01-04 ### Added -- **Adapted to BDS version *1.21.50*** @OEOTYAN @ddf8196 @Dofes @dreamguxiang @futrime @KawaiiNahida @Lovelylavender4 @PA733 @Pd233 @RimuruChan @ShrBox @wu-vincent +- **Adapted to BDS version *1.21.50*** @OEOTYAN @ddf8196 @Dofes @dreamguxiang @futrime @KawaiiNahida @Lovelylavender4 @PA733 @Pd233 @RimuruChan @ShrBox @wu-vincent - Added the missing field to CommandRegistry::Overload @wu-vincent - Added StdoutRedirector @OEOTYAN - Added imgui and some relate codes @ddf8196 @OEOTYAN @@ -716,7 +734,8 @@ For lip and tooth-hub test only. [#1574]: https://github.com/LiteLDev/LeviLamina/issues/1574 [#1582]: https://github.com/LiteLDev/LeviLamina/issues/1582 -[Unreleased]: https://github.com/LiteLDev/LeviLamina/compare/v1.0.0-rc.1...HEAD +[Unreleased]: https://github.com/LiteLDev/LeviLamina/compare/v1.0.0-rc.2...HEAD +[1.0.0-rc.2]: https://github.com/LiteLDev/LeviLamina/compare/v1.0.0-rc.1...v1.0.0-rc.2 [1.0.0-rc.1]: https://github.com/LiteLDev/LeviLamina/compare/v0.13.5...v1.0.0-rc.1 [0.13.5]: https://github.com/LiteLDev/LeviLamina/compare/v0.13.4...v0.13.5 [0.13.4]: https://github.com/LiteLDev/LeviLamina/compare/v0.13.3...v0.13.4 diff --git a/README.md b/README.md index 8096a18436..62816adf59 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ [![Discord](https://img.shields.io/discord/849252980430864384?style=for-the-badge&logo=discord)](https://discord.gg/v5R5P4vRZk) [![Telegram](https://img.shields.io/badge/Telegram-blue?style=for-the-badge&logo=telegram)](https://t.me/LiteLoader) -[![656669024](https://img.shields.io/badge/656669024-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ndxRXO1HARA8ing7OunMClOz3cQTogL0&authKey=D7QTcqnzhBzuh3zc%2F70FjgklsVvkCImTjSRqHMwYGCLwIFpxzp%2FflC97Y7AUG%2Fpy&noverify=0&group_code=656669024) -[![937236109](https://img.shields.io/badge/937236109-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=1u0nmmUIZOB716neFTlbyj_2aOQn_TV-&authKey=1lBqM20oOfdKjDnxkq09DjR729fqFfWVnaLQ7VjrDB%2FAg6qwvw6QCwdwYoRUrewU&noverify=0&group_code=937236109) -[![850517473](https://img.shields.io/badge/850517473-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=3Fxt0gwMYkoLPani_vQ9tsNfYrnVy4hK&authKey=2A%2BNk3jmRaK%2FO1FBQSjTIbStAU1kbZWkjEkyh2RTVA015eTg6c4CvVhfByc1BtGZ&noverify=0&group_code=850517473) -[![1evilamina](https://img.shields.io/badge/1evilamina-red?style=for-the-badge&logo=tencent%20qq)](https://pd.qq.com/s/a13gu04rv) +[![656669024](https://img.shields.io/badge/656669024-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ndxRXO1HARA8ing7OunMClOz3cQTogL0&authKey=D7QTcqnzhBzuh3zc%2F70FjgklsVvkCImTjSRqHMwYGCLwIFpxzp%2FflC97Y7AUG%2Fpy&noverify=0&group_code=656669024) +[![937236109](https://img.shields.io/badge/937236109-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=1u0nmmUIZOB716neFTlbyj_2aOQn_TV-&authKey=1lBqM20oOfdKjDnxkq09DjR729fqFfWVnaLQ7VjrDB%2FAg6qwvw6QCwdwYoRUrewU&noverify=0&group_code=937236109) +[![850517473](https://img.shields.io/badge/850517473-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=3Fxt0gwMYkoLPani_vQ9tsNfYrnVy4hK&authKey=2A%2BNk3jmRaK%2FO1FBQSjTIbStAU1kbZWkjEkyh2RTVA015eTg6c4CvVhfByc1BtGZ&noverify=0&group_code=850517473) +[![1evilamina](https://img.shields.io/badge/1evilamina-red?style=for-the-badge&logo=qq)](https://pd.qq.com/s/a13gu04rv) ![English](https://img.shields.io/badge/English-inactive?style=for-the-badge) [![中文](https://img.shields.io/badge/简体中文-informational?style=for-the-badge)](README.zh.md) diff --git a/README.zh.md b/README.zh.md index 258b6950f1..28de138b8b 100644 --- a/README.zh.md +++ b/README.zh.md @@ -4,10 +4,10 @@ [![Discord](https://img.shields.io/discord/849252980430864384?style=for-the-badge&logo=discord)](https://discord.gg/v5R5P4vRZk) [![Telegram](https://img.shields.io/badge/Telegram-blue?style=for-the-badge&logo=telegram)](https://t.me/LiteLoader) -[![656669024](https://img.shields.io/badge/656669024-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ndxRXO1HARA8ing7OunMClOz3cQTogL0&authKey=D7QTcqnzhBzuh3zc%2F70FjgklsVvkCImTjSRqHMwYGCLwIFpxzp%2FflC97Y7AUG%2Fpy&noverify=0&group_code=656669024) -[![937236109](https://img.shields.io/badge/937236109-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=1u0nmmUIZOB716neFTlbyj_2aOQn_TV-&authKey=1lBqM20oOfdKjDnxkq09DjR729fqFfWVnaLQ7VjrDB%2FAg6qwvw6QCwdwYoRUrewU&noverify=0&group_code=937236109) -[![850517473](https://img.shields.io/badge/850517473-red?style=for-the-badge&logo=tencent%20qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=3Fxt0gwMYkoLPani_vQ9tsNfYrnVy4hK&authKey=2A%2BNk3jmRaK%2FO1FBQSjTIbStAU1kbZWkjEkyh2RTVA015eTg6c4CvVhfByc1BtGZ&noverify=0&group_code=850517473) -[![1evilamina](https://img.shields.io/badge/1evilamina-red?style=for-the-badge&logo=tencent%20qq)](https://pd.qq.com/s/a13gu04rv) +[![656669024](https://img.shields.io/badge/656669024-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ndxRXO1HARA8ing7OunMClOz3cQTogL0&authKey=D7QTcqnzhBzuh3zc%2F70FjgklsVvkCImTjSRqHMwYGCLwIFpxzp%2FflC97Y7AUG%2Fpy&noverify=0&group_code=656669024) +[![937236109](https://img.shields.io/badge/937236109-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=1u0nmmUIZOB716neFTlbyj_2aOQn_TV-&authKey=1lBqM20oOfdKjDnxkq09DjR729fqFfWVnaLQ7VjrDB%2FAg6qwvw6QCwdwYoRUrewU&noverify=0&group_code=937236109) +[![850517473](https://img.shields.io/badge/850517473-red?style=for-the-badge&logo=qq)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=3Fxt0gwMYkoLPani_vQ9tsNfYrnVy4hK&authKey=2A%2BNk3jmRaK%2FO1FBQSjTIbStAU1kbZWkjEkyh2RTVA015eTg6c4CvVhfByc1BtGZ&noverify=0&group_code=850517473) +[![1evilamina](https://img.shields.io/badge/1evilamina-red?style=for-the-badge&logo=qq)](https://pd.qq.com/s/a13gu04rv) [![English](https://img.shields.io/badge/English-informational?style=for-the-badge)](README.md) ![中文](https://img.shields.io/badge/简体中文-inactive?style=for-the-badge) diff --git a/tooth.json b/tooth.json index 7e9d7d1e21..ca81db612e 100644 --- a/tooth.json +++ b/tooth.json @@ -1,14 +1,14 @@ { "format_version": 2, "tooth": "github.com/LiteLDev/LeviLamina", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "info": { "name": "LeviLamina", "description": "A lightweight, modular and versatile mod loader for Minecraft Bedrock Edition.", "author": "levimc", "tags": [] }, - "asset_url": "https://github.com/LiteLDev/LeviLamina/releases/download/v1.0.0-rc.1/levilamina-release-windows-x64.zip", + "asset_url": "https://github.com/LiteLDev/LeviLamina/releases/download/v1.0.0-rc.2/levilamina-release-windows-x64.zip", "dependencies": { "github.com/LiteLDev/bds": "1.21.50", "github.com/LiteLDev/CrashLogger": "1.1.x", From 3210714679da6b3958fa2f3b7f9428552afbb8aa Mon Sep 17 00:00:00 2001 From: Dofes <91889957+Dofes@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:51:29 +0800 Subject: [PATCH 14/14] refactor: refactor block state getter and setter --- src/mc/world/level/block/Block.h | 4 ++-- src/mc/world/level/block/BlockLegacy.h | 14 +++++++------- .../world/level/block/states/BlockStateInstance.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mc/world/level/block/Block.h b/src/mc/world/level/block/Block.h index 07e6dae7e5..c5b8603c9f 100644 --- a/src/mc/world/level/block/Block.h +++ b/src/mc/world/level/block/Block.h @@ -92,12 +92,12 @@ class Block { public: template - T getState(uint64 id) const { + std::optional getState(uint64 id) const { return mLegacyBlock->get()->getState(id, mData); } template - T getState(BlockState const& state) const { + std::optional getState(BlockState const& state) const { return mLegacyBlock->get()->getState(state, mData); } diff --git a/src/mc/world/level/block/BlockLegacy.h b/src/mc/world/level/block/BlockLegacy.h index ccbe97421f..99c5e15c7c 100644 --- a/src/mc/world/level/block/BlockLegacy.h +++ b/src/mc/world/level/block/BlockLegacy.h @@ -334,7 +334,7 @@ class BlockLegacy { LLNDAPI static optional_ref tryGetFromRegistry(uint legacyBlockID); template - T getState(uint64 id, ushort data) const { + std::optional getState(uint64 id, ushort data) const { auto it = mStates->lower_bound(id); if (it == mStates->end() || it->first != id) { @@ -342,7 +342,7 @@ class BlockLegacy { if (result.has_value()) { return static_cast(result.value()); } else { - return T{}; + return std::nullopt; } } @@ -350,12 +350,13 @@ class BlockLegacy { } template - T getState(BlockState const& stateType, ushort data) const { + std::optional getState(BlockState const& stateType, ushort data) const { return getState(stateType.mID, data); } template - Block const* trySetState(uint64 id, T val, ushort data) { + requires(std::is_integral_v || std::is_enum_v) + optional_ref trySetState(uint64 id, T val, ushort data) { auto it = mStates->lower_bound(id); if (it != mStates->end() && it->first == id) { @@ -372,8 +373,7 @@ class BlockLegacy { } } - Block const* alteredStateBlock = _trySetStateFromAlteredStateCollection(id, static_cast(val), data); - if (alteredStateBlock) { + if (auto alteredStateBlock = _trySetStateFromAlteredStateCollection(id, static_cast(val), data)) { return alteredStateBlock; } @@ -385,7 +385,7 @@ class BlockLegacy { } template - Block const* trySetState(BlockState const& stateType, T val, ushort data) { + optional_ref trySetState(BlockState const& stateType, T val, ushort data) { return trySetState(stateType.mID, val, data); } diff --git a/src/mc/world/level/block/states/BlockStateInstance.h b/src/mc/world/level/block/states/BlockStateInstance.h index af857943bb..1e44008d4e 100644 --- a/src/mc/world/level/block/states/BlockStateInstance.h +++ b/src/mc/world/level/block/states/BlockStateInstance.h @@ -21,8 +21,8 @@ class BlockStateInstance { public: template + requires(std::is_integral_v || std::is_enum_v) T get(ushort data) const { - if (sizeof(T) * 8 < mNumBits) return T{}; return static_cast((data >> (mEndBit - mNumBits + 1)) & ((1 << mNumBits) - 1)); }