部分模组提供了 JEI 插件但未提供 EMI 插件,而 EMI 仍会通过其内置的兼容层读取 JEI 插件来显示这些配方。这通常能正常工作——除了那些由滚动网格小部件而非固定坐标放置槽位的配方。
这些槽位最终都会绘制在配方的左上角,彼此堆叠并覆盖在配方的输入项之上。如果你曾在 EMI 中打开过滤网(Strainer)配方,看到整个掉落表堆叠在输入物品上,那就是这个 Bug。
本模组修复了此问题。除此之外无任何变化:没有新增 UI,没有配置项,也没有添加或隐藏任何配方。
之前 / 之后
BenBenLaw 的 Strainers 将其掉落表置于一个 5×3 的滚动网格中。在没有本模组的情况下,所有这些输出项都会渲染在与输入槽相同的重叠位置上;有了本模组后,它们会按照配方要求的网格布局排列。
原因分析
EMI 的 JEI 兼容层将 JEI 的“添加槽位并让小部件稍后定位”方法实现为:
public IRecipeSlotBuilder addSlotToWidget(RecipeIngredientRole role, ISlottedWidgetFactory<?> widgetFactory) {
return addSlot(role, 0, 0);
}
这里忽略了小部件,导致所有槽位都落在 (0, 0) 处。本模组拦截了该调用,询问网格其放置位置及宽度,并将每个槽位放入下一个网格单元格——这与 JEI 自身的网格小部件所使用的定位方式相同。
任何使用滚动网格的 JEI 插件都能受益,而不仅仅是 Strainers。
要求
- Minecraft 1.21.1, NeoForge
- 同时安装了 EMI 和 JEI(本模组修补的代码路径仅在 EMI 读取 JEI 插件时存在)
- 仅限客户端——它在服务器上不起作用,服务器上也无需安装
已知限制
EMI 的配方面板不支持滚动,因此如果一个配方的输出项数量超过了网格预设的尺寸,它会继续向下延伸超出面板底部,而不是触发滚动。不过,滤网(Strainer)配方的内容量完全能够舒适地容纳在内。
Some mods ship a JEI plugin but no EMI plugin, and EMI shows those recipes anyway by reading the
JEI plugin through its built-in compatibility layer. That mostly works — except for recipes whose
slots are placed by a scrolling grid widget instead of by fixed coordinates.
Those slots all end up drawn in the top-left corner of the recipe, stacked on each other and on top
of the recipe's inputs. If you have ever opened a strainer recipe in EMI and seen the entire drop
table piled onto the input item, this is that bug.
This mod fixes it. Nothing else changes: no new UI, no config, no recipes added or hidden.
Before / after
BenBenLaw's Strainers puts its drop table in a 5×3 scrolling grid. Without this mod every one of
those outputs renders at the same spot over the input slots; with it, they lay out in the grid the
recipe asked for.
Why it happens
EMI's JEI-compat layer implements JEI's "add a slot and let a widget position it later" method as:
public IRecipeSlotBuilder addSlotToWidget(RecipeIngredientRole role, ISlottedWidgetFactory<?> widgetFactory) {
return addSlot(role, 0, 0);
}
The widget is ignored, so every slot lands at (0, 0). This mod intercepts that call, asks the grid
where it was placed and how wide it is, and puts each slot in the next grid cell — the same position
JEI's own grid widget would have used.
Any JEI plugin using a scroll grid benefits, not just Strainers.
Requirements
- Minecraft 1.21.1, NeoForge
- EMI and JEI both installed (the code path this patches only exists when EMI is reading JEI
plugins)
- Client side only — it does nothing on a server, and is not needed on one
Known limitation
EMI recipe panels do not scroll, so a recipe with more outputs than its grid was sized for keeps
flowing downward past the bottom of the panel instead of scrolling. Strainer recipes fit comfortably.
评论 0
登录后参与评分
还没有评论,来抢沙发吧