Description
# IU-IC2 Compatibility Patch
**Unofficial compatibility fix for Minecraft 1.7.10 — Industrial Upgrade 2.5.21 + IndustrialCraft 2 2.2.828**
Industrial Upgrade silently replaces IC2 electric storage blocks in the player's inventory with its own versions. A freshly crafted or `/give`-spawned IC2 MFE becomes an IU MFE on the next tick. The item IDs are not colliding — IU's tick handler replaces the whole `ItemStack`.
This patch stops that replacement and also restores IC2 recipe priority.

## The problem
A machine can look correct in the creative tab or in NEI, then change into a different item after it enters the inventory.
Typical example from a modpack:
| Before | After one tick |
|---|---|
| IC2 MFE `251:1` — 4,000,000 EU | IU MFE `2308:3` — 0 EU |
| IndustrialCraft 2 | Industrial Upgrade |
The IDs above are from one pack; **your IDs may be different**. The important part is that both items share the display name "MFE" but use different registry names and different item IDs.
The cause is in Industrial Upgrade:
```java
IUEventHandler.check(LivingUpdateEvent)
for each slot in player.inventory.mainInventory:
if (stack.getItem() instanceof IC2 ItemElectricBlock)
stack = new ItemStack(IU electricblock, 1, mappedMeta)
```
The mapping is:
| IC2 item | Replaced with |
|---|---|
| `IC2:blockElectric` meta 0 (BatBox) | `industrialupgrade:electricblock` meta 2 |
| `IC2:blockElectric` meta 1 (MFE) | `industrialupgrade:electricblock` meta 3 |
| `IC2:blockElectric` meta 2 (MFSU) | `industrialupgrade:electricblock` meta 4 |
| `IC2:blockElectric` meta 7 (CESU) | `industrialupgrade:electricblock` meta 5 |
| `IC2:blockChargepad` meta 0–3 | `industrialupgrade:BlockChargepad` meta 2–5 |
This runs on **both the client and the server**, every player tick. That is why:
- `/give` does not help — the item changes after it is given.
- Disabling NEI does not help — it is not a NEI issue.
- Fixing recipes does not help — the `ItemStack` itself is replaced.
- Installing the patch on only one side does not help — the other side keeps replacing it.

## What this patch does
### 1. Stops the inventory replacement
The 1.1 coremod removes only the `IUEventHandler.check(LivingUpdateEvent)` method from Industrial Upgrade. All other IU features — armor, flight, tools, machines, recipes — are left alone.
The coremod is version-specific: it targets the method signature in **Industrial Upgrade 2.5.21**.
### 2. Restores IC2 recipe priority
The patch moves every recipe whose output is in the `IC2:` namespace to the front of the crafting list. If an IU recipe and an IC2 recipe both match the same grid, the IC2 recipe wins.
### 3. Re-adds missing IC2 storage recipes
If another mod removes the IC2 BatBox / MFE / MFSU / CESU recipes, the patch adds the original-shaped recipes back.
### 4. Audits item IDs
On startup the patch checks for numeric item-ID collisions and prints them to the log. It does **not** change item IDs.

## Requirements
| Requirement | Version |
|---|---|
| Minecraft | 1.7.10 |
| Forge | 10.13.4.1614 (other 1.7.10 builds may work) |
| IndustrialCraft 2 | 2.2.828-experimental |
| Industrial Upgrade | 2.5.21 |
| Java | 8 |
**Environment: client and server both required.** This is not a server-only recipe patch. The replacement code runs on both sides.
## Installation
1. **Back up** your world, `config`, and `mods` folder.
2. Remove any older `IUIC2Patch-1.7.10-1.0.jar`.
3. Put `IUIC2Patch-1.7.10-1.1.jar` into:
- the client `mods` folder;
- the server `mods` folder.
4. Restart the client and the server.
5. Check the log for:
```text
[IUIC2Fix] Removing IUEventHandler.check (IC2 -> IU inventory conversion).
[IUIC2Patch] postInit: no numeric item-ID collisions detected.
[IUIC2Patch] postInit: moved … IC2-output recipes to the front …
```
6. Test in-game:
```text
/give <player> IC2:blockElectric 1 1
```
Press `F3 + H` and hover the item. It should stay `IC2:blockElectric` and should not turn into `industrialupgrade:electricblock` after a few seconds.
## Configuration
The first launch creates `config/iuic2patch.cfg`:
```text
general {
B:prioritizeIC2Recipes=true
B:restoreIC2StorageRecipes=true
B:removeIUStorageRecipes=false
}
diagnostics {
B:auditItemIds=true
B:verbose=false
}
```
- `prioritizeIC2Recipes` — move IC2-output recipes to the front.
- `restoreIC2StorageRecipes` — restore the four IC2 storage recipes if missing.
- `removeIUStorageRecipes` — remove IU's electricblock recipes; normally leave this off.
- `auditItemIds` — log numeric ID collisions.
- `verbose` — log every IU/IC2 item ID and moved recipe.
The coremod itself has no config toggle. Remove the jar to re-enable IU's original behavior.
## Compatibility and limitations
- Tested with **IC2 2.2.828-experimental** and **Industrial Upgrade 2.5.21** on Forge 1.7.10.
- The coremod targets an internal IU method; **other IU versions may not work**. Check the log for `[IUIC2Fix]` after updating IU.
- Existing items that were already converted to IU **will not automatically convert back**. They are valid IU items. Re-obtain the IC2 version with `/give` or the creative tab.
- The patch does not add items, blocks, textures, or world generation.
- The patch is designed for packs that want to keep IC2 and IU as separate, parallel tech trees. It does not merge their items or recipes.
## FAQ
**Is this an official IC2 or IU addon?**
No. It is an unofficial compatibility patch. It is not affiliated with or endorsed by the IC2 or Industrial Upgrade authors.
**Does it contain IC2 or IU code/assets?**
No. It contains only original patch code. It transforms one IU class at runtime and does not redistribute IC2 or IU.
**Can I install it only on the server?**
No. Both sides run the replacement logic. Install it on the client and the server.
**Will it work with an existing world?**
Yes. Back up the world first. Already-converted IU items stay IU.
**Can I use it in a modpack?**
Yes. A link back to this project is appreciated. Do not redistribute the IC2 or IU jars with it.
## Credits
- **IndustrialCraft 2** — the IC2 team.
- **Industrial Upgrade** — Denfop, ijo42, and contributors.
- This patch is unofficial and only fixes the inventory replacement and recipe priority described above.
## License
The patch source is distributed under the **GNU Affero General Public License v3.0 (AGPLv3)**, matching the license of Industrial Upgrade. The full license text is included in the source archive.
Source code and license: see the project's Source link / additional files.
---
## Screenshots
### Cover

### The bug in one picture

### Why recipe fixes alone cannot stop it

### Original in-game evidence


---
# 中文说明
**非官方兼容补丁,适用于 Minecraft 1.7.10、IC2 2.2.828-experimental、工业升级 2.5.21。**
工业升级的 `IUEventHandler.check` 会每 tick 扫描玩家背包,把 IC2 的 BatBox、MFE、MFSU、CESU 和充电座强制替换成工业升级的对应物品。所以 `/give`、创造栏拿、工作台合成之后,物品都会在下一 tick 变成 IU 版本。这不是物品 ID 冲突,也不是 NEI 或配方优先级问题。
1.1 版补丁做了两件事:
1. 用 coremod 只删除 `IUEventHandler.check` 这一个方法,停止背包替换;IU 的其他功能不受影响。
2. 保留配方修复:IC2 输出配方优先,并在缺失时补回 IC2 的四个储电配方。
**客户端和服务端都必须安装。** 只装一边,另一边仍会替换物品。
安装后日志应出现:
```text
[IUIC2Fix] Removing IUEventHandler.check (IC2 -> IU inventory conversion).
```
已经变成 IU 的旧物品不会自动变回 IC2;可以重新 `/give` 或从创造栏获取 IC2 版本。
---
## Source
Source
https://github.com/suyingqingcheng/iuic2patch
Release: https://github.com/suyingqingcheng/iuic2patch/releases/tag/v1.1.0



