Skip to content

Commit

Permalink
small code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Jun 1, 2024
1 parent 6fd344e commit 26a9ccb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
32 changes: 18 additions & 14 deletions src/main/java/fr/catcore/modremapperapi/utils/MappingsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ public static void addMinecraftJar(TinyRemapper remapper) throws IOException {
"intermediary",
"official"
);

if (!MappingsUtilsImpl.isSourceNamespaceObf()) {
classPath = getMinecraftJar(
Arrays.asList(
classPath
),
"official",
MappingsUtilsImpl.getSourceNamespace()
);
}

remapper.readClassPathAsync(
!Objects.equals(MappingsUtilsImpl.getSourceNamespace(), "official") ?
getMinecraftJar(
Arrays.asList(
classPath
),
"official",
MappingsUtilsImpl.getSourceNamespace()
) : classPath
);
remapper.readClassPathAsync(classPath);
} catch (IOException e) {
throw new RuntimeException("Failed to populate default remap classpath", e);
}
Expand Down Expand Up @@ -160,11 +161,14 @@ public static void addMinecraftJar(TinyRemapper remapper) throws IOException {
Object realmsJar = share.get("fabric-loader:inputRealmsJar");

if (realmsJar instanceof Path) list.add((Path) realmsJar);

Path[] classPath = list.toArray(new Path[0]);

if (!MappingsUtilsImpl.isSourceNamespaceObf()) {
classPath = getMinecraftJar(list, "official", MappingsUtilsImpl.getSourceNamespace());
}

for (Path path :
!Objects.equals(MappingsUtilsImpl.getSourceNamespace(), "official") ?
getMinecraftJar(list, "official", MappingsUtilsImpl.getSourceNamespace())
: list.toArray(new Path[0])) {
for (Path path : classPath) {
Constants.MAIN_LOGGER.debug("Appending '%s' to remapper classpath", path);
remapper.readClassPathAsync(path);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.fabriccompatibiltylayers.modremappingapi.impl;

import fr.catcore.modremapperapi.utils.Constants;
import fr.catcore.modremapperapi.utils.MappingsUtils;
import fr.catcore.wfvaio.WhichFabricVariantAmIOn;
import io.github.fabriccompatibiltylayers.modremappingapi.api.MappingUtils;
import io.github.fabriccompatibiltylayers.modremappingapi.impl.utils.MappingTreeHelper;
Expand Down Expand Up @@ -85,6 +86,10 @@ public static void loadExtraMappings(InputStream stream) {
}
}

public static boolean isSourceNamespaceObf() {
return Objects.equals(sourceNamespace, "official");
}

@ApiStatus.Internal
public static MemoryMappingTree loadMappings(InputStream stream) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
Expand Down Expand Up @@ -220,7 +225,7 @@ public static IMappingProvider createProvider(MappingTree mappings, String from,

@ApiStatus.Internal
public static void initializeMappingTree(MappingVisitor mappingVisitor) throws IOException {
initializeMappingTree(mappingVisitor, getSourceNamespace(), "intermediary");
initializeMappingTree(mappingVisitor, getSourceNamespace(), MappingsUtils.getTargetNamespace());
}

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
Expand Down

0 comments on commit 26a9ccb

Please sign in to comment.