Skip to content

Commit 1ec58cb

Browse files
committed
Fix NAE2 MixinDualityInterface
1 parent 2287c27 commit 1ec58cb

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.7.8
2+
- Fix NAE2 MixinDualityInterface craftingList compatibility with AE2-UEL
3+
4+
* * *
5+
16
# 2.7.7
27
- Drop BQu Mixin [#363](https://github.com/GTModpackTeam/GTExpert-Core/pull/363)
38
- Fix conflict ImplosionRecipe [#364](https://github.com/GTModpackTeam/GTExpert-Core/pull/364)

buildscript.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ modGroup = com.github.gtexpert.core
77

88
# Version of your mod.
99
# This field can be left empty if you want your mod's version to be determined by the latest git tag instead.
10-
modVersion = 2.7.7-beta
10+
modVersion = 2.7.8-beta
1111

1212
# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
1313
includeMCVersionJar = true

src/main/java/com/github/gtexpert/core/core/NAE2PatchTransformer.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import com.github.gtexpert.core.api.util.GTELog;
1313

1414
/**
15-
* ASM Transformer to patch NAE2's MixinDualityInterface by removing the problematic craftingList field
16-
* and any methods that reference it. This fixes compatibility issues with newer AE2 versions
17-
* where the craftingList field no longer exists.
15+
* ASM Transformer to patch NAE2's MixinDualityInterface by removing the @Shadow craftingList field
16+
* and replacing methods that reference it with no-ops. This fixes compatibility issues with newer
17+
* AE2 versions where the craftingList field no longer exists, while preserving Mixin injection points.
1818
*/
1919
public class NAE2PatchTransformer implements IClassTransformer {
2020

@@ -65,30 +65,32 @@ private byte[] patchMixinDualityInterface(byte[] classBytes) {
6565
if (method.name.contains("injectInventoryChange") ||
6666
method.name.contains("handler$")) {
6767

68-
// Remove any GETFIELD instructions that reference craftingList
68+
// Check for any GETFIELD/PUTFIELD instructions that reference craftingList
6969
if (method.instructions != null) {
70-
boolean methodModified = false;
70+
boolean hasCraftingListRef = false;
7171
Iterator<AbstractInsnNode> insnIterator = method.instructions.iterator();
72-
7372
while (insnIterator.hasNext()) {
7473
AbstractInsnNode insn = insnIterator.next();
75-
7674
if (insn.getOpcode() == Opcodes.GETFIELD || insn.getOpcode() == Opcodes.PUTFIELD) {
7775
FieldInsnNode fieldInsn = (FieldInsnNode) insn;
7876
if ("craftingList".equals(fieldInsn.name)) {
79-
GTELog.logger.info(
80-
"Found reference to craftingList in method {}, removing the method entirely",
81-
method.name);
82-
methodIterator.remove();
83-
modified = true;
84-
methodModified = true;
77+
hasCraftingListRef = true;
8578
break;
8679
}
8780
}
8881
}
8982

90-
if (methodModified) {
91-
continue;
83+
if (hasCraftingListRef) {
84+
GTELog.logger.info(
85+
"Found reference to craftingList in method {}, replacing with no-op",
86+
method.name);
87+
method.instructions.clear();
88+
if (method.tryCatchBlocks != null) {
89+
method.tryCatchBlocks.clear();
90+
}
91+
method.localVariables = null;
92+
method.instructions.add(new InsnNode(Opcodes.RETURN));
93+
modified = true;
9294
}
9395
}
9496
}

0 commit comments

Comments
 (0)