Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Avoid loom removing <init> parameters #13

Merged
merged 2 commits into from Jun 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -47,4 +47,4 @@ Replace `QMoL_VERSION` in `build.gradle` with the version corresponding to the v
| - | - |
| 0.10 | 3.1.2 |
| 0.11.31- | 4.0.0 |
| 0.11.32+ | 4.2.0 |
| 0.11.32+ | 4.2.1 |
2 changes: 1 addition & 1 deletion build.gradle.kts
Expand Up @@ -7,7 +7,7 @@ plugins {

group = "org.quiltmc"
// Don't forget to update README.MD
version = "4.2.0"
version = "4.2.1"

repositories {
mavenCentral()
Expand Down
Expand Up @@ -21,12 +21,13 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Predicate;

import net.fabricmc.loom.configuration.providers.mappings.extras.unpick.UnpickLayer;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.mappingio.adapter.MappingNsCompleter;
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;
import net.fabricmc.mappingio.tree.MappingTree;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.util.GFileUtils;
Expand All @@ -43,7 +44,7 @@

@SuppressWarnings("UnstableApiUsage")
public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
private static final int HASH_CODE_VERSION_BASE = 1;
private static final int HASH_CODE_VERSION_BASE = 2;
private static final int HASH_CODE_VERSION_EXTRA_BITS = 8;
private static final int HASH_CODE_VERSION = (1 << HASH_CODE_VERSION_EXTRA_BITS) + HASH_CODE_VERSION_BASE;

Expand Down Expand Up @@ -132,7 +133,16 @@ public void visit(MappingVisitor mappingVisitor) throws IOException {
}
}

Tiny2Reader.read(new FileReader(intermediaryToQm), mappingVisitor);
if (mappingVisitor instanceof MappingTree mappingTree) {
// Complete missing intermediary names with official ones (i.e. <init>s) to avoid losing mappings
MemoryMappingTree tree = new MemoryMappingTree();
mappingTree.accept(tree);
Tiny2Reader.read(new FileReader(intermediaryToQm), tree);
tree.accept(new MappingNsCompleter(mappingVisitor, Map.of(MappingsNamespace.INTERMEDIARY.toString(), MappingsNamespace.OFFICIAL.toString())));
} else {
// Shouldn't happen, unless the impl changes to not use a MappingTree
Tiny2Reader.read(new FileReader(intermediaryToQm), mappingVisitor);
}
}

private void extractMappings(File dependency, File output) {
Expand Down