Skip to content

Commit

Permalink
Fix classes' intermediary names not getting exported when no members …
Browse files Browse the repository at this point in the history
…with intermediary name are present
  • Loading branch information
NebelNidas committed May 31, 2023
1 parent 36bf998 commit e1408d4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/net/fabricmc/stitch/commands/GenState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));

Expand All @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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 {
Expand Down

0 comments on commit e1408d4

Please sign in to comment.