LinearReader


LinearReader 是一款服务端 Minecraft 模组,它能在不影响游戏体验的前提下减小你的世界文件体积。这主要通过使用 Xymb 的 线性区域文件格式 替代 Minecraft 原有的 Anvil 文件格式,并利用 Zstd 压缩算法取代原版使用的 Zlib 压缩算法来实现。
如何减小世界体积?
Xymb 的 线性区域文件格式 相比原版 Minecraft 的区域文件格式已经有了巨大的提升,能够显著减小世界体积。
另一个必要的改进在于压缩算法及其压缩级别。更高程度的压缩需要更多的资源和时间,这对于活跃的服务端来说并不理想;而较低的压缩级别显然无法节省那么多存储空间。因此,挑战在于:LinearReader 如何既能提供低级别压缩的速度,又能实现高级别压缩带来的存储节省?
LinearReader 通过将工作负载分为两个独立的阶段来解决这个问题。实时的写入操作会使用较低级别的 Zstd 压缩进行快速压缩,从而为运行 Minecraft 留出充足的 CPU 资源。随后,当服务器处于空闲状态时,LinearReader 会以更深的压缩程度安全地重新压缩这些区域文件。
压缩基准测试
为了展示 LinearReader 在存储方面的增益,并解释为何不在实时写入时使用高级别压缩,我对使用 Java 默认压缩级别(即 Vanilla Minecraft 所使用的)的 Zlib 压缩 Anvil 文件格式、通常用于实时写入的 Zstd 4 级压缩(LinearReader 默认设置),以及用于重新压缩的 Zstd 22 级压缩进行了基准测试。有关基准测试的更深入分析,请参阅 benchmarks/ 目录。
| 数据集 |
格式 |
原始大小 |
压缩后大小 |
压缩率 |
压缩速度 |
解压速度 |
| 主世界 (Overworld) |
Anvil/Zlib 6 |
9.51 GB |
8.38 GB |
5.44x |
75.7 MB/s |
1271.3 MB/s |
| 主世界 (Overworld) |
LinearReader (Zstd 4) |
9.51 GB |
6.21 GB |
7.39x |
585.5 MB/s |
1412.8 MB/s |
| 主世界 (Overworld) |
LinearReader (Zstd 22) |
9.51 GB |
4.28 GB |
10.71x |
4.4 MB/s |
1589.2 MB/s |
| 末地 (End, 大部分虚空) |
Anvil/Zlib 6 |
2.33 GB |
2.16 GB |
3.66x |
188.4 MB/s |
1576.4 MB/s |
| 末地 (End, 大部分虚空) |
LinearReader (Zstd 4) |
2.33 GB |
244 MB |
33.20x |
1811.1 MB/s |
4062.7 MB/s |
| 末地 (End, 大部分虚空) |
LinearReader (Zstd 22) |
2.33 Gb |
141 MB |
57.50x |
10.1 MB/s |
6166.9 MB/s |
| Tectonic + Terralith |
Anvil/Zlib 6 |
2.89 GB |
2.56 GB |
5.97x |
84.1 MB/s |
1338.1 MB/s |
| Tectonic + Terralith |
LinearReader (Zstd 4) |
2.89 GB |
1.80 GB |
8.49x |
735.8 MB/s |
1742.8 MB/s |
| Tectonic + Terralith |
LinearReader (Zstd 22) |
2.89 GB |
1.24 GB |
12.37x |
4.4 MB/s |
1787.3 MB/s |
如上表所示,LinearReader + Zstd 能够在保持正常游戏过程中快速压缩和解压速度的同时,实现更好的压缩效果(Zstd 22 仅用于重新压缩器,不会在正常游戏过程中激活)。
其他功能
LinearReader 不仅仅替换了 Minecraft 的文件格式和压缩算法,它还包含许多其他功能,例如:
- 备份系统:LinearReader 可以自动创建区域文件的备份,以备不时之需。
- 缓存系统:可配置数量的最近使用的区域文件将保留在内存中作为缓存,从而减少磁盘读取和解压操作。
- 区块清理系统:LinearReader 可以搜索并安全删除那些空白的、无用的区块。系统设有严格的规则,以确保只清理真正无用的区块。
- 自适应运行时策略:LinearReader 可以调整某些设置,以保持游戏的流畅运行。
专为服务端设计
作为一款服务端模组,LinearReader 力求为服务器管理员提供最有帮助且信息丰富的支持。提供了如 bench 和 health 等命令,用于查看基准测试结果和内部指标,同时还配有配置文件,以便根据服务器需求定制设置。
(LinearReader 也适用于单人游戏,单人游戏中的玩家也可以访问所有服务器管理员可用的功能。)
模组化服务端
LinearReader 致力于与尽可能多的模组兼容。大多数模组只需安装即可正常工作,但任何更改 Minecraft 存储系统部分或需要在磁盘上读取文件的模组可能无法正常工作。从 RAM 中读取区块数据的模组很可能可以正常工作。
兼容/不兼容模组的列表可以在 wiki 中找到。
如果你发现某个模组与 LinearReader 不兼容(且尚未在列表中列为不兼容),请在我 GitHub 仓库提交一个 issue。
安装与卸载
要安装,只需从 CurseForge 或 Modrinth 下载 LinearReader,将 .jar 文件放入 mods 文件夹即可,一切就绪。之后 LinearReader 会自动处理所有后续工作。
要卸载,请先运行命令 /linearreader export-mca start 将世界中的 .linear 文件转换回 .mca 格式,然后用新的 .mca 区域文件替换原有的 .linear 区域文件,最后移除 LinearReader。
数据安全
建议在安装 LinearReader 之前备份你的世界,因为 LinearReader 会改变 Minecraft 内部存储引擎的许多机制,任何与存储相关的错误都可能导致你的世界损坏。因此,请务必 备份你的世界。
了解更多
本 README 并未提供对 LinearReader 所有功能的全面深入说明。强烈建议阅读 wiki 以全面了解 LinearReader 的所有功能。
此外,你也可以通过留下 issue 在 GitHub 仓库中提问。你还可以使用 CurseForge 的评论区。
开发状态
LinearReader 1.3.0 很可能是最后一个重大更新。
我不再计划为 LinearReader 添加太多新功能。不过,我计划在不久的将来保持 LinearReader 与最新的 Minecraft 版本同步。
我仍会尝试回复 GitHub 上的 issue,如有需要可能会进行热修复或小版本更新,但我打算在发布 1.3.0 版本后停止对 LinearReader 的重大开发(由我主导)。
AI 免责声明
本模组的代码使用了 AI 辅助编写。每次发布前都会进行手动测试。如果遇到任何问题,请在 GitHub 上报告,我会尽快尝试解决。
有关本模组中使用 AI 的更多信息,请参阅 AI_USAGE.md。
LinearReader


LinearReader is a server-side Minecraft mod that reduces your world size without negatively impacting
gameplay. This is done mainly through using Xymb's
Linear Region File Format in
place of Minecraft's Anvil file format, and through utilizing Zstd for compression instead of
the Zlib compression algorithm used by vanilla Minecraft.
How is World Size Reduced?
Xymb's Linear Region File Format
is already a large step up from vanilla Minecraft's region file format, and greatly reduces
world sizes.
The other necessary improvement is the compression algorithm and level of compression. Higher levels
of compression require more resources and more time, which is not ideal for an active server, and
lower levels obviously do not save as much storage. So the challenge was, how can LinearReader
provide the speed of low-level compression and the storage savings of high-level compression?
LinearReader solves this by splitting the workload into two separate stages. Live writes are
compressed quickly with low-level Zstd compression levels, leaving the CPU with plenty of resources
to run Minecraft. Then later, when the server is idle, LinearReader will safely recompress the
region files with much deeper compression.
Compression Benchmarks
To show LinearReader's storage gains and why high level compression is not used during live writes,
I ran benchmarks for the Anvil file format with Zlib using Java’s default compression level (which is
what Vanilla Minecraft uses), Zstd level 4 (which is what LinearReader usually uses for live writes),
and Zstd level 22 (which LinearReader uses for recompression). For a deeper dive on the benchmarks,
see the benchmarks/ directory.
| Dataset |
Format |
Original |
Compressed |
Compression Ratio |
Compression Speed |
Decompression Speed |
| Overworld |
Anvil/Zlib 6 |
9.51 GB |
8.38 GB |
5.44x |
75.7 MB/s |
1271.3 MB/s |
| Overworld |
LinearReader (Zstd 4) |
9.51 GB |
6.21 GB |
7.39x |
585.5 MB/s |
1412.8 MB/s |
| Overworld |
LinearReader (Zstd 22) |
9.51 GB |
4.28 GB |
10.71x |
4.4 MB/s |
1589.2 MB/s |
| End (mostly void) |
Anvil/Zlib 6 |
2.33 GB |
2.16 GB |
3.66x |
188.4 MB/s |
1576.4 MB/s |
| End (mostly void) |
LinearReader (Zstd 4) |
2.33 GB |
244 MB |
33.20x |
1811.1 MB/s |
4062.7 MB/s |
| End (mostly void) |
LinearReader (Zstd 22) |
2.33 Gb |
141 MB |
57.50x |
10.1 MB/s |
6166.9 MB/s |
| Tectonic + Terralith |
Anvil/Zlib 6 |
2.89 GB |
2.56 GB |
5.97x |
84.1 MB/s |
1338.1 MB/s |
| Tectonic + Terralith |
LinearReader (Zstd 4) |
2.89 GB |
1.80 GB |
8.49x |
735.8 MB/s |
1742.8 MB/s |
| Tectonic + Terralith |
LinearReader (Zstd 22) |
2.89 GB |
1.24 GB |
12.37x |
4.4 MB/s |
1787.3 MB/s |
As is shown in the above table, LinearReader + Zstd achieves better compression while still
maintaining fast compression and decompression speeds during normal gameplay, (Zstd 22 is used for
the recompressor, which is not active during normal gameplay).
Other Features
LinearReader doesn't just replace Minecraft's file format and compression algorithm, it also
includes a bunch of other features, such as:
- A backup system: LinearReader can automatically create backups of region files, which can be
used if need be.
- A cache system: A configurable number of recently used region files remain cached in memory,
reducing disk reads and decompression.
- A chunk pruning system: LinearReader can search for empty, worthless chunks that can safely be
deleted. Strict rules are in place to ensure that only truly worthless chunks are pruned.
- An adaptive runtime policy: LinearReader can tweak certain settings to keep the game running
smooth.
Made with Servers in Mind
Being a server-side mod, LinearReader tries to be as helpful and informative for server admins
as possible. There are commands, such as bench and health, for seeing benchmarks and
internal metrics, and a config file so that settings can be tailored to fit the server.
(LinearReader works on singleplayer too, and players in singleplayer have access to all the
same features that server admins can access.)
Modded Servers
LinearReader strives to be compatible with as many mods as possible. Most mods will just work,
but any mods that change part of Minecraft's storage system or require reading files on
disk will likely not work. Mods that read chunk data from RAM will likely work.
A list of compatible/incompatible mods can be found in the
wiki.
If you find a mod that is incompatible with LinearReader (and is not already listed as being
incompatible), please create an issue on my
GitHub repo.
Installation and Uninstallation
To install, just download LinearReader off of CurseForge
or Modrinth, drop the .jar file in the mods folder, and
you're all set. LinearReader will handle everything from there.
To uninstall, run the command /linearreader export-mca start to convert your world's .linear
files back to .mca, replace your .linear region files with the fresh .mca files, and remove
LinearReader.
Data Safety
It is recommended to create a backup of your world before installing LinearReader, as LinearReader
changes much about Minecraft's internal storage engine and any storage-related bugs could potentially
corrupt your world. So please, make backups of your world.
Where to Learn More
This README does not provide a full, in depth explanation of all of LinearReader's features. I highly
encourage reading the wiki to gain a full
understanding of all LinearReader has to offer.
Additionally, you can ask a question on the GitHub repository by leaving an
issue. You can also use the CurseForge
comments section.
Development Status
LinearReader 1.3.0 will probably be the last major update.
I no longer plan to add much to LinearReader anymore. However, I do plan to keep LinearReader up to
date with the latest Minecraft releases for the near future.
I will still try to respond to GitHub issues, and hotfixes or small updates may happen if need be,
but my intention is for serious development of LinearReader (by me) to cease after the release of
version 1.3.0.
AI Disclaimer
AI was used to code this mod. Everything is manually tested before a new release. If you run
into any issues at all please report them on GitHub
and I will try to resolve them as fast as possible.
For more information regarding the use of AI in this mod, please refer to
AI_USAGE.md.
评论 0
登录后参与评分
还没有评论,来抢沙发吧