Open
Conversation
burningtnt
reviewed
Feb 4, 2026
gradle/libs.versions.toml
Outdated
| java-info = { module = "org.glavo:java-info", version.ref = "java-info" } | ||
| authlib-injector = { module = "org.glavo.hmcl:authlib-injector", version.ref = "authlib-injector" } | ||
| monet-fx = { module = "org.glavo:MonetFX", version.ref = "monet-fx" } | ||
| micanbt = {module = "tech.minediamond:micanbt", version.ref = "micanbt"} |
Contributor
Author
There was a problem hiding this comment.
之所以要换NBT库是因为这个 #5095,这个PR我也尝试重构一下。
同时这个库加了一个叫NBTPath的东西,这样获取深入嵌套的数据就不需要写非常长的get和instanceof了,这能减少维护成本,这也是打算在这个PR就换库的原因,比如:
之前:
public boolean isLargeBiomes() {
CompoundTag data = levelData.get("Data");
if (data.get("generatorName") instanceof StringTag generatorNameTag) { //Valid before 1.16
return "largeBiomes".equals(generatorNameTag.getValue());
} else {
if (data.get("WorldGenSettings") instanceof CompoundTag worldGenSettingsTag
&& worldGenSettingsTag.get("dimensions") instanceof CompoundTag dimensionsTag
&& dimensionsTag.get("minecraft:overworld") instanceof CompoundTag overworldTag
&& overworldTag.get("generator") instanceof CompoundTag generatorTag) {
if (generatorTag.get("biome_source") instanceof CompoundTag biomeSourceTag
&& biomeSourceTag.get("large_biomes") instanceof ByteTag largeBiomesTag) { //Valid between 1.16 and 1.16.2
return largeBiomesTag.getValue() == (byte) 1;
} else if (generatorTag.get("settings") instanceof StringTag settingsTag) { //Valid after 1.16.2
return "minecraft:large_biomes".equals(settingsTag.getValue());
}
}
return false;
}
}现在:(不含最新版本的逻辑)
public boolean isLargeBiomes() {
if (levelData.at("Data/generatorName") instanceof StringTag generatorNameTag) { //Valid before 1.16
return "largeBiomes".equals(generatorNameTag.getClonedValue());
} else {
if (levelData.at("Data/WorldGenSettings/dimensions/minecraft:overworld/generator") instanceof CompoundTag generatorTag) {
if (generatorTag.at("biome_source/large_biomes") instanceof ByteTag largeBiomesTag) { //Valid between 1.16 and 1.16.2
return largeBiomesTag.getClonedValue() == (byte) 1;
} else if (generatorTag.get("settings") instanceof StringTag settingsTag) { //Valid after 1.16.2
return "minecraft:large_biomes".equals(settingsTag.getClonedValue());
}
}
return false;
}
}最后,opennbt已经归档了,换一个能更积极维护的库也是好的。新库是我写的,我在尝试添加更多更好的功能。
Contributor
There was a problem hiding this comment.
Pull request overview
为 HMCL 增加对 Minecraft 26.1-snapshot-6 引入的全新/破坏性存档基础数据格式的读取与编辑支持,以修复新版本世界信息(如种子、难度、结构生成等)无法正确解析的问题(close #5436)。
Changes:
- 引入 MicaNBT 依赖,并在核心世界数据读取/写入中切换到新的 NBT 读写实现。
World支持读取world_gen_settings.dat以及在新格式下从独立玩家数据文件读取玩家信息。- UI 世界信息页/管理页适配新字段路径(种子、结构生成、难度/锁定/硬核等)。
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | 新增 MicaNBT 版本与库坐标 |
| HMCLCore/build.gradle.kts | HMCLCore 引入 micanbt 依赖 |
| HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java | 使用 MicaNBT 读取/写入世界数据,并支持新格式拆分的数据文件 |
| HMCL/src/main/resources/assets/about/deps.json | 关于页依赖列表新增 MicaNBT 信息 |
| HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldManagePage.java | 刷新入口从 reloadLevelDat() 调整为 reloadWorldData() |
| HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java | 世界信息 UI 适配新格式字段与保存逻辑 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/WorldInfoPage.java
Outdated
Show resolved
Hide resolved
Member
|
OpenNBT 长时间无人维护,我也在考虑自行维护 NBT 库。 我希望要么把 NBT 支持库合并到 HMCL 源码中维护,要么将仓库托管在 |
Contributor
Author
|
可以,我个人非常乐意将 MicaNBT 交给 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在26.1-snapshot-6中,mojang对整个存档格式和存档基础数据存储格式进行了非常深的破坏性变更,这导致HMCL几乎无法正确读取新版本的世界数据,本PR将添加对新版本的新格式支持
close #5436