Fix mojmap package names for realms and math

dev/0.11
Charlotte Som 2022-02-04 17:53:12 +00:00
parent 94ce38068c
commit 71c28bbcd0
2 changed files with 32 additions and 0 deletions

View File

@ -60,6 +60,8 @@ public record MojangMappingLayer(MinecraftVersionMeta.Download clientDownload,
printMappingsLicense(clientMappings); printMappingsLicense(clientMappings);
mappingVisitor = new MojangPackageFixingMappingVisitor(mappingVisitor);
// Filter out field names matching the pattern // Filter out field names matching the pattern
DstNameFilterMappingVisitor nameFilter = new DstNameFilterMappingVisitor(mappingVisitor, SYNTHETIC_NAME_PATTERN); DstNameFilterMappingVisitor nameFilter = new DstNameFilterMappingVisitor(mappingVisitor, SYNTHETIC_NAME_PATTERN);

View File

@ -0,0 +1,30 @@
package net.fabricmc.loom.configuration.providers.mappings.mojmap;
import net.fabricmc.mappingio.MappedElementKind;
import net.fabricmc.mappingio.MappingVisitor;
import net.fabricmc.mappingio.adapter.ForwardingMappingVisitor;
import java.io.IOException;
/*
* This is temporary, since currently using the Quilt mappings layered on top of mojmap
* crashes the game due to a conflict in mapped packages for anonymous inner classes.
*
* The problematic Mojang packages are replaced with their Quilt counterparts and the
* remapped game then properly works.
*/
public class MojangPackageFixingMappingVisitor extends ForwardingMappingVisitor {
public MojangPackageFixingMappingVisitor(MappingVisitor next) {
super(next);
}
@Override
public void visitDstName(MappedElementKind targetKind, int namespace, String name) throws IOException {
if (targetKind == MappedElementKind.CLASS)
name = name
.replace("com/mojang/realmsclient/", "net/minecraft/client/realms/")
.replace("com/mojang/math/", "net/minecraft/util/math/");
super.visitDstName(targetKind, namespace, name);
}
}