一款旨在修复大型优化模组未涵盖的小型、易被忽视的客户端性能问题的 Minecraft Fabric 模组。
依赖项
- Minecraft 26.1.x, 26.2 或 26.3
- Fabric Loader >= 0.19.5
无需 Fabric API。
功能
- 好友列表优化 (Minecraft 26.2 及更高版本): 缓存好友列表,而非在每次调用时重新构建。
- 计分板侧边栏优化: 缓存排序后的侧边栏条目,而非每帧都扫描和排序所有分数。
- 标签页列表优化: 当列表处于打开状态时,缓存标签页玩家顺序,而非每帧都重新对所有玩家进行排序。
好友列表优化不包含在 26.1 版本中,因为 Minecraft 26.1 没有好友列表功能。
技术细节与深入解析
好友列表存在性检查开销
仅限 Minecraft 26.2 及更高版本。
原版 PlayerSocialManager.getFriends() 会在每次调用时通过 Stream 将整个好友列表转换为一个新列表,尽管底层数据仅在收到新的好友列表时才会更改。当好友列表启用时,PresenceHandler.tick() 会在每个渲染帧调用它一次(它从 Minecraft.runTick 调用,而非每秒 20 次的游戏刻)。每次调用的成本很小,但这是产生相同结果的重复工作。
Blindspot 会缓存结果,仅在原版存储新好友数据时才重新计算。
计分板侧边栏每帧重建
为了绘制侧边栏,原版会在每帧调用 Scoreboard.listPlayerScores()。这会遍历计分板所知的所有持有者,而不仅仅是显示目标中的那些。然后它会过滤掉隐藏条目,对所有条目进行排序并保留前 15 名。如果有数千个条目,这种扫描和排序操作会在每一帧上执行,即使没有任何分数发生变化。在客户端约有 5,000 个计分条目的测试中,原版侧边栏每帧耗时约 0.9–1.3 毫秒,而使用 Blindspot 后约为 0.06–0.08 毫秒。
Blindspot 保留最终经过过滤、排序和限制后的列表,并将其交给原版的处理管线以替代完整的分数列表。为了知道该列表何时过期,Blindspot 向计分板添加了版本计数器,每当创建、更改或删除分数,或团队隶属关系发生变化时,计数器都会更新。仅当这些计数器之一发生变化或显示了不同的目标时,原版代码才会重建列表。此步骤之后的所有内容(如团队颜色和前缀、数字格式、文本宽度)仍像原版一样每帧运行。因此,字体、语言和资源包更改的行为与未安装模组时相同。
标签页列表每帧重新排序
当标签页列表处于打开状态时,原版会在每帧对所有列出的玩家进行排序。每次比较都会在计分板上查找双方玩家的团队。顺序仅取决于服务器提供的列表顺序、旁观者模式、团队和玩家名称,而这些很少发生变化。
Blindspot 缓存排序后的顺序,仅在玩家添加到列表或从列表中移除、玩家的游戏模式或列表顺序发生变化、或团队隶属关系发生变化时,才让原版重建顺序。延迟更新、显示名称和皮肤不会影响顺序,也不会触发重建。行本身(名称、延迟、分数、生命值)仍由原版每帧绘制。
验证缓存
启动游戏时使用 JVM 参数 -Dblindspot.verifyCaches=true,使 Blindspot 在每个侧边栏和标签页列表缓存命中时同时计算原版结果并进行比较。日志将显示任何不匹配之处,并且每 1,000 次检查会显示命中率。每次检查除了缓存外还会运行完整的原版计算,因此在启用期间游戏速度会比未安装模组时慢。这仅用于测试和错误报告。
兼容性
Blindspot 不会改变所绘制的内容、发送给或接收自服务器的数据,也不会影响世界的模拟方式。它对侧边栏、标签页列表、计分板和数据包处理代码的钩子仅缓存原版无论如何都会计算的结果,或记录这些结果何时发生变化。
已在 Minecraft 26.3 的单人模式和多人模式中,与 Sodium 0.9.2 和 Lithium 0.26.2 一起进行了测试。尚未用所有模组进行测试。
完全替换原版侧边栏或标签页列表代码的模组可能会与之冲突。Blindspot 的设计使得此类冲突通常会在启动时表现为崩溃,而不是在游戏中无声地产生错误结果。如果遇到此类问题,请在 GitHub 上提交包含你日志的问题报告。
源码与贡献
Blindspot 基于 LGPL-3.0-only 开源协议。源代码位于 GitHub。
发现了其他类似的小且易被忽视的性能问题?欢迎在那里提交问题或拉取请求。
A Minecraft Fabric mod aiming to fix small, overlooked client-side performance issues that larger optimization mods don't cover.
Requirements
- Minecraft 26.1.x, 26.2 or 26.3
- Fabric Loader >= 0.19.5
Fabric API is not required.
Features
- Friends List Optimization (Minecraft 26.2 and newer): Caches the friends list instead of rebuilding it on every call.
- Scoreboard Sidebar Optimization: Caches the sorted sidebar entries instead of scanning and sorting every score on every frame.
- Tab List Optimization: Caches the tab list player order instead of re-sorting all players on every frame while the list is open.
The friends list optimization isn't part of the 26.1 version, because Minecraft 26.1 has no friends list.
Technical Details & Deep Dives
Friends List presence check overhead
Minecraft 26.2 and newer only.
Vanilla's PlayerSocialManager.getFriends() converts the whole friends list into a new list through a Stream on every call, even though the underlying data only changes when a new friend list arrives. While the friends list is enabled, PresenceHandler.tick() calls it once per rendered frame (it is called from Minecraft.runTick, not from the 20-per-second game tick). The cost per call is small, but it is repeated work that produces the same result each time.
Blindspot caches the result and only recomputes it when vanilla stores new friend data.
Scoreboard sidebar rebuilt every frame
To draw the sidebar, vanilla calls Scoreboard.listPlayerScores() on every frame. This walks through every score holder the scoreboard knows about, not just the ones on the displayed objective. It then filters out hidden entries, sorts all of them and keeps the top 15. With thousands of entries this scan and sort is paid on every single frame, even when no score has changed. In a test with about 5,000 score entries on the client, the sidebar took about 0.9–1.3 ms per frame in vanilla and about 0.06–0.08 ms with Blindspot.
Blindspot keeps the final filtered, sorted and limited list and hands it to vanilla's pipeline in place of the full score list. To know when that list is outdated, Blindspot adds version counters to the scoreboard that change whenever a score is created, changed or removed, or team membership changes. The list is only rebuilt by vanilla's own code when one of these counters changed or a different objective is displayed. Everything after that step still runs every frame exactly as in vanilla: team colors and prefixes, number formats, text widths. Font, language and resource pack changes therefore behave the same as without the mod.
Tab list re-sorted every frame
While the tab list is open, vanilla sorts all listed players on every frame. Each comparison looks up both players' teams on the scoreboard. The order only depends on the server-provided list order, spectator mode, team and player name, which rarely change.
Blindspot caches the sorted order and lets vanilla rebuild it only when a player is added to or removed from the list, a player's game mode or list order changes, or team membership changes. Ping updates, display names and skins don't affect the order and don't cause a rebuild. The rows themselves (names, ping, scores, hearts) are still drawn by vanilla every frame.
Verifying the caches
Start the game with the JVM argument -Dblindspot.verifyCaches=true to make Blindspot compute the vanilla result alongside every sidebar and tab list cache hit and compare them. The log then shows any mismatch and, every 1,000 checks, the hit rate. Every check runs the full vanilla computation in addition to the cache, so the game is slower than without Blindspot while it's enabled. It's only meant for testing and bug reports.
Compatibility
Blindspot doesn't change what is drawn, what is sent to or received from a server, or how the world is simulated. Its hooks into the sidebar, tab list, scoreboard and packet handling code only cache results vanilla would compute anyway, or note when those results change.
Tested together with Sodium 0.9.2 and Lithium 0.26.2 on Minecraft 26.3, in singleplayer and multiplayer. It hasn't been tested with every mod.
Mods that completely replace the vanilla sidebar or tab list code may conflict with it. Blindspot is set up so that such a conflict usually shows up as a crash at startup instead of silently wrong results in game. If you run into one, please open an issue on GitHub with your log.
Source & Contributing
Blindspot is open source under LGPL-3.0-only. The source code is on GitHub.
Found another small, overlooked performance issue like these? Feel free to open an issue or pull request there.
下载 Blindspot
下载 Blindspot
下载 Blindspot
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Blindspot
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Blindspot
下载 Blindspot
下载 Blindspot
下载 Blindspot
Blindspot 0.4.0
新增
- 船只状态优化: 每个游戏刻,原版都会扫描每艘船周围的流体和方块碰撞形状,以判断其处于水中、水下、陆地还是空中。停靠的船只以及由服务器移动的船只也会执行此操作。Blindspot 现在会在船的边界框完全相同且周围区块未发生变化时复用上一次的结果。那些碰撞形状可以在不改变方块的情况下发生变化的方块(活塞、潜影盒、脚手架以及其他原版标记为具有动态形状的方块)永远不会被缓存,因此结果始终与原版一致。
- 缓存验证模式 (
-Dblindspot.verifyCaches=true) 现在也涵盖了船只状态缓存。
更改
- 所有 Minecraft 版本现在使用统一的版本号命名规则:Minecraft 版本号作为构建元数据附加在后面,例如
0.4.0+26.3、0.4.0+26.2和0.4.0+26.1。这也适用于最新的 Minecraft 版本。
兼容性
- 已在 Minecraft 26.3 上与 Sodium 0.9.2 和 Lithium 0.26.2 配合测试通过。
- 仍然不需要 Fabric API。
- 完全替换原版侧边栏、标签页列表或船只代码的模组可能与 Blindspot 发生冲突。在这种情况下,游戏通常会在启动时崩溃而不是显示错误的结果。如果发生这种情况,请提交包含日志的问题报告。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
评论 0
登录后参与评分
还没有评论,来抢沙发吧