From f67e69047dcc0ccc077a1a7869986016c9a4b7c6 Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 1 Sep 2025 19:16:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?NAE2=E3=81=AE=E7=B5=86=E5=89=B5=E8=86=8F?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E4=BF=AE=E6=AD=A3=E3=82=92?= =?UTF-8?q?=E5=8F=96=E3=82=8A=E8=BE=BC=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/gtexpert/core/GTExpertMod.java | 2 +- .../core/core/NAE2PatchTransformer.java | 62 +++++++++++++++---- .../integration/nae2/AE2FCIntegration.java | 28 +++++++++ .../core/integration/nae2/NAE2Module.java | 7 +++ 4 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/github/gtexpert/core/integration/nae2/AE2FCIntegration.java diff --git a/src/main/java/com/github/gtexpert/core/GTExpertMod.java b/src/main/java/com/github/gtexpert/core/GTExpertMod.java index fa40a1dd..b4cc6b0b 100644 --- a/src/main/java/com/github/gtexpert/core/GTExpertMod.java +++ b/src/main/java/com/github/gtexpert/core/GTExpertMod.java @@ -38,9 +38,9 @@ dependencies = GTInternalTags.DEP_VERSION_STRING + "required-after:" + Mods.Names.MIXINBOOTER + "@[10.5,);" + "required-after:" + Mods.Names.GREGICALITY_MULTIBLOCKS + ";" + "required-after:" + Mods.Names.APPLIED_ENERGISTICS2 + "@[v0.56.7,);" + - "required-after:" + Mods.Names.NEEVES_AE2 + ";" + "required-after:" + Mods.Names.AE2_FLUID_CRAFTING + ";" + "after:" + Mods.Names.GREGTECH_WOOD_PROCESSING + ";" + "after:" + Mods.Names.IMPLOSION_NO_BOMB + ";" + "after:" + Mods.Names.GREGTECH_FOOD_OPTION + ";" + "after:" + Mods.Names.AE_ADDITIONS + ";" + + "after:" + Mods.Names.AE2_FLUID_CRAFTING + ";" + "after:" + Mods.Names.NEEVES_AE2 + ";" + "after:" + Mods.Names.EXTRA_CPUS + ";" + "after:" + Mods.Names.ENDER_CORE + ";" + "after:" + Mods.Names.ENDER_IO + ";" + "after:" + Mods.Names.ENDER_ENDERGY + ";" + "after:" + Mods.Names.ENDER_MACHINES + ";" + "after:" + Mods.Names.ENDER_CONDUITS + ";" + diff --git a/src/main/java/com/github/gtexpert/core/core/NAE2PatchTransformer.java b/src/main/java/com/github/gtexpert/core/core/NAE2PatchTransformer.java index e1669cf6..3e2d3bcd 100644 --- a/src/main/java/com/github/gtexpert/core/core/NAE2PatchTransformer.java +++ b/src/main/java/com/github/gtexpert/core/core/NAE2PatchTransformer.java @@ -6,15 +6,15 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; import com.github.gtexpert.core.api.util.GTELog; /** - * ASM Transformer to patch NAE2's MixinDualityInterface by removing the problematic craftingList field. - * This implements the diff change that removes the @Shadow craftingList field from the mixin. + * ASM Transformer to patch NAE2's MixinDualityInterface by removing the problematic craftingList field + * and any methods that reference it. This fixes compatibility issues with newer AE2 versions + * where the craftingList field no longer exists. */ public class NAE2PatchTransformer implements IClassTransformer { @@ -28,16 +28,16 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) private byte[] patchMixinDualityInterface(byte[] classBytes) { try { - GTELog.logger.info("Patching NAE2 MixinDualityInterface to remove craftingList field"); + GTELog.logger.info("Patching NAE2 MixinDualityInterface to remove craftingList references"); ClassReader classReader = new ClassReader(classBytes); ClassNode classNode = new ClassNode(); classReader.accept(classNode, 0); + boolean modified = false; + // Remove the craftingList field Iterator fieldIterator = classNode.fields.iterator(); - boolean fieldRemoved = false; - while (fieldIterator.hasNext()) { FieldNode field = fieldIterator.next(); if ("craftingList".equals(field.name)) { @@ -48,7 +48,7 @@ private byte[] patchMixinDualityInterface(byte[] classBytes) { GTELog.logger .info("Removing @Shadow craftingList field from NAE2 MixinDualityInterface"); fieldIterator.remove(); - fieldRemoved = true; + modified = true; break; } } @@ -56,17 +56,55 @@ private byte[] patchMixinDualityInterface(byte[] classBytes) { } } - if (fieldRemoved) { + // Remove or modify methods that reference craftingList + Iterator methodIterator = classNode.methods.iterator(); + while (methodIterator.hasNext()) { + MethodNode method = methodIterator.next(); + + // Check if this is an injected method that might reference craftingList + if (method.name.contains("injectInventoryChange") || + method.name.contains("handler$")) { + + // Remove any GETFIELD instructions that reference craftingList + if (method.instructions != null) { + boolean methodModified = false; + Iterator insnIterator = method.instructions.iterator(); + + while (insnIterator.hasNext()) { + AbstractInsnNode insn = insnIterator.next(); + + if (insn.getOpcode() == Opcodes.GETFIELD || insn.getOpcode() == Opcodes.PUTFIELD) { + FieldInsnNode fieldInsn = (FieldInsnNode) insn; + if ("craftingList".equals(fieldInsn.name)) { + GTELog.logger.info( + "Found reference to craftingList in method {}, removing the method entirely", + method.name); + methodIterator.remove(); + modified = true; + methodModified = true; + break; + } + } + } + + if (methodModified) { + continue; + } + } + } + } + + if (modified) { ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(classWriter); GTELog.logger.info("Successfully patched NAE2 MixinDualityInterface"); return classWriter.toByteArray(); } else { - GTELog.logger.info("craftingList field not found or already removed in MixinDualityInterface"); + GTELog.logger.info("No craftingList references found in MixinDualityInterface"); } } catch (Exception e) { - GTELog.logger.error("Failed to patch NAE2 MixinDualityInterface: " + e.getMessage(), e); + GTELog.logger.error("Failed to patch NAE2 MixinDualityInterface: {}", e.getMessage(), e); } return classBytes; diff --git a/src/main/java/com/github/gtexpert/core/integration/nae2/AE2FCIntegration.java b/src/main/java/com/github/gtexpert/core/integration/nae2/AE2FCIntegration.java new file mode 100644 index 00000000..f1598f6a --- /dev/null +++ b/src/main/java/com/github/gtexpert/core/integration/nae2/AE2FCIntegration.java @@ -0,0 +1,28 @@ +package com.github.gtexpert.core.integration.nae2; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Optional; + +import com.glodblock.github.loader.FCBlocks; +import com.glodblock.github.loader.FCItems; + +import co.neeve.nae2.NAE2; +import co.neeve.nae2.common.registration.definitions.Upgrades; + +public class AE2FCIntegration { + + public static void postInit() { + Upgrades upgrades = NAE2.definitions().upgrades(); + + if (upgrades.autoComplete().isEnabled()) + registerUpgradeFc(Upgrades.UpgradeType.AUTO_COMPLETE); + if (upgrades.gregtechCircuit().isEnabled()) + registerUpgradeFc(Upgrades.UpgradeType.GREGTECH_CIRCUIT); + } + + @Optional.Method(modid = "nae2") + private static void registerUpgradeFc(Upgrades.UpgradeType upgrade) { + upgrade.registerItem(new ItemStack(FCBlocks.DUAL_INTERFACE), 1); + upgrade.registerItem(new ItemStack(FCItems.PART_DUAL_INTERFACE), 1); + } +} diff --git a/src/main/java/com/github/gtexpert/core/integration/nae2/NAE2Module.java b/src/main/java/com/github/gtexpert/core/integration/nae2/NAE2Module.java index 09dbcb9a..e904909f 100644 --- a/src/main/java/com/github/gtexpert/core/integration/nae2/NAE2Module.java +++ b/src/main/java/com/github/gtexpert/core/integration/nae2/NAE2Module.java @@ -2,6 +2,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import com.github.gtexpert.core.api.GTEValues; import com.github.gtexpert.core.api.modules.GTEModule; @@ -19,6 +20,12 @@ description = "Neeve's AE2 Integration Module") public class NAE2Module extends GTEIntegrationSubmodule { + @Override + public void postInit(FMLPostInitializationEvent event) { + if (Mods.NeevesAE2.isModLoaded()) + AE2FCIntegration.postInit(); + } + @Override public void registerRecipesLowest(RegistryEvent.Register event) { NAE2ItemsRecipe.init(); From 8f3ded1d78cbfad830769887548d897c686a7bb9 Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 1 Sep 2025 20:25:17 +0900 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c9b7bf..77064520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.5.1 +- Incorporated the patch fix for NAE2 [#335](https://github.com/GTModpackTeam/GTExpert-Core/pull/335) + - Drop required dependencies: NAE2 1.6.4 and AE2FC 2.6.6-r + +* * * + # 2.5.0 - Bump version to MixinBooter v10 [#334](https://github.com/GTModpackTeam/GTExpert-Core/pull/334) - Updated MixinBooter from v9.4 to v10.6