Skip to content

Commit

Permalink
MappingConfiguration: Remove optimised merged v2 code path
Browse files Browse the repository at this point in the history
This was leaving the broken "intermediary, named, official"
namespace order from layered mappings. While it could've been
fixed there, the optimised code path also lacked some fixes
to enclosing classes from MappingsMerger, so it's better to
use the "vanilla" code from Fabric.
  • Loading branch information
Juuxel committed Jul 1, 2024
1 parent d29605c commit b1ed6a4
Showing 1 changed file with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.tools.ant.util.StringUtils;
import com.google.common.base.Stopwatch;
import com.google.gson.JsonObject;
import dev.architectury.loom.util.MappingOption;
import org.apache.tools.ant.util.StringUtils;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.jetbrains.annotations.Nullable;
Expand All @@ -69,8 +68,8 @@
import net.fabricmc.loom.util.ZipUtils;
import net.fabricmc.loom.util.service.ScopedSharedServiceManager;
import net.fabricmc.loom.util.service.SharedServiceManager;
import net.fabricmc.loom.util.srg.MCPReader;
import net.fabricmc.loom.util.srg.ForgeMappingsMerger;
import net.fabricmc.loom.util.srg.MCPReader;
import net.fabricmc.loom.util.srg.SrgNamedWriter;
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.format.MappingFormat;
Expand Down Expand Up @@ -334,12 +333,7 @@ private void storeMappings(Project project, SharedServiceManager serviceManager,
extractExtras(delegate.fs());
}

if (areMappingsMergedV2(baseTinyMappings)) {
// Architectury Loom Patch
// If a merged tiny v2 mappings file is provided
// Skip merging, should save a lot of time
Files.copy(baseTinyMappings, tinyMappings, StandardCopyOption.REPLACE_EXISTING);
} else if (areMappingsV2(baseTinyMappings)) {
if (areMappingsV2(baseTinyMappings)) {
// These are unmerged v2 mappings
IntermediateMappingsService intermediateMappingsService = IntermediateMappingsService.getInstance(serviceManager, project, minecraftProvider);

Expand Down Expand Up @@ -406,17 +400,6 @@ private static boolean areMappingsV2(Path path) throws IOException {
}
}

private static boolean areMappingsMergedV2(Path path) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(path)) {
reader.mark(4096); // == DETECT_HEADER_LEN
boolean isTinyV2 = MappingReader.detectFormat(reader) == MappingFormat.TINY_2_FILE;
reader.reset();
return isTinyV2 && MappingReader.getNamespaces(reader, MappingFormat.TINY_2_FILE).containsAll(Arrays.asList("named", "intermediary", "official"));
} catch (NoSuchFileException e) {
return false;
}
}

public static void extractMappings(Path jar, Path extractTo) throws IOException {
try (FileSystemUtil.Delegate delegate = FileSystemUtil.getJarFileSystem(jar)) {
extractMappings(delegate.fs(), extractTo);
Expand Down

0 comments on commit b1ed6a4

Please sign in to comment.