Skip to content

Commit 75b6192

Browse files
committed
Fix vanilla classes not being filtered out of mods
1 parent 4c5c343 commit 75b6192

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/context/ModDiscoverer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public void excludeClassEdits(List<ModCandidate> candidates, InternalCacheHandle
9090
var outputPath = tempDirectory.resolve(outputName);
9191

9292
if (Files.isDirectory(modPath)) {
93+
outputPath = tempDirectory.resolve(outputName + ".zip");
9394
FileUtils.zipFolder(modPath, outputPath);
9495
} else {
9596
Files.copy(modPath, outputPath);

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/context/ModRemmaperV2Context.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.io.ByteArrayInputStream;
1616
import java.io.IOException;
17+
import java.net.URISyntaxException;
1718
import java.nio.charset.StandardCharsets;
1819
import java.nio.file.Path;
1920
import java.util.*;
@@ -114,6 +115,16 @@ public List<ModRemapper> discoverMods(boolean remapClassEdits) {
114115
var config2Candidates = candidates.stream()
115116
.collect(Collectors.groupingBy(ModCandidate::getDiscovererConfig));
116117

118+
for (var entry : config2Candidates.entrySet()) {
119+
var config = entry.getKey();
120+
121+
try {
122+
config2Discoverer.get(config).excludeClassEdits(entry.getValue(), this.cacheHandler, this.mappingsRegistry);
123+
} catch (IOException | URISyntaxException e) {
124+
throw new RuntimeException(e);
125+
}
126+
}
127+
117128
for (var candidate : candidates) {
118129
mappingsRegistry.addModMappings(candidate.getPath());
119130
}

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/utils/FileUtils.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,29 @@ public static void emptyDir(Path dir) {
137137
}
138138
}
139139

140+
/* Define ZIP File System Properties in Map */
141+
private static final Map<String, String> ZIPPING_PROPERTIES = Map.of(
142+
/* We want to read an existing ZIP File, so we set this to False */
143+
"create", "true",
144+
/* Specify the encoding as UTF-8 */
145+
"encoding", "UTF-8"
146+
);
147+
140148
/**
141149
* @author moehreag
142150
*/
143151
@ApiStatus.Internal
144152
public static void zipFolder(Path in, Path out) throws IOException {
145-
try (var outFs = FileSystems.newFileSystem(out)) {
153+
try (var outFs = FileSystems.newFileSystem(out, ZIPPING_PROPERTIES)) {
146154
Files.walkFileTree(in, new SimpleFileVisitor<>(){
147155
@Override
148156
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) throws IOException {
149157
var outPath = outFs.getPath(in.relativize(file).toString());
150-
Files.createDirectories(outPath.getParent());
158+
159+
if (outPath.getParent() != null) {
160+
Files.createDirectories(outPath.getParent());
161+
}
162+
151163
Files.copy(file, outPath);
152164
return super.visitFile(file, attrs);
153165
}

0 commit comments

Comments
 (0)