Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/gtexpert/core/GTExpertMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ";" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<FieldNode> fieldIterator = classNode.fields.iterator();
boolean fieldRemoved = false;

while (fieldIterator.hasNext()) {
FieldNode field = fieldIterator.next();
if ("craftingList".equals(field.name)) {
Expand All @@ -48,25 +48,63 @@ private byte[] patchMixinDualityInterface(byte[] classBytes) {
GTELog.logger
.info("Removing @Shadow craftingList field from NAE2 MixinDualityInterface");
fieldIterator.remove();
fieldRemoved = true;
modified = true;
break;
}
}
}
}
}

if (fieldRemoved) {
// Remove or modify methods that reference craftingList
Iterator<MethodNode> 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<AbstractInsnNode> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<IRecipe> event) {
NAE2ItemsRecipe.init();
Expand Down