重要许可声明
以任何形式使用本项目,即表示您“明确同意”本项目的许可条款(见 许可证),并确认我(本项目作者)已履行许可中规定的义务,即“在现有情况下尽合理努力获得接收者对本许可条款的明确同意”。
TooManyRecipeViewers
TooManyRecipeViewers(简称 TMRV)是一个兼容层,允许在使用 EMI 的同时运行 JEI 插件,而无需安装 JEI。该模组由 Nolij 编写。
您需要安装 EMI 才能使用此模组。
为何选择 TMRV 而非 EMI+JEI(即 JEMI)?
JEMI 是内置于 EMI 中的一个兼容层,旨在通过重度依赖 JEI 内部机制,使 JEI 插件大部分能在 EMI 中正常工作。其设计尽可能简洁,并依赖于 JEI 先处理配方数据,然后再将其导入 EMI。
TMRV 与 JEMI 不同——它旨在完全替换 JEI API(注意:TMRV 包含部分未修改的 JEI 内部实现,详见 JEI 代码复用)。在可行的情况下,TMRV 将 JEI API 替换为直接映射到 EMI API 的方式,而不是加载整个 JEI 注册表并在事后进行查询。这种方法具有多种优势,包括更高效地利用系统资源,但同时也是一种权衡,因为 TMRV 的方案使得维护工作远比 JEMI 复杂得多。JEMI 有意采用这种设计,以便让 EMI 的开发能够专注于改进 EMI 本身,这也是我完全支持的做法。
TL;DR:TMRV 比 JEMI 高效得多,但代价是维护 TMRV 需要 付出远大于 JEMI 的努力,并且不应期望 EMI 会为此投入如此多的精力来支持一个在设计时有意未引用的 API。能开箱即用加载 JEI 插件就已经值得庆幸了——这本身也耗费了不少功夫。
话虽如此,TMRV 相比 JEMI 主要有两大优势:
1. 插件兼容性
TMRV 对 JEI API 的覆盖比 JEMI 更完善(唯一例外——参见 已知的 API 限制)。截至撰写本文时,这包括:
- 对内置配方类型的更好转换(JEMI 仅支持合成和信息配方类型;TMRV 支持所有 JEI 内置配方类型)
- 支持原料/搜索别名
createRecipeExtras支持
2. 效率
使用 TMRV,你进入世界的速度将始终快于使用 JEMI。这是因为 JEI 插件的初始化会阻塞世界加载——在所有 JEI 插件初始化完成之前,你无法开始游戏。而 EMI 会在世界加载之后异步加载插件。
这意味着,即使 TMRV 加载 JEI 插件的速度比 JEI 更慢(事实并非如此,TMRV 加载它们的速度明显更快——见基准测试),使用 TMRV 的世界加载速度也始终快于使用 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 | 对比 | |
|---|---|---|---|
| Craftoria | 1582ms(世界加载前 5ms,世界加载后 1577ms) | 11036ms(世界加载前 10000ms,世界加载后 1036ms) | -9454毫秒(世界加载前为-9995毫秒,世界加载后为+541毫秒) |
| ATM10 | 4951毫秒(世界加载前为3毫秒,世界加载后为4948毫秒) | 20132毫秒(世界加载前为15550毫秒,世界加载后为4582毫秒) | -15181毫秒(世界加载前为-15547毫秒,世界加载后为+366毫秒) |
| Finality: Omnia | 3010毫秒(世界加载前为6毫秒,世界加载后为3004毫秒) | 6354毫秒(世界加载前为4425毫秒,世界加载后为1929毫秒) | -3344毫秒(世界加载前为-4419毫秒,世界加载后为+1075毫秒) |
内存使用量
| TMRV | JEMI | 对比 | |
|---|---|---|---|
| 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 配置文件,并且没有计划支持它们。
配方管理器插件
JEI API 支持“配方管理器插件”(Recipe Manager Plugins)。这些插件允许模组控制自身的配方注册表,并在运行时自行处理配方查找。
TMRV 将尝试从这些插件中提取配方,但这并不适用于大多数插件,也远未提供对该功能的完整支持。除此之外不再计划提供支持。配方管理器插件是一个过时的概念,目前仅有极少数插件仍在使用;若不使用侵入性极强的 EMI mixins,则无法对其进行完善的支持——而这正是我无意在此项目中采用的方案。
运行时注册表更改
JEI API 支持在运行时(即插件注册完成后)修改配方和物品注册表。这一概念与 EMI 不兼容,且我不希望支持这种做法。因此,在 IModPlugin.onRuntimeAvailable 被调用后,所有用于运行时注册表修改的 API 如果再次被调用,都将抛出 IllegalStateException,以避免潜在的混淆。
JEI 代码复用
计划在未来的更新中替换更多 JEI 的内部实现。然而,出于各种原因,JEI 的某些部分不值得重新实现。无论如何,TMRV 中已有足够多的 JEI 内部实现被替换,因此我可以自信地说:
- 通过 mixins 实现对 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 (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
下载 TooManyRecipeViewers (TMRV)
- 添加了异步插件加载功能
- 添加了配置文件
- 现在可以禁用插件
- 即使检测到重复的 EMI 插件,也可以强制插件完全加载
- 可以禁用异步加载(或通过覆盖配置仅对特定插件启用异步)
- 添加了对合成类别扩展的支持(这可能是 TMRV 能够合理支持的 JEI API 中最后一个主要部分)
- 减少了烘焙后的内存占用
- 修复了物品、流体以及大多数模组自定义成分类型的隐藏问题
- 进一步优化了整体系统稳定性,并进行了其他 minor 调整以提升用户体验
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧