3131import net .fabricmc .mapping .tree .TinyTree ;
3232
3333public class PatchworkMappingService {
34- public static final TinyTree MAPPINGS = FabricLauncherBase .getLauncher ().getMappingConfiguration ().getMappings ();
35- public static final String INTERMEDIARY = "intermediary" ;
36- public static final String NAMED = "named" ;
34+ // We're technically messing with Loader's internal APIs here, if Loader ever gets a better mapping resolution system this class should be refactored.
35+ private static final TinyTree MAPPINGS = FabricLauncherBase .getLauncher ().getMappingConfiguration ().getMappings ();
36+ private static final String INTERMEDIARY = "intermediary" ;
37+ private static final String NAMED = "named" ;
3738
3839 private PatchworkMappingService () {
3940 // NO-OP
@@ -48,7 +49,7 @@ private PatchworkMappingService() {
4849 */
4950 @ Nonnull
5051 public static String remapName (INameMappingService .Domain domain , String name ) {
51- if (FabricLoader . getInstance (). getMappingResolver (). getCurrentRuntimeNamespace (). equals ( INTERMEDIARY )) {
52+ if (runtimeNamespaceIsIntermediary ( )) {
5253 return name ;
5354 }
5455
@@ -78,6 +79,10 @@ public static String remapName(INameMappingService.Domain domain, String name) {
7879 */
7980 @ Nonnull
8081 public static String remapNameFast (INameMappingService .Domain domain , Class <?> clazz , String name ) {
82+ if (runtimeNamespaceIsIntermediary ()) {
83+ return name ;
84+ }
85+
8186 ClassDef classDef = MAPPINGS .getDefaultNamespaceClassMap ().get (clazz .getName ());
8287 String remappedName = remapNameInternal (domain , classDef , name );
8388
@@ -92,8 +97,8 @@ public static String remapNameFast(INameMappingService.Domain domain, Class<?> c
9297 * @return The remapped name, or null if it couldn't be remapped.
9398 */
9499 @ Nullable
95- public static String remapNameInternal (INameMappingService .Domain domain , ClassDef classDef , String name ) {
96- if (FabricLoader . getInstance (). getMappingResolver (). getCurrentRuntimeNamespace (). equals ( INTERMEDIARY )) {
100+ private static String remapNameInternal (INameMappingService .Domain domain , ClassDef classDef , String name ) {
101+ if (runtimeNamespaceIsIntermediary ( )) {
97102 return name ;
98103 }
99104
@@ -111,4 +116,8 @@ public static String remapNameInternal(INameMappingService.Domain domain, ClassD
111116
112117 return null ;
113118 }
119+
120+ private static boolean runtimeNamespaceIsIntermediary () {
121+ return FabricLoader .getInstance ().getMappingResolver ().getCurrentRuntimeNamespace ().equals (INTERMEDIARY );
122+ }
114123}
0 commit comments