Skip to content

Commit

Permalink
Allow alternate mapping namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Jul 13, 2024
1 parent 7e26bed commit 2c4ae6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public class BuiltinProperties {
public static final String MCMETA_VERSION = "architectury.mcmeta.version";
public static final String PLATFORM_NAME = "architectury.platform.name";
public static final String PLATFORM_PACKAGE = "architectury.platform.package";
public static final String FORGE_PRODUCTION_NAMESPACE = "architectury.forge.production_namespace";
public static final String NEOFORGE_LIKE_REMAPS = "architectury.neoforge.forgelike_remaps";
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class FixForgeMixin implements AssetEditTransformer {

@Override
public void doEdit(TransformerContext context, FileAccess output) throws Exception {
String productionNamespace = System.getProperty(BuiltinProperties.FORGE_PRODUCTION_NAMESPACE, "srg");
Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
List<String> mixinConfigs = new ArrayList<>();
String refmap = System.getProperty(BuiltinProperties.REFMAP_NAME);
Expand Down Expand Up @@ -110,7 +111,7 @@ public void doEdit(TransformerContext context, FileAccess output) throws Excepti
@Nullable
public String mapClass(String value) {
Mapped classDef = srgMap.get(value);
return classDef == null ? null : classDef.getName("srg");
return classDef == null ? null : classDef.getName(productionNamespace);
}

@Override
Expand All @@ -120,10 +121,10 @@ public String mapMethod(@Nullable String className, String methodName, String me
Mapped mapped;
if (className != null) {
mapped = srgMap.get(className + " " + methodId);
if (mapped != null) return mapped.getName("srg");
if (mapped != null) return mapped.getName(productionNamespace);
}
mapped = srgMap.get(methodId);
return mapped == null ? null : mapped.getName("srg");
return mapped == null ? null : mapped.getName(productionNamespace);
}

@Override
Expand All @@ -133,10 +134,10 @@ public String mapField(@Nullable String className, String fieldName, String fiel
Mapped mapped;
if (className != null) {
mapped = srgMap.get(className + " " + fieldId);
if (mapped != null) return mapped.getName("srg");
if (mapped != null) return mapped.getName(productionNamespace);
}
mapped = srgMap.get(fieldId);
return mapped == null ? null : mapped.getName("srg");
return mapped == null ? null : mapped.getName(productionNamespace);
}
}) {
@Override
Expand Down

0 comments on commit 2c4ae6d

Please sign in to comment.