该模组会在玩家在线或离线时,被动地在玩家周围生成区块,并预先生成世界出生点附近可能在近期会用到的区块。
工作原理
Minecraft 是部分多线程的。
每个维度(如果你是一名使用 Mojmaps 的模组开发者,则称为“层级”)都有自己独立的线程来生成区块。
在主线程(用于处理大部分游戏内内容的线程)上,我正在检查哪些区块适合加载。这包括检测该维度的世界生成线程当前是否正在生成某个区块。这样可以确保更重要的区块优先被生成。如果找到合适的区块,它将在每个相关线程上安排生成任务。
错误抑制
IO 线程有时尝试保存区块,而与此同时,世界生成线程可能正在向地图中添加新区块。这会引发并发修改异常(ConcurrentModificationException),并被记录到日志中。这些区块会在后续的保存尝试中被写入磁盘(在我的测试中这种情况确实发生过,且不会导致世界损坏——但为了保险起见,建议你还是做好备份)。由于这些异常发生较为频繁且可以忽略,因此会被抑制,不再记录到日志中。
This mod generates chunks passively around players, offline or online, and the worldspawn to generate chunks that will most likely be needed in the near future.
How this works
Minecraft is partially multithreaded.
Each Dimension(or Level if you are a modder and use Mojmaps) has its own Thread to generate chunks.
On the Main Thread, the one used for most ingame stuff, I'm checking for viable chunks to load. This includes a check if that dimensions worldgen thread is currently generating a chunk. This makes sure, that more important chunks are generated first. It then schedules the generation of a viable chunk on each thread, if it could find one.
Error Suppression
The IO Thread is sometimes trying to save chunks, while a new one is added to a map by a worldgen thread. This causes ConcurrentModificationExceptions to be thrown and logged. The chunk is saved to disc in a later attempt (that happened during my testing, and shouldn't destroy worlds (but you should make backups, just to be sure)). These Exception, because they happen rather often and can be ignored are suppressed and won't be logged.
评论 0
登录后参与评分
还没有评论,来抢沙发吧