ObserverLib 是一个库模组,可用于以极小的性能开销可靠地观察大范围内方块的变化。
该库可供公开使用,主要面向从 1.13+ 版本的 Astral Sorcery 使用而设计。
本质上,此模组允许你注册一个Observer(观察者)——具体观察什么最终取决于实现——针对特定区域。在该观察区域内发生的世界变化会被传递给 Observer。观察者可以自行决定这些变化的含义;判断它们是否使观察者的状态失效或有效。例如,以此确定结构是否已完整建成。
实际调用以检查事物是否有效的操作是查询相关位置的 ChangeSubscriber(变更订阅者),然后询问其当前状态是否有效。
这比简单地反复检查一个大区域好在哪里?如果你想观察的区域大于一个区块该怎么办?如果你必须检查的其他区块被卸载了又该怎么办?为了确保没有任何变化且结构完好无损,模组必须加载该区块并检查方块。如果这导致大量的区块加载和卸载,可能会成为一个问题。ObserverLib 的实现确保你可以放心,传递给你的 notifyChange 实现的变更包含所有必要信息,以确保你所观察的内容仍然有效或无效。
此处可见一个用于检查结构是否正确建成的示例实现:这里。与始终检查结构的所有组件不同,该检查确保跟踪不正确/不匹配的位置,并且仅基于与匹配器预期不符的差异进行工作。
如果你有兴趣在自己的项目中使用它,可以从 Maven 获取:
如需进一步的解释和详情,欢迎在 AstralSorcery Discord 上提问:
ObserverLib is a library mod, usable to reliably observe block changes in a potentially large area with very little performance implications.
The library is publicly usable and is primarily focused to be used in Astral Sorcery from 1.13+.
In essence this mod allows you to register an Observer - whatever it observes in the end is up to the implementation - for a specific area. Changes that happen in the world in its observed area are passed onto the Observer. The observer can then decide on its own what these changes mean; if they invalidate or validate the observer's state. So for example if the structure is now complete or not.
The actual call to check if things are valid or not is to query the ChangeSubscriber at the relevant position and then ask if its current state is valid or not.
What makes this better than generally just repeatedly checking a large area? What happens if the area you want to observe is larger than a chunk? What happens if the other chunk you have to check becomes unloaded? In order to be sure nothing has changed and the structure is intact, a mod would have to load said chunk and check the block. Potentially an issue if this causes a lot of chunk loading and unloading. The Implementation of ObserverLib makes sure you can relax and the changes passed onto your implementation of notifyChange contain all necessary information to make sure whatever you're observing is still valid or not.
One exemplary implementation for checking if a structure is built correctly or not can be seen here. Instead of always checking everything of the structure's components, the check makes sure to track the positions that are incorrect/mismatching and only works based off of mismatches to what the matcher expects.
If you're interested in using it for your own projects, you can grab it from maven here:
For further explanations and details, feel free to ask on the AstralSorcery discord:
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 ObserverLib
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
构建于:
- Neoforge 21.1.173
备注:
- 1.21.1 的初始版本
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
评论 0
登录后参与评分
还没有评论,来抢沙发吧