Skip to content

Commit efa0631

Browse files
committed
Make Interface sorting opt-in
1 parent 47f85c1 commit efa0631

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/net/minecraftforge/mergetool/ConsoleMerger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private static void merge(String[] args) {
7676
OptionSpec<Boolean> inject = parser.accepts("inject").withOptionalArg().ofType(Boolean.class).defaultsTo(true);
7777
OptionSpec<Void> data = parser.accepts("keep-data");
7878
OptionSpec<Void> meta = parser.accepts("keep-meta");
79+
OptionSpec<Void> sortInterfaces = parser.accepts("sort-interfaces");
7980
OptionSpec<AnnotationVersion> anno = parser.accepts("ann").withOptionalArg().ofType(AnnotationVersion.class).withValuesConvertedBy(AnnotationReader).defaultsTo(AnnotationVersion.API);
8081
OptionSpec<String> whitelist = parser.accepts("whitelist").withRequiredArg().ofType(String.class);
8182
OptionSpec<String> whitelistPkg = parser.accepts("whitelist-pkg").withRequiredArg().ofType(String.class);
@@ -109,6 +110,9 @@ private static void merge(String[] args) {
109110
if (options.has(bundled))
110111
merge.bundledServerJar();
111112

113+
if (options.has(sortInterfaces))
114+
merge.sortInterfaces();
115+
112116
Predicate<String> filter = null;
113117
if (options.has(whitelist) || options.has(whitelistMap)) {
114118
Set<String> classes = loadList(options.valuesOf(whitelist), options.valuesOf(whitelistMap));

src/main/java/net/minecraftforge/mergetool/Merger.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class Merger {
5959
private boolean copyData = false;
6060
private boolean keepMeta = false;
6161
private boolean bundledServerJar = false;
62+
private boolean sortInterfaces = false;
6263

6364
public Merger(File client, File server, File merged) {
6465
this.client = client;
@@ -111,6 +112,11 @@ public Merger bundledServerJar() {
111112
return this;
112113
}
113114

115+
public Merger sortInterfaces() {
116+
this.sortInterfaces = true;
117+
return this;
118+
}
119+
114120
public void process() throws IOException {
115121
try (ZipOutputStream outJar = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(this.merged)))) {
116122
Set<String> added = new HashSet<>();
@@ -349,8 +355,10 @@ private void processInterfaces(ClassNode cClass, ClassNode sClass) {
349355
}
350356
}
351357

352-
Collections.sort(cIntfs); //Sort things, we're in obf territory but should stabilize things.
353-
Collections.sort(sIntfs);
358+
if (sortInterfaces) {
359+
Collections.sort(cIntfs); //Sort things, we're in obf territory but should stabilize things.
360+
Collections.sort(sIntfs);
361+
}
354362

355363
if (this.annotation != null && !cOnly.isEmpty() || !sOnly.isEmpty()) {
356364
this.annotation.add(cClass, cOnly, sOnly);

0 commit comments

Comments
 (0)