Skip to content

Commit

Permalink
Allow using MRAPI in dev workspace once again.
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Jun 1, 2024
1 parent 2e4e042 commit 860814a
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/main/java/fr/catcore/modremapperapi/utils/MappingsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static String getNativeNamespace() {
}

public static String getTargetNamespace() {
return !FabricLoader.getInstance().isDevelopmentEnvironment() ? "intermediary" : FabricLoader.getInstance().getMappingResolver().getCurrentRuntimeNamespace();
return FabricLoader.getInstance().getMappingResolver().getCurrentRuntimeNamespace();
}

public static MappingTree loadMappings(Reader reader) {
Expand Down Expand Up @@ -60,10 +60,6 @@ public static IMappingProvider createProvider(MappingTree mappings) {
return MappingsUtilsImpl.createProvider(mappings, getNativeNamespace(), getTargetNamespace());
}

private static IMappingProvider createBackwardProvider(MappingTree mappings) {
return MappingsUtilsImpl.createProvider(mappings, getTargetNamespace(), "official");
}

private static Path[] getMinecraftJar(List<Path> sourcePaths, String src, String target) throws IOException {
Path[] originalClassPath = sourcePaths.toArray(new Path[0]);

Expand Down Expand Up @@ -109,7 +105,28 @@ private static Path[] getMinecraftJar(List<Path> sourcePaths, String src, String
public static void addMinecraftJar(TinyRemapper remapper) throws IOException {
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
try {
remapper.readClassPathAsync(getMinecraftJar(getRemapClasspath(), getTargetNamespace(), "official"));
Path[] classPath = getMinecraftJar(
Arrays.asList(
getMinecraftJar(
getRemapClasspath(),
getTargetNamespace(),
"intermediary"
)
),
"intermediary",
"official"
);

remapper.readClassPathAsync(
!Objects.equals(MappingsUtilsImpl.getSourceNamespace(), "official") ?
getMinecraftJar(
Arrays.asList(
classPath
),
"official",
MappingsUtilsImpl.getSourceNamespace()
) : classPath
);
} catch (IOException e) {
throw new RuntimeException("Failed to populate default remap classpath", e);
}
Expand Down

0 comments on commit 860814a

Please sign in to comment.