Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Feb 27, 2024
1 parent 1565691 commit 2177dd1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/fabricmc/loader/api/FabricLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ static FabricLoader getInstance() {
File getGameDirectory();

/**
* Get the current directory for temporary files.
* Get the current directory for temporary files for a particular mod.
*
* @param modId The ID of the mod to get the cache directory for
* @return the cache directory
*/
Path getCacheDir();
Path getCacheDir(String modId);

/**
* Get the current directory for game configuration files.
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public final class FabricLoaderImpl extends net.fabricmc.loader.FabricLoader {
public static final String VERSION = "0.15.7";
public static final String MOD_ID = "fabricloader";

// Relative to game dir
private static final String MOD_CACHE_DIR = ".cache";
private static final String MOD_CONFIG_DIR = "config";

public static final String CACHE_DIR_NAME = ".fabric"; // relative to game dir
private static final String PROCESSED_MODS_DIR_NAME = "processedMods"; // relative to loader cache dir
public static final String REMAPPED_JARS_DIR_NAME = "remappedJars"; // relative to loader cache dir
private static final String TMP_DIR_NAME = "tmp"; // relative to loader cache dir
Expand Down Expand Up @@ -131,10 +136,10 @@ public void setGameProvider(GameProvider provider) {
setGameDir(provider.getLaunchDirectory());
}

public void setGameDir(Path gameDir) {
private void setGameDir(Path gameDir) {
this.gameDir = gameDir;
this.cacheDir = gameDir.resolve(".cache");
this.configDir = gameDir.resolve("config");
this.cacheDir = gameDir.resolve(MOD_CACHE_DIR);
this.configDir = gameDir.resolve(MOD_CONFIG_DIR);
}

@Override
Expand Down Expand Up @@ -176,11 +181,11 @@ private Path ensureDirExists(Path path, String name) {
}

/**
* @return The game instance's temporary file directory.
* @return The game instance's temporary file directory for a particular mod.
*/
@Override
public Path getCacheDir() {
return ensureDirExists(cacheDir, "cache");
public Path getCacheDir(String modId) {
return ensureDirExists(cacheDir.resolve(modId), "cache");
}

/**
Expand Down Expand Up @@ -243,7 +248,7 @@ private void setup() throws ModResolutionException {

dumpModList(modCandidates);

Path loaderCacheDir = getCacheDir().resolve(MOD_ID);
Path loaderCacheDir = gameDir.resolve(CACHE_DIR_NAME);
Path outputDir = loaderCacheDir.resolve(PROCESSED_MODS_DIR_NAME);

// runtime mod remapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,7 @@ public static Map<String, Path> deobfuscate(Map<String, Path> inputFileMap, Stri
}

private static Path getDeobfJarDir(Path gameDir, String gameId, String gameVersion) {
FabricLoaderImpl loader = FabricLoaderImpl.INSTANCE;

loader.setGameDir(gameDir);
Path ret = loader.getCacheDir().resolve(FabricLoaderImpl.MOD_ID).resolve(FabricLoaderImpl.REMAPPED_JARS_DIR_NAME);

Path ret = gameDir.resolve(FabricLoaderImpl.CACHE_DIR_NAME).resolve(FabricLoaderImpl.REMAPPED_JARS_DIR_NAME);
StringBuilder versionDirName = new StringBuilder();

if (!gameId.isEmpty()) {
Expand Down

0 comments on commit 2177dd1

Please sign in to comment.