27
27
import java .nio .file .Path ;
28
28
import java .nio .file .Paths ;
29
29
import java .util .*;
30
+ import java .util .function .Supplier ;
30
31
import java .util .stream .Collectors ;
31
32
import java .util .zip .ZipEntry ;
32
33
import java .util .zip .ZipInputStream ;
@@ -57,12 +58,31 @@ public static void init(List<io.github.fabriccompatibiltylayers.modremappingapi.
57
58
}
58
59
}
59
60
61
+ for (ModRemapper remapper : remappers ) {
62
+ Optional <String > sourceNamespace = remapper .getSourceNamespace ();
63
+
64
+ if (sourceNamespace .isPresent ()) {
65
+ MappingsUtilsImpl .setSourceNamespace (sourceNamespace .get ());
66
+ break ;
67
+ }
68
+ }
69
+
70
+ for (ModRemapper remapper : remappers ) {
71
+ Optional <Supplier <InputStream >> mappings = remapper .getExtraMapping ();
72
+
73
+ if (mappings .isPresent ()) {
74
+ MappingsUtilsImpl .loadExtraMappings (mappings .get ().get ());
75
+ break ;
76
+ }
77
+ }
78
+
60
79
MINECRAFT_TREE = MappingsUtilsImpl .getMinecraftMappings ();
80
+
61
81
LOADER_TREE = generateMappings ();
62
82
MappingsUtilsImpl .addMappingsToContext (LOADER_TREE );
63
83
64
84
for (MappingTree .ClassMapping classView : MINECRAFT_TREE .getClasses ()) {
65
- String className = classView .getName ("official" );
85
+ String className = classView .getName (MappingsUtilsImpl . getSourceNamespace () );
66
86
67
87
if (className != null ) {
68
88
MC_CLASS_NAMES .add (className );
@@ -504,7 +524,7 @@ private static TinyRemapper makeRemapper(MappingTree... trees) {
504
524
}
505
525
506
526
for (MappingTree tree : trees ) {
507
- builder .withMappings (MappingsUtilsImpl .createProvider (tree , "official" , MappingsUtils .getTargetNamespace ()));
527
+ builder .withMappings (MappingsUtilsImpl .createProvider (tree , MappingsUtilsImpl . getSourceNamespace () , MappingsUtils .getTargetNamespace ()));
508
528
}
509
529
510
530
MRAApplyVisitor preApplyVisitor = new MRAApplyVisitor ();
@@ -530,7 +550,11 @@ private static TinyRemapper makeRemapper(MappingTree... trees) {
530
550
531
551
TinyRemapper remapper = builder .build ();
532
552
533
- MappingsUtils .addMinecraftJar (remapper );
553
+ try {
554
+ MappingsUtils .addMinecraftJar (remapper );
555
+ } catch (IOException e ) {
556
+ throw new RuntimeException (e );
557
+ }
534
558
535
559
for (ModRemapper modRemapper : remappers ) {
536
560
List <RemapLibrary > libraries = new ArrayList <>();
@@ -562,11 +586,11 @@ private static void remapFiles(TinyRemapper remapper, Map<Path, Path> paths) {
562
586
List <OutputConsumerPath .ResourceRemapper > resourceRemappers = new ArrayList <>(NonClassCopyMode .FIX_META_INF .remappers );
563
587
resourceRemappers .add (new RefmapRemapper ());
564
588
565
- applyRemapper (remapper , paths , outputConsumerPaths , resourceRemappers );
589
+ applyRemapper (remapper , paths , outputConsumerPaths , resourceRemappers , true );
566
590
}
567
591
568
592
@ ApiStatus .Internal
569
- public static void applyRemapper (TinyRemapper remapper , Map <Path , Path > paths , List <OutputConsumerPath > outputConsumerPaths , List <OutputConsumerPath .ResourceRemapper > resourceRemappers ) {
593
+ public static void applyRemapper (TinyRemapper remapper , Map <Path , Path > paths , List <OutputConsumerPath > outputConsumerPaths , List <OutputConsumerPath .ResourceRemapper > resourceRemappers , boolean analyzeMapping ) {
570
594
try {
571
595
Map <Path , InputTag > tagMap = new HashMap <>();
572
596
@@ -593,7 +617,7 @@ public static void applyRemapper(TinyRemapper remapper, Map<Path, Path> paths, L
593
617
Constants .MAIN_LOGGER .debug ("Done 1!" );
594
618
}
595
619
596
- MappingsUtilsImpl .completeMappingsFromTr (remapper .getEnvironment ());
620
+ if ( analyzeMapping ) MappingsUtilsImpl .completeMappingsFromTr (remapper .getEnvironment ());
597
621
} catch (Exception e ) {
598
622
remapper .finish ();
599
623
outputConsumerPaths .forEach (o -> {
0 commit comments