Fix record signatures based on data provided by mappings. (#507)

Reads "extras/record_signatures.json" from mappings jar, just works with yarn.

Mojmap:

```
mappings loom.layered {
   officialMojangMappings()
   signatureFix("net.fabricmc:yarn:21w38a+build.9:v2")
}
```
This commit is contained in:
modmuss50
2021-09-28 10:38:11 +01:00
committed by GitHub
parent 7d2dad6e46
commit 676a498e0c
17 changed files with 347 additions and 46 deletions

View File

@@ -28,6 +28,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import com.google.common.collect.ImmutableMap;
@@ -59,10 +60,10 @@ public final class TinyRemapperHelper {
}
public static TinyRemapper getTinyRemapper(Project project, String fromM, String toM) throws IOException {
return getTinyRemapper(project, fromM, toM, false);
return getTinyRemapper(project, fromM, toM, false, (builder) -> { });
}
public static TinyRemapper getTinyRemapper(Project project, String fromM, String toM, boolean fixRecords) throws IOException {
public static TinyRemapper getTinyRemapper(Project project, String fromM, String toM, boolean fixRecords, Consumer<TinyRemapper.Builder> builderConsumer) throws IOException {
LoomGradleExtension extension = LoomGradleExtension.get(project);
MemoryMappingTree mappingTree = extension.getMappingsProvider().getMappings();
@@ -72,7 +73,7 @@ public final class TinyRemapperHelper {
int intermediaryNsId = mappingTree.getNamespaceId(MappingsNamespace.INTERMEDIARY.toString());
return TinyRemapper.newRemapper()
TinyRemapper.Builder builder = TinyRemapper.newRemapper()
.withMappings(create(mappingTree, fromM, toM, true))
.withMappings(out -> JSR_TO_JETBRAINS.forEach(out::acceptClass))
.renameInvalidLocals(true)
@@ -84,8 +85,10 @@ public final class TinyRemapperHelper {
}
return next;
})
.build();
});
builderConsumer.accept(builder);
return builder.build();
}
public static Path[] getMinecraftDependencies(Project project) {