BetterView
描述
BetterView 是一款高性能的 Paper 插件和 Fabric 模组,适用于 Minecraft 服务器。它通过异步玩家处理、直接从磁盘读取区块以及缓存区块数据,在不牺牲服务器性能的前提下扩展了常规视距。
功能
- 在网络线程上异步快速处理玩家逻辑
- 直接从磁盘读取区块,无需加载它们
- 优化的区块状态追踪与区块迭代
- 可配置的区块数据缓存以实现快速访问
- 可配置的限制以控制区块发送和区块生成
- 支持按维度(Dimension)配置选项
- 支持集成式或独立式 Fabric 服务器
- 为扩展区块提供轻量级反 X 光支持
示例:视距为 127 个区块时的加载速度
下面的截图是在末地维度坐标 0 2250 0 处拍摄的,视距设置为 127 个区块(已禁用雾效)。在 AMD Ryzen 7 5800X 处理器上,加入服务器后,所有可见区块在冷缓存情况下约需 12 秒传输至客户端,在热缓存情况下约需 9 秒。
支持的软件
| Minecraft 版本 |
Paper |
Fabric |
| 26.3.x |
✅ |
✅ |
| 26.2.x |
✅ |
✅ |
| 26.1.x |
✅ |
✅ |
| 1.21.11 |
✅ |
✅ |
| 1.21.10 |
✅ |
✅ |
| 1.21.9 |
✅ |
✅ |
| 1.21.8 |
✅ |
✅ |
| 1.21.7 |
✅ |
✅ |
| 1.21.6 |
✅ |
✅ |
| 1.21.5 |
✅ |
✅ |
| 1.21.4 |
✅ |
✅ |
| 1.21.3 |
✅ |
✅ |
| 1.21.1 |
✅ |
✅ |
在 Fabric 环境下,此模组依赖 Moonrise 和
adventure-platform-mod 才能正常工作。
用法
在 Paper 服务器上,将 jar 文件放入 plugins 目录并重启服务器。在 Fabric 服务器/客户端上,
将 jar 文件放入 mods 目录并重启服务器或客户端。默认情况下,BetterView 将为每个维度配置 32 个区块的视距。
配置
首次启动时,该插件会自动创建一个配置文件。如果使用 Paper,它将创建于
plugins/BetterView/config.yml;如果使用 Fabric,它将创建于你的世界目录内的 betterview.yml 文件中
(例如独立服务器的 world 目录)。在其中,你可以配置以下选项:
config-version:请勿修改此项
integrated-server-render-distance:仅对单人世界有效,此选项允许替换集成服务器的渲染距离。否则 BetterView 将不起作用(默认值:-1,已禁用)
global:
enabled:是否启用或禁用整个插件/模组(默认值:true)
chunk-generation-limit:每个刻(tick)全局可生成的新区块数量上限(默认值:3)
chunk-send-limit:每个刻发送给单个玩家的最大区块数量(默认值:3)
dimensions:
<dimension>(例如 minecraft:overworld):
enabled:是否在此维度中启用或禁用该插件/模组(默认值:true)
chunk-generation-limit:每个刻可为此层级生成的新区块数量上限(默认值:2)
chunk-queue-size:每个玩家可同时排队的区块数量上限(默认值:16)
view-distance:此维度的最大扩展视距(默认值:32)
cache-duration:扩展区块在内存中保留的缓存时长(默认值:PT5M,即 5 分钟)
- 请根据服务器的用途调整缓存时长;
例如,对于静态大厅服务器,可以使用比动态 SMP 服务器更长的缓存时长。
如果缓存时间过长,玩家在重新加入后可能会看到过时的区块内容。
anti-xray:
- 请注意,本插件实现了一个轻量级的反 X 光功能,它不会检查方块是否暴露在空气中。这意味着除
HIDE 之外的所有引擎模式可能看起来效果不佳。
enabled:是否在此世界中启用或禁用反 X 光功能(默认值:false)
engine-mode:反 X 光的引擎模式,可选 HIDE、OBFUSCATE 或 OBFUSCATE_LAYER
(默认值:HIDE)
hidden-blocks:需要隐藏/混淆的方块列表(默认值:所有矿石以及所有维度的所有基础方块)
chunk-batches:
- 区块批次用于确保客户端/玩家的网络连接不会因为一次性发送过多区块而过载。如果启用,BetterView 会发送一个区块批次并等待玩家确认已接收完整的区块批次。只有在收到确认后,才会发送下一批区块。
这会产生一个副作用:连接良好但延迟较高的玩家将比理论速度更慢地接收区块。
注意:区块批次可能会跨越多个刻进行发送。
enabled:是否在此维度中启用或禁用区块批次功能(默认值:true)
chunks-per-batch:单个批次中的区块数量(默认值:12)
prepare-chunks-while-waiting:在等待前一批次确认期间,BetterView 是否应继续准备区块(默认值:true)
batch-timeout:如果在指定时间内未发送任何区块,则批次过期(默认值:PT5S)
batch-wait-timeout:超时时间,超过此时间后即使没有玩家响应,BetterView 也会自动将批次标记为完成(默认值:PT30S)
您可以随意调整区块生成和发送限制,以在您的服务器设置中获得最佳体验。
API 用法
Maven 仓库:https://repo.minceraft.dev/releases/
Maven 构件:dev.booky.betterview:betterview-api:2.2.1
Javadoc:
Paper 示例
// 使用 Bukkit 的 ServicesManager 获取 BetterView API 实例
// 这是在 Paper 上使用 API 与 Fabric 之间的唯一区别
BvManager bvManager = Bukkit.getServicesManager().load(BvManager.class);
if (bvManager == null) {
throw new IllegalStateException("Failed to load BetterView API");
}
// 使主世界坐标 0,0 处的区块缓存失效
BvLevel overworld = bvManager.getLevel(Key.key(Key.MINECRAFT_NAMESPACE, "overworld"));
overworld.invalidateChunkCache(0, 0);
// 刷新主世界中所有玩家的区块
for (BvPlayer player : overworld.getPlayers()) {
// (切换到适当的线程以确保线程安全)
player.getExecutor().execute(() -> {
if (!player.isActive() || player.getLevel() != overworld) {
// 玩家不活跃或不在主世界——也许在这段代码运行的短时间内他们切换了维度?
return;
}
// 确保 BetterView 实际上“拥有”坐标 0,0 处的区块
if (player.getChunkLifecycle(0, 0).isOwned()) {
// 最后,排队刷新该区块!
player.refreshChunk(0, 0);
}
});
}
Fabric 示例
// 使用 Fabric 的 ObjectShare 获取 BetterView API 实例
// 这是在 Paper 和 Fabric 上使用 API 的唯一区别
BvManager bvManager = (BvManager) FabricLoader.getInstance().getObjectShare().get("betterview:api");
if (bvManager == null) {
throw new IllegalStateException("加载 BetterView API 失败");
}
// 重载世界中坐标为 0, 0 的区块缓存失效
BvLevel overworld = bvManager.getLevel(Key.key(Key.MINECRAFT_NAMESPACE, "overworld"));
overworld.invalidateChunkCache(0, 0);
// 为重载世界中的所有玩家刷新区块
for (BvPlayer player : overworld.getPlayers()) {
// (切换到合适的线程以确保线程安全)
player.getExecutor().execute(() -> {
if (!player.isActive() || player.getLevel() != overworld) {
// 玩家未激活或不在重载世界中——可能在这段代码执行期间他们切换了维度?
return;
}
// 确保 BetterView 实际上“拥有”坐标为 0, 0 的区块
if (player.getChunkLifecycle(0, 0).isOwned()) {
// 最后,将区块加入刷新队列!
player.refreshChunk(0, 0);
}
});
}
请注意,该 API 仍在开发中。请随时在 Discord 或问题追踪器中提出建议、增强功能或其他想法。
构建
- 克隆项目(
git clone https://github.com/MinceraftMC/BetterView.git)
- 进入克隆的目录(
cd BetterView)
- 构建 jar 文件(Linux/MacOS 上运行
./gradlew build,Windows 上直接运行 gradlew build)
jar 文件位于 build → libs 目录中。
贡献
如果您想为 BetterView 做出贡献,请随意分叉仓库并创建拉取请求。请确保遵循项目中使用的代码风格和约定。如果您有任何问题或需要帮助,欢迎在 Discord 中提问。
您可以通过运行 ./gradlew :paper:runServer 或分别运行 ./gradlew :fabric:prodServer/./gradlew :fabric:prodClient 来测试您的更改。这将启动一个本地服务器,自动安装已编译的插件或模组,并在 IDE 中准备好进行调试。
BetterView
Description
BetterView is a high-performance Paper plugin and Fabric mod for Minecraft servers. It extends the normal view distance
without sacrificing server performance using asynchronous player processing, direct chunk reading from disk, and
caching of chunk data.
Features
- Asynchronous fast player ticking on networking threads
- Reads chunks directly from disk without loading them
- Optimized chunk state tracking and chunk iteration
- Configurable chunk data caching for fast access
- Configurable limitations for chunk sending and chunk generation
- Per-dimension configuration options
- Support for integrated or dedicated fabric servers
- Lightweight anti-xray support for extended chunks
Example: Loading speed for a view distance of 127 chunks
The screenshot below was taken at 0 2250 0 in the end dimension with a view distance of 127 chunks
(with fog disabled). On an AMD Ryzen 7 5800X, all visible chunks were transmitted to the client in about
12 seconds after having joined the server with a cold cache and in about 9 seconds with a warm cache.
Supported Software
| Minecraft Version |
Paper |
Fabric |
| 26.3.x |
✅ |
✅ |
| 26.2.x |
✅ |
✅ |
| 26.1.x |
✅ |
✅ |
| 1.21.11 |
✅ |
✅ |
| 1.21.10 |
✅ |
✅ |
| 1.21.9 |
✅ |
✅ |
| 1.21.8 |
✅ |
✅ |
| 1.21.7 |
✅ |
✅ |
| 1.21.6 |
✅ |
✅ |
| 1.21.5 |
✅ |
✅ |
| 1.21.4 |
✅ |
✅ |
| 1.21.3 |
✅ |
✅ |
| 1.21.1 |
✅ |
✅ |
On fabric, this mod depends on Moonrise and
adventure-platform-mod to work.
Usage
On Paper servers, place the jar file in your plugins directory and restart your server. On Fabric servers/clients,
place the jar file in your mods directory and restart your server or client. By default, BetterView will configure a
view distance of 32 chunks for each dimension.
Configuration
On the first start, this plugin will automatically create a configuration file. If using Paper it will be created at
plugins/BetterView/config.yml, if using Fabric it will be created as betterview.yml inside your world directory
(e.g. world for dedicated servers). In there, you are able to configure the following options:
config-version: Don't touch this
integrated-server-render-distance: Only relevant for singleplayer worlds, this allows replacing the render distance
of the integrated server as BetterView would otherwise have no effect (default: -1, disabled)
global:
enabled: Whether to enable or disable the entire plugin/mod (default: true)
chunk-generation-limit: How many new chunks can be generated globally in one tick (default: 3)
chunk-send-limit: The maximum amount of chunks sent to a player in a tick (default: 3)
dimensions:
<dimension> (e.g. minecraft:overworld):
enabled: Whether to enable or disable the plugin/mod for this dimension (default: true)
chunk-generation-limit: How many new chunks can be generated for this level in one tick (default: 2)
chunk-queue-size: How many chunks can be queued per player at once (default: 16)
view-distance: The maximum extended view distance for this dimension (default: 32)
cache-duration: The cache duration for how long extended chunks should be kept in memory (default: PT5M,
5 minutes)
- Make sure to adjust the cache duration based on what you use your server for;
for e.g. static lobby servers, you can use a longer cache duration than for dynamic SMP servers.
If the cache duration is too high, chunks will display outdated content after e.g. a rejoin.
anti-xray:
- Be aware that this plugin implements a lightweight version of anti-xray, which
doesn't check if a block is exposed to air or not. This means that every engine-mode other than
HIDE
will probably not look very good.
enabled: Whether anti-xray will be enabled or disabled in this world (default: false)
engine-mode: Engine modes of anti-xray, either HIDE, OBFUSCATE, or OBFUSCATE_LAYER
(default: HIDE)
hidden-blocks: The list of blocks to hide/obfuscate (default: all ores and
all base blocks of dimensions)
chunk-batches:
- Chunk batches are used to ensure the client/internet of players doesn't get overwhelmed by
too many chunks being sent at once. If enabled, BetterView sends a chunk batch and waits
for the player to acknowledge they received the full chunk batch. Only then the next batch of chunks
will be sent.
A side effect of this will be that players with good connectivity but high latency
will receive chunks at a much slower rate than possible.
Note: chunk batches may be sent across multiple ticks.
enabled: Whether chunk batches are enabled or disabled in this dimension (default: true)
chunks-per-batch: The amount of chunks in a single batch (default: 12)
prepare-chunks-while-waiting: Whether BetterView should continue preparing chunks while waiting for acknowledgement of previous batch (default: true)
batch-timeout: The amount of time without a chunk being sent after which a batch expires (default: PT5S)
batch-wait-timeout: The timeout after which BetterView automatically marks the batch as done, even without a player response (default: PT30S)
Feel free to play around with the chunk generations and chunk sending limits for
an optimal experience on your server setup.
API Usage
Maven Repository: https://repo.minceraft.dev/releases/
Maven Artifact: dev.booky.betterview:betterview-api:2.2.1
Javadoc:
Example for Paper
// get the BetterView API instance using Bukkit's ServicesManager
// this is the only difference between using the API on paper and fabric
BvManager bvManager = Bukkit.getServicesManager().load(BvManager.class);
if (bvManager == null) {
throw new IllegalStateException("Failed to load BetterView API");
}
// invalidate chunk cache at 0 0 in the overworld
BvLevel overworld = bvManager.getLevel(Key.key(Key.MINECRAFT_NAMESPACE, "overworld"));
overworld.invalidateChunkCache(0, 0);
// refresh the chunk for all players in the overworld
for (BvPlayer player : overworld.getPlayers()) {
// (switch to proper thread for thread-safety)
player.getExecutor().execute(() -> {
if (!player.isActive() || player.getLevel() != overworld) {
// player isn't active or isn't in overworld - maybe they have switched
// dimensions in the short time it took for this code to run?
return;
}
// ensure BetterView actually "owns" the chunk at 0 0
if (player.getChunkLifecycle(0, 0).isOwned()) {
// finally, queue the chunk to be refreshed!
player.refreshChunk(0, 0);
}
});
}
Example for Fabric
// get the BetterView API instance using fabric's object share
// this is the only difference between using the API on paper and fabric
BvManager bvManager = (BvManager) FabricLoader.getInstance().getObjectShare().get("betterview:api");
if (bvManager == null) {
throw new IllegalStateException("Failed to load BetterView API");
}
// invalidate chunk cache at 0 0 in the overworld
BvLevel overworld = bvManager.getLevel(Key.key(Key.MINECRAFT_NAMESPACE, "overworld"));
overworld.invalidateChunkCache(0, 0);
// refresh the chunk for all players in the overworld
for (BvPlayer player : overworld.getPlayers()) {
// (switch to proper thread for thread-safety)
player.getExecutor().execute(() -> {
if (!player.isActive() || player.getLevel() != overworld) {
// player isn't active or isn't in overworld - maybe they have switched
// dimensions in the short time it took for this code to run?
return;
}
// ensure BetterView actually "owns" the chunk at 0 0
if (player.getChunkLifecycle(0, 0).isOwned()) {
// finally, queue the chunk to be refreshed!
player.refreshChunk(0, 0);
}
});
}
Please note that the API is still work in progress. Please be sure to post suggestions, enhancements or any other ideas
on our Discord or in the issue tracker.
Building
- Clone the project (
git clone https://github.com/MinceraftMC/BetterView.git)
- Go to the cloned directory (
cd BetterView)
- Build the jar files (
./gradlew build on Linux/MacOS, just gradlew build on Windows)
The jar files can be found in the build → libs directory.
Contributing
If you want to contribute to BetterView, feel free to fork the repository and create a pull request. Please make sure to
follow the code style and conventions used in the project. If you have any questions or need help, feel free to ask in
our Discord.
You can test your changes by running ./gradlew :paper:runServer or
./gradlew :fabric:prodServer/./gradlew :fabric:prodClient respectively. This will start a local server with the
compiled plugin or mod automatically installed, ready for debugging in your IDE.
评论 0
登录后参与评分
还没有评论,来抢沙发吧