From e1408d441116600c7d5d3de5f99290326621176d Mon Sep 17 00:00:00 2001 From: NebelNidas Date: Wed, 31 May 2023 14:01:15 +0200 Subject: [PATCH] Fix classes' intermediary names not getting exported when no members with intermediary name are present --- .../java/net/fabricmc/stitch/commands/GenState.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/fabricmc/stitch/commands/GenState.java b/src/main/java/net/fabricmc/stitch/commands/GenState.java index a76bbcf..542abc2 100644 --- a/src/main/java/net/fabricmc/stitch/commands/GenState.java +++ b/src/main/java/net/fabricmc/stitch/commands/GenState.java @@ -447,6 +447,7 @@ private String getMethodName(ClassStorage storageOld, ClassStorage storageNew, J private MappingTree addClass(JarClassEntry c, ClassStorage storageOld, ClassStorage storage, String prefix) throws IOException { String cName = ""; String origPrefix = prefix; + boolean anyIntermediaries = false; if (!needsIntermediaryName(storage, c)) { cName = c.getName(); @@ -487,12 +488,13 @@ private MappingTree addClass(JarClassEntry c, ClassStorage storageOld, ClassStor if (cName != null && !cName.contains("class_")) { System.out.println(cName + " is now " + (cName = next(c, "class"))); prefix = origPrefix; + anyIntermediaries = true; } else if (cName == null) { cName = next(c, "class"); + anyIntermediaries = true; } } - boolean wroteAnyIntermediaries = false; MemoryMappingTree mappingTree = new MemoryMappingTree(); mappingTree.visitNamespaces(official, Arrays.asList(intermediary)); @@ -503,7 +505,7 @@ private MappingTree addClass(JarClassEntry c, ClassStorage storageOld, ClassStor String fName = getFieldName(storage, c, f); if (fName != null || writeAll) { - wroteAnyIntermediaries = true; + anyIntermediaries = true; if (fName == null) fName = f.getName(); } @@ -517,7 +519,7 @@ private MappingTree addClass(JarClassEntry c, ClassStorage storageOld, ClassStor String mName = getMethodName(storageOld, storage, c, m); if (mName != null || writeAll) { - wroteAnyIntermediaries = true; + anyIntermediaries = true; if (mName == null) mName = m.getName(); } @@ -532,11 +534,11 @@ private MappingTree addClass(JarClassEntry c, ClassStorage storageOld, ClassStor if (ccMappingTree != null) { ccMappingTree.accept(mappingTree); - wroteAnyIntermediaries = true; + anyIntermediaries = true; } } - return wroteAnyIntermediaries || writeAll ? mappingTree : null; + return anyIntermediaries || writeAll ? mappingTree : null; } public void prepareRewrite(File oldMappings) throws IOException {