
Easy Data Fix
一个允许模组开发者注册自定义数据修复器的库。
项目简介
Easy Data Fix 是一个小型库模组,旨在辅助模组开发数据修复器,使自定义模组游戏数据能够安全地在不同游戏版本之间进行转换。该模组封装了内置的 DataFixerUpper 类,正如 Mojang 所述,这是一套“用于增量构建、合并和优化数据转换的工具集”。
使用方法
- 从此 README 顶部提供的任意位置下载
easy_data_fix-<loader>-x.x.x+mc26.1。
- 将下载的 jar 文件复制到你的
mods 文件夹中。
在开发中使用本库
要为你的模组设置数据修复器,首先需要在 build.gradle 文件中将其作为依赖项添加,然后通过 Easy Data Fix 的 API 在预启动阶段注册它们。参见下方示例。
build.gradle
repositories {
mavenCentral()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
...
// 将 <Version> 替换为 Modrinth 版本页面上的版本号字符串
implementation "com.modrinth:easy-data-fix:<Version>"
}
ExampleFix.java
public class ExampleFix implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
DataFixerRegistry.addDataFix("数据修复器描述", builder -> {
// dataVersion = 你正在升级到的版本所使用的 Minecraft 数据版本。
// SchemaVersion = 与数据版本对应的内置模式类。
// 示例:(4773, V4771::new) = 26.1 完整发布版
Schema schema = builder.addSchema(dataVersion, V[SchemaVersion]::new);
builder.addFixer(BlockRenameFix.create(schema, "修复器名称", DataFixerAPI.createRenamer("example_mod:mod_block", "example_mod:new_mod_block")));
builder.addFixer(ItemRenameFix.create(schema, "修复器名称", DataFixerAPI.createRenamer("example_mod:mod_item", "example_mod:new_mod_item")));
});
// 你也可以在此处拥有多个 DataFixerRegistry,以便更好地组织数据修复或支持其他版本。
}
}
开始开发
要获取本地副本并运行,请遵循以下简单步骤。
前置要求
确保你的机器上安装了以下内容:
- Java Development Kit (JDK):版本 25 或更高。
- Gradle:版本 9.2 或更高。
- Minecraft:版本 26.1
构建
- 克隆仓库
git clone https://codeberg.org/VoxelBill/easy-data-fix.git
- 进入项目目录
cd easy-data-fix
- 使用 Gradle 构建项目
./gradlew clean build
你可以在 easy-data-fix/<loader>/build/libs/easy_data_fix-<loader>-x.x.x+mc26.1.jar 找到构建好的模组。

Easy Data Fix
A library that enables modders to register custom data fixers.
About The Project
Easy Data Fix is a small library mod that aids in creation of data fixers for mods, allowing custom mod game data to be converted between different versions of the game safly. The mod wraps the builtin DataFixerUpper classes which are as Mojang says "a set of utilities designed for incremental building, merging, and optimization of data transformations"
Use
- Download
easy_data_fix-<loader>-x.x.x+mc26.1 from on of the places at the top of this README.
- Copy the downloaded jar file to your
mods folder.
Using The Library In Development
To setup data fixers for your mod you first need to add the library as a dependency in your build.gradle file, then you just need to register them on pre-launch using Easy Data Fix's API. See example below.
build.gradle
repositories {
mavenCentral()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
...
// Replace <Version> with the version number string from the Modrinth version page
implementation "com.modrinth:easy-data-fix:<Version>"
}
ExampleFix.java
public class ExampleFix implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
DataFixerRegistry.addDataFix("Description of data fixer", builder -> {
// dataVersion = The Minecraft data version used in the version your upgrading to.
// SchemaVersion = The builtin schema class that goes with the data version.
// Example: (4773, V4771::new) = 26.1 full release
Schema schema = builder.addSchema(dataVersion, V[SchemaVersion]::new);
builder.addFixer(BlockRenameFix.create(schema, "Fixer Name", DataFixerAPI.createRenamer("example_mod:mod_block", "example_mod:new_mod_block")));
builder.addFixer(ItemRenameFix.create(schema, "Fixer Name", DataFixerAPI.createRenamer("example_mod:mod_item", "example_mod:new_mod_item")));
});
// You may also have multiple DataFixerRegistry here to better organize your data fixes or to support other versions.
}
}
Getting Started With Development
To get a local copy up and running, follow these simple steps.
Prerequisites
Ensure you have the following installed on your machine:
- Java Development Kit (JDK): Version 25 or higher.
- Gradle: Version 9.2 or higher.
- Minecraft: Version 26.1
Build
- Clone the repository
git clone https://codeberg.org/VoxelBill/easy-data-fix.git
- Navigate to the project directory
cd easy-data-fix
- Build the project with Gradle
./gradlew clean build
You can find the built mod at easy-data-fix/<loader>/build/libs/easy_data_fix-<loader>-x.x.x+mc26.1.jar.
评论 0
登录后参与评分
还没有评论,来抢沙发吧