重要许可证声明
以任何形式使用本项目,即表示您对本项目许可证条款(见 License)给予“明确同意”,并确认我(本项目的作者)已履行许可证规定的义务,即“在现有情况下做出合理努力以获取接收者对本许可证条款的明确同意”。
TooManyRecipeViewers
TooManyRecipeViewers(简称 TMRV)是一个兼容层,由 Nolij 编写,用于在不安装 JEI 的情况下,让 EMI 运行 JEI 插件。
你需要安装 EMI 才能使用此模组。
为什么选择 TMRV 而不是 EMI+JEI(即 JEMI)?
JEMI 是内置于 EMI 中的一个兼容层,旨在通过大量依赖 JEI 的内部机制,使 JEI 插件在 EMI 中基本可用。它的设计尽可能简单,依赖于 JEI 先处理配方数据,然后再将其导入到 EMI 中。
TMRV 与 JEMI 不同——它旨在完全替换 JEI API(注意:TMRV 包含一些未修改的 JEI 内部代码——详见 JEI Code Re-Use)。TMRV(在可行的情况下)将 JEI API 替换为直接映射到 EMI API 的代码,而不是加载整个 JEI 注册表并在事后查询它。这带来了几个优势,包括更有效地利用系统资源,但这也是一项权衡,因为 TMRV 的方法使得维护工作远比 JEMI 复杂。JEMI 故意这样设计,以便让 EMI 的开发能够专注于改进 EMI 本身,我完全支持这种做法。
TL;DR:TMRV 比 JEMI 效率高得多,代价是维护成本远高于 JEMI,且不应期望 EMI 投入如此多的精力来支持一个在设计时有意未引用的 API。请庆幸 EMI 从一开始就能开箱即用加载 JEI 插件——这也确实花了相当大的功夫。
话虽如此,TMRV 相比 JEMI 有两个主要优势:
1. 插件兼容性
TMRV 对 JEI API 的支持覆盖范围比 JEMI 更广(有一个例外——见 Known API Limitations)。截至撰写本文时,这包括:
- 更好的内置配方类型转换(JEMI 仅支持合成和信息配方类型;TMRV 支持所有内置的 JEI 配方类型)
- 支持原料/搜索别名
createRecipeExtras支持
2. 效率
使用 TMRV 时,你进入世界的速度总是快于使用 JEMI。这是因为 JEI 插件初始化会阻塞世界加载——在所有 JEI 插件初始化完成之前,你无法开始游戏。而 EMI 在世界加载后异步加载插件。
这意味着,即使 TMRV 加载 JEI 插件的速度比 JEI 慢(事实并非如此,它的加载速度明显更快——见 benchmarks),世界也始终会比使用 JEMI 时加载得更快。
如前所述,TMRV 将大部分 JEI API 替换为对应 EMI API 的映射器——这意味着可以彻底移除 JEI 内部结构的很大一部分。无需初始化和存储整个 JEI 配方注册表——TMRV 只需将 JEI API 调用转换为 EMI 调用,并将响应转换为 JEI 格式。可以将 TMRV 比作 Wine 或 Proton,而将 JEMI 比作虚拟机。JEMI 使用真实的 JEI,因此可能会出现某些场景下 TMRV 报错而 JEMI 不会的情况(请注意,这并不一定意味着 JEMI 正确支持该场景,只是看起来像那样),但总体而言,TMRV 的效率会高于 JEMI。
基准测试
完整的结果和获取这些结果所遵循的步骤记录在 BENCHMARKS.md 中。这些结果并非经过挑选。说明文件中的步骤被严格遵照执行。我鼓励社区进行验证。
加载时间
| TMRV | JEMI | Comparison | |
|---|---|---|---|
| Craftoria | 1582ms (世界加载前 5ms,世界加载后 1577ms) | 11036ms (世界加载前 10000ms,世界加载后 1036ms) | -9454ms (世界加载前 -9995ms,世界加载后 +541ms) |
| ATM10 | 4951ms (世界加载前 3ms,世界加载后 4948ms) | 20132ms (世界加载前 15550ms,世界加载后 4582ms) | -15181ms (世界加载前 -15547ms,世界加载后 +366ms) |
| Finality: Omnia | 3010ms (世界加载前 6ms,世界加载后 3004ms) | 6354ms (世界加载前 4425ms,世界加载后 1929ms) | -3344ms (世界加载前 -4419ms,世界加载后 +1075ms) |
内存占用
| TMRV | JEMI | Comparison | |
|---|---|---|---|
| Craftoria | 4.278 GiB | 4.386 GiB | -110.6 MiB (近似值) |
| ATM10 | 4.401 GiB | 5.273 GiB | -892.9 MiB (近似值) |
| Finality: Omnia | 1.947 GiB | 2.065 GiB | -120.8 MiB (近似值) |
已知的 API 限制
JEI 配置文件
.minecraft/config/jei/blacklist.json 是 TMRV 唯一读取的 JEI 配置文件。该文件对于原版原料类型以及由 JEI 插件添加的模组原料类型应该能正常工作(这不包括原生同时支持 JEI 和 EMI 的模组,例如 Mekanism)。这是为了作为从 JEI 切换过来的整合包的权宜之计。JEMI 也存在类似的缺陷。EMI 有自己的隐藏原料配置——请使用那个配置。TMRV 完全忽略其他所有 JEI 配置文件,并且没有计划支持它们。
Recipe Manager Plugins
JEI API 支持“配方管理器插件”(Recipe Manager Plugins)。这些插件允许模组自行控制其配方注册表,并在运行时处理配方查询。
TMRV 将尝试从这些插件中提取配方,但这在大多数插件上并不生效,且远未达到对该功能的完善支持。目前暂无计划提供超出此范围的支持。配方管理器插件是一个过时的概念,极少有插件仍在沿用;若要对其进行妥善支持,则必须使用侵入性极强的 EMI mixin——而这并非本项目所打算采用的方案。
运行时注册表更改
JEI API 支持在运行时(即插件注册完成后)修改配方和物品注册表。这一概念与 EMI 不兼容,且我不希望支持此类做法。因此,在 IModPlugin.onRuntimeAvailable 被调用后,若再尝试调用任何用于运行时注册表修改的 API,都将抛出 IllegalStateException,以避免潜在的混淆。
JEI 代码复用
计划在后续更新中替换更多 JEI 的内部实现。然而,出于各种原因,JEI 的部分内容并无重新实现的必要。无论如何,TMRV 已经替换了足够多的 JEI 内部逻辑,我可以自信地说:
- 通过 mixin 来实现对 JEMI 的同等优化是不可行的(至少无法以合理的方式实现),并且
- 已有足够多的 JEI 内部实现被替换或移除,因此我认为这并未对 JEI 造成不公平,尤其是考虑到 JEI 的许可证 明确允许此类行为。
许可证
本项目采用 OSL-3.0 许可证授权。更多信息请参阅 LICENSE。
部分代码遵循其版权许可证要求,从 EMI 和 JEI 复制而来。本项目中存在的所有修改均与项目其余部分一样,采用 OSL-3.0 许可证授权。
IMPORTANT LICENSE NOTICE
By using this project in any form, you hereby give your "express assent" for the terms of the license of this project (see License), and acknowledge that I (the author of this project) have fulfilled my obligation under the license to "make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License".
TooManyRecipeViewers
TooManyRecipeViewers (or TMRV) is a compatibility layer for running JEI plugins with EMI without having to install JEI, written by Nolij.
You'll need EMI installed to use this mod.
Why use TMRV over EMI+JEI (AKA JEMI)?
JEMI is a compatibility layer built-in to EMI to get JEI plugins mostly working with EMI by heavily relying on the JEI internals. It is designed to be as simplistic as possible and relies on JEI to process recipe data first before it is imported to EMI.
TMRV is not like JEMI - it aims to completely replace the JEI API (NOTE: TMRV does contain some unmodified JEI internals - see JEI Code Re-Use). TMRV (where feasible) replaces JEI APIs with direct mappers to EMI APIs instead of loading the whole JEI registry and querying it after the fact. This has several advantages, including more efficient use of system resources, but is also a tradeoff, as TMRV's approach makes maintenance far more involved than what JEMI requires. JEMI is intentionally designed this way to allow EMI development to be focused on improving EMI itself, which is an approach I fully support.
TL;DR: TMRV is much more efficient than JEMI at the cost of taking much more effort to maintain than JEMI does, and nobody should expect EMI to put this amount of effort in to supporting an API that was intentionally not referenced during design. Be happy EMI can even load JEI plugins out of the box to begin with - it still took a fair amount of effort.
That being said, TMRV has two primary advantages over JEMI:
1. Plugin Compatibility
TMRV has better coverage of JEI's API than JEMI does (with one exception - see Known API Limitations). As of writing, this includes:
- Better conversion of built-in recipe types (JEMI only supports crafting and info recipe types; TMRV supports all built-in JEI recipe types)
- Ingredient/search alias support
createRecipeExtrassupport
2. Efficiency
With TMRV, you will always load in to the world faster than with JEMI. This is because JEI plugin initialization blocks world load - you can't start playing until all JEI plugins are initialized. EMI loads plugins asynchronously after the world is loaded.
This means that even if TMRV loaded JEI plugins slower than JEI does (not the case, it loads them measurably faster - see benchmarks), worlds will always load faster with TMRV than with JEMI.
As already mentioned, TMRV replaces much of the JEI APIs with mappers to the corresponding EMI APIs - this means entire parts of the JEI internals can be outright removed. There's no need to initialize and store a whole JEI recipe registry - TMRV just converts JEI API calls to EMI ones, and converts the responses to the JEI format. Think of TMRV like Wine or Proton, and JEMI like a VM. JEMI uses real JEI, so there will be some scenarios where TMRV will error where JEMI won't (note that this doesn't necessarily mean that JEMI properly supports a scenario, it just means it looks like it does), but TMRV will generally be more efficient than JEMI.
Benchmarks
The full results and steps followed to obtain them are documented in BENCHMARKS.md. These results were not cherry-picked. The instructions were followed exactly as documented in that file. I encourage the community to verify them.
Load Times
| TMRV | JEMI | Comparison | |
|---|---|---|---|
| Craftoria | 1582ms (5ms before world load, 1577ms after world load) | 11036ms (10000ms before world load, 1036ms after world load) | -9454ms (-9995ms before world load, +541ms after world load) |
| ATM10 | 4951ms (3ms before world load, 4948ms after world load) | 20132ms (15550ms before world load, 4582ms after world load) | -15181ms (-15547ms before world load, +366ms after world load) |
| Finality: Omnia | 3010ms (6ms before world load, 3004ms after world load) | 6354ms (4425ms before world load, 1929ms after world load) | -3344ms (-4419ms before world load, +1075ms after world load) |
Memory Usage
| TMRV | JEMI | Comparison | |
|---|---|---|---|
| Craftoria | 4.278 GiB | 4.386 GiB | -110.6 MiB (approximate) |
| ATM10 | 4.401 GiB | 5.273 GiB | -892.9 MiB (approximate) |
| Finality: Omnia | 1.947 GiB | 2.065 GiB | -120.8 MiB (approximate) |
Known API Limitations
JEI Config Files
.minecraft/config/jei/blacklist.json is the only JEI config file that TMRV even reads. This file should work fine for vanilla ingredient types and for modded ingredient types added by a JEI plugin (this does not include mods that support both JEI and EMI natively, such as Mekanism). This is meant to be a stop-gap for packs switching over from JEI. JEMI had a similar flaw. EMI has its own config for hiding ingredients - please use that instead. All other JEI config files are completely ignored by TMRV, and there are no plans to support them.
Recipe Manager Plugins
The JEI API supports "Recipe Manager Plugins". These plugins allow mods to control their own recipe registries and handle recipe lookups themselves at runtime.
TMRV will attempt to extract recipes from these plugins, but this does not work for most plugins, and by no means provides proper support for the feature. Support beyond this is not planned. Recipe Manager plugins are an outdated concept that very few plugins still use, and they aren't possible to properly support without very invasive EMI mixins - something I do not intend to use in this project.
Runtime Registry Changes
The JEI API supports modifying the recipe and ingredient registries at runtime (ie after plugin registration is complete). This concept is not compatible with EMI, and it is not a practice I want to support. As such, after IModPlugin.onRuntimeAvailable has been invoked, all APIs for runtime registry modifications will throw an IllegalStateException if invoked to avoid potential confusion.
JEI Code Re-use
The plan is to replace more of the JEI internals in future updates. However, some parts of JEI simply aren't worth re-implementing for various reasons. Regardless, enough of JEI has already been replaced in TMRV that I can confidently say:
- It wouldn't be feasible to achieve the same improvements over JEMI with mixins (at least sanely), and
- Enough of the JEI internals have been replaced or removed that I don't consider this unfair to JEI, especially given the fact that JEI's license explicitly allows doing this.
License
This project is licensed under OSL-3.0. For more information, see LICENSE.
Some code was copied from EMI and JEI in compliance with their copyright licenses. All modifications present in this project are licensed under the same license as the rest of this project, OSL-3.0.
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
下载 TooManyRecipeViewers
- 添加了异步插件加载功能
- 添加了配置文件
- 现在可以禁用插件
- 即使检测到重复的 EMI 插件,也可以强制插件完全加载
- 可以禁用异步加载(或通过覆盖配置仅对特定插件启用异步加载)
- 添加了对合成类别扩展的支持(这可能是 TMRV 能够合理支持的 JEI API 最后一个主要部分)
- 减少了烘焙后的内存占用
- 修复了物品、流体及大多数模组自定义成分类型的隐藏问题
- 进一步优化了整体系统稳定性,并进行了其他微调以提升用户体验
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
缓冲的原始输入和线程化的事件轮询
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
原版世界生成优化模组
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
评论 0
登录后参与评分
还没有评论,来抢沙发吧