Skip to content

Commit efa3f79

Browse files
committed
Fix various bugs do to refactoring
1 parent 96dcb66 commit efa3f79

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

src/main/java/fr/catcore/modremapperapi/ModRemappingAPI.java

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import io.github.fabriccompatibiltylayers.modremappingapi.impl.ModRemappingAPIImpl;
44

5+
@Deprecated
56
public class ModRemappingAPI {
7+
@Deprecated
68
public static final boolean BABRIC = ModRemappingAPIImpl.BABRIC;
79
}

src/main/java/fr/catcore/modremapperapi/remapping/RemapUtil.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ private static void preloadClasses() {
311311
"io.github.fabriccompatibiltylayers.modremappingapi.impl.ModDiscoverer$1",
312312
"io.github.fabriccompatibiltylayers.modremappingapi.impl.ModEntry",
313313
"io.github.fabriccompatibiltylayers.modremappingapi.impl.remapper.resource.RefmapJson",
314-
"fr.catcore.modremapperapi.remapping.MapEntryType",
315314
"fr.catcore.modremapperapi.remapping.MappingBuilder",
316315
"fr.catcore.modremapperapi.remapping.MappingBuilder$Entry",
317316
"fr.catcore.modremapperapi.remapping.MappingBuilder$Type",
@@ -529,7 +528,7 @@ private static TinyRemapper makeRemapper(MappingTree... trees) {
529528
modRemapper.addRemapLibraries(libraries, FabricLoader.getInstance().getEnvironmentType());
530529

531530
for (RemapLibrary library : libraries) {
532-
Path libPath = CacheUtils.getLibraryPath(library.fileName);
531+
Path libPath = CacheUtils.getLibraryPath(MappingsUtilsImpl.getSourceNamespace()).resolve(library.fileName);
533532

534533
if (Files.exists(libPath)) {
535534
remapper.readClassPathAsync(libPath);

src/main/java/io/github/fabriccompatibiltylayers/modremappingapi/impl/ModDiscoverer.java

+25-17
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,19 @@ protected static void init(List<ModRemapper> modRemappers, boolean remapClassEdi
5353

5454
if (Files.exists(mainTempDir)) {
5555
FileUtils.emptyDir(mainTempDir);
56-
} else {
57-
try {
58-
Files.createDirectory(mainTempDir);
59-
} catch (IOException e) {
60-
throw new RuntimeException(e);
61-
}
56+
}
57+
58+
try {
59+
Files.createDirectory(mainTempDir);
60+
} catch (IOException e) {
61+
throw new RuntimeException(e);
6262
}
6363

6464
Map<Path, Path> modPaths = mods.stream()
6565
.filter(entry -> Files.exists(entry.original))
66-
.collect(Collectors.toMap(entry -> entry.original, entry -> entry.file));
66+
.collect(Collectors.groupingBy(entry -> entry.modId))
67+
.entrySet().stream()
68+
.collect(Collectors.toMap(entry -> entry.getValue().get(0).original, entry -> entry.getValue().get(0).file));
6769

6870
if (!remapClassEdits) {
6971
modPaths = excludeClassEdits(modPaths, mainTempDir);
@@ -145,8 +147,8 @@ private static Optional<ModEntry> discoverFolderMod(Path folder, Path destinatio
145147
return Optional.of(
146148
new DefaultModEntry(
147149
name,
148-
folder,
149-
destination
150+
destination,
151+
folder
150152
)
151153
);
152154
}
@@ -160,20 +162,26 @@ private static Optional<ModEntry> discoverFileMod(Path file, Path destinationFol
160162

161163
List<String> entries = FileUtils.listZipContent(file);
162164

165+
boolean found = false;
166+
163167
for (String entry : entries) {
164-
if (Objects.equals(entry, "/fabric.mod.json")) break;
168+
if (entry.contains("fabric.mod.json")) return Optional.empty();
165169

166170
if (entry.endsWith(".class")) {
167-
return Optional.of(
168-
new DefaultModEntry(
169-
modName,
170-
file,
171-
destinationFolder.resolve(fileName)
172-
)
173-
);
171+
found = true;
174172
}
175173
}
176174

175+
if (found) {
176+
return Optional.of(
177+
new DefaultModEntry(
178+
modName,
179+
destinationFolder.resolve(fileName),
180+
file
181+
)
182+
);
183+
}
184+
177185
return Optional.empty();
178186
}
179187

src/main/java/io/github/fabriccompatibiltylayers/modremappingapi/impl/utils/CacheUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CacheUtils {
1717
public static final Path MAIN_FOLDER = BASE_FOLDER
1818
.resolve(VersionHelper.MINECRAFT_VERSION)
1919
.resolve(VersionHelper.MOD_VERSION);
20-
public static final Path LIBRARY_FOLDER = BASE_FOLDER.resolve("libs");
20+
public static final Path LIBRARY_FOLDER = MAIN_FOLDER.resolve("libs");
2121

2222
public static Path getCachePath(String pathName) {
2323
return MAIN_FOLDER.resolve(pathName);

0 commit comments

Comments
 (0)