promotional bannermobile promotional banner

GTM JEI Startup Crash Fix

格雷科技与 JEI 兼容性修复;GregTech and JEI compatibility fix
1.png

1.png

2.png

2.png

Description

GregTech CEu Modern and JEI currently cannot be used together on NeoForge 1.21.1 — this mod fixes that.

Version mapping file: Please strictly follow this version mapping table when installing.-jei-/version-compatibility-matrix.md at main · sdfalt/-jei-

Without it, a GTM + JEI install either crashes on startup, or (if it starts) shows no GregTech recipe categories at all, with nothing in the log to explain why. Five separate problems, at five different points in the game lifecycle, are each intercepted at the stage where they occur.

### What it fixes

1. **Startup crash.** GregTech constructs its recipe-category icons during class initialization, which happens *before* JEI has handed it its runtime object — so the icon wrapper dereferences a null runtime and the game dies before reaching the registry phase. Fixed by returning a lazy placeholder icon that swaps itself for the real one when JEI is ready. No timing guesswork.
2. **No GregTech categories in JEI.** In this snapshot, GregTech's own category registration is commented out, *and* the first special-category registration can throw (JEI's newer category size validation) — while JEI's plugin caller swallows the exception. The method dies halfway, categories and recipes both vanish, and the log stays quiet. This mod replays the entire registration in GregTech's own order, isolating each category so one failure cannot take out the rest.
3. **Crash when opening a recipe page.** GregTech embeds ModularUI 3.3.1, which was compiled against an older JEI and writes to two `RecipeSlot` fields that no longer exist. The mod injects them back at the bytecode level so the accessors resolve. *(A stop-gap: the restored fields are written but not read — see the technical notes.)*
4. **Multiblock preview offset to the top-left in JEI.** The 3D preview sets the OpenGL viewport, which does not follow the GUI pose; JEI draws recipe pages via a pose translation that the viewport ignores. Fixed by reading the real page origin at draw time and adding it to the viewport calculation. Applied only inside JEI, only when non-zero.
5. **Controller "usable types" popup opening off-screen.** ModularUI's menu always opens downward and never asks how big the screen is; worse, it anchors to unscrolled coordinates. The menu is now flipped to the opposite side when it would overflow. When the situation cannot be resolved safely, the original behaviour is left untouched byte for byte.

### Requirements

- **Minecraft 1.21.1 on NeoForge**
- **GregTech CEu Modern — latest available snapshot.** This mod targets `8.0.0-SNAPSHOT`. Older releases do not contain the same code paths and are **not** supported.
- **JEI — a recent version.** The crash this mod works around is triggered in part by JEI's own category size validation, which older builds do not have. If you still crash with this mod installed, update JEI first.
- **Client side only.** Nothing is required on the server.

### Installation

Drop the JAR into your `mods` folder alongside GregTech CEu Modern and JEI. No configuration, no commands.

### Links

- Source & issues: <https://github.com/sdfalt/-jei-&gt;

### License

MIT. This mod patches GregTech CEu Modern and ModularUI at runtime; both are used under their own respective licenses.

---

**在 NeoForge 1.21.1 上,格雷科技现代版(GTM)现在无法和 JEI 一起用 —— 这个模组就是修这个的。**

不装它,GTM + JEI 的组合要么启动直接崩,要么(如果能启动)JEI 里根本看不到任何格雷配方分类,而且日志里不会告诉你为什么。这是分布在游戏生命周期不同阶段的五个独立问题,本模组在各自的阶段把它们逐个掐住。

### 修了什么

1. **启动崩溃。** 格雷在类静态初始化阶段就构造配方分类图标,而这个时机**早于** JEI 把运行时对象交给它 —— 于是图标包装类解引用了一个 null,游戏还没走到注册表阶段就没了。修法:返回一个惰性占位图标,JEI 就绪后自己换成真图标。不赌时机。
2. **JEI 里没有格雷分类。** 这个快照里格雷自己的主分类注册被注释掉了,而第一个特殊分类注册又可能抛异常(JEI 较新版本的分类宽高校验),偏偏 JEI 的插件调用器会把异常吞掉。方法体半路夭折,分类和配方一起消失,日志安安静静。本模组按格雷自己的顺序重放整套注册,每个分类独立隔离,坏一个不影响其余。
3. **一打开配方页就崩。** 格雷内嵌的 ModularUI 3.3.1 是对着旧版 JEI 编译的,往里写两个已经被删掉的 `RecipeSlot` 字段。本模组在字节码层面把字段补回去,让访问器能落地。(属于止血措施:补回的字段只写不读,详见技术文档。)
4. **JEI 里多方块 3D 结构图偏到左上角。** 那张预览图直接设置 OpenGL 视口,而视口不跟随 GUI 的位姿;JEI 恰恰是靠位姿平移来画配方页的。修法:在绘制现场读取页面真实原点,加进视口计算。只在 JEI 内、只在偏移非零时生效。
5. **控制器"可使用的类型"弹出菜单开出屏幕外。** ModularUI 的菜单永远朝下开、压根不问屏幕多大,而且锚的是没算滚动的坐标。现在会溢出时翻到按钮另一侧。判断不出来的情况一律保持原版,一个字节不改。

### 环境要求

- **Minecraft 1.21.1 + NeoForge**
- **格雷科技现代版(GTM):必须用最新的快照版。** 本模组针对 `8.0.0-SNAPSHOT`,旧版 release 不含相同的代码路径,**不受支持**。
- **JEI:请使用较新的版本。** 本模组所规避的崩溃,部分成因来自 JEI 自身的分类宽高校验,较旧的构建没有这套校验。如果你装了本模组仍然崩溃,**请先更新 JEI**。
- **仅客户端。** 服务端无需安装。

### 安装

把 JAR 丢进 `mods` 文件夹,和 GTM、JEI 放一起即可。无需配置,无需指令。

### 链接

- 源码与问题反馈:<https://github.com/sdfalt/-jei-&gt;

### 许可证

MIT。本模组在运行时对格雷科技现代版与 ModularUI 打补丁,两者各自遵循其原有许可证。

GTM JEI Startup Crash Fix Team

profile avatar
Owner
  • 1
    Projects
  • 79
    Downloads
Donate