게임 경로 설정¶
게임 파일이 저장되는 마인크래프트 디렉토리의 경로와 구조를 바꿀 수 있습니다.
Example¶
마인크래프트 경로를 ./games 로 설정하고 기본 디렉터리 구조로 MinecraftLauncher 를 초기화합니다.
// initialize launcher with the specific path
MinecraftPath myPath = new MinecraftPath("./games");
MinecraftLauncher launcher = new MinecraftLauncher(myPath);
// myPath.BasePath : ./games
// myPath.Library : ./games/libraries
// myPath.Resource : ./games/resources
// myPath.Versions : ./games/versions
// myPath.GetVersionJarPath("1.16.5") : ./games/versions/1.16.5/1.16.5.jar
// myPath.GetIndexFilePath("1.16.5") : ./games/assets/indexes/1.16.5.json
기본 디렉터리 경로¶
MinecraftPath.GetOSDefaultPath() 메서드나 new MinecraftPath() 으로 기본 디렉터리 경로를 가져올 수 있습니다.
기본 디렉터리 경로는 다음과 같습니다:
- Windows:
%appdata%\.minecraft - Linux:
$HOME/.minecraft - macOS:
$HOME/Library/Application Support/minecraft
기본 디렉터리 구조¶
/ (MinecraftPath.BasePath)
├── assets/ (MinecraftPath.Assets)
│ ├── indexes/
│ │ └── {asset_id}.json (MinecraftPath.GetIndexFilePath(assetId))
│ ├── objects/ (MinecraftPath.GetAssetObjectPath(assetId))
│ └── virtual/
│ └── legacy/ (MinecraftPath.GetAssetLegacyPath(assetId))
├── libraries/ (MinecraftPath.Library)
├── resources/ (MinecraftPath.Resource)
├── runtime/ (MinecraftPath.Runtime)
└── versions/ (MinecraftPath.Versions)
└── {version_name}/
├── {version_name}.jar (MinecraftPath.GetVersionJarPath("version_name"))
├── {version_name}.json (MinecraftPath.GetVersionJsonPath("version_name"))
└── natives/ (MinecraftPath.GetNativePath("version_name"))
커스텀 디렉터리 구조 만들기¶
커스텀 디렉터리 구조를 만들기 위한 두가지 방법이 있습니다.
속성 설정하기¶
경로 속성을 바꾸세요. 모든 속성은 Properties 에서 확인하세요
Info
반드시 절대 경로만 입력하세요.
MinecraftPath myPath = new MinecraftPath();
myPath.Libraries = myPath.BasePath + "/commons/libs";
myPath.Versions = myPath.BasePath + "/commons/versions";
myPath.Assets = MinecraftPath.GetOSDefaultPath() + "/assets";
상속¶
MinecraftPath 를 상속받는 클래스를 만들고 메서드를 오버라이드하세요. 모든 메서드 (CreateDirs, NormalizePath, 등등) 은 Methods 에서 확인하세요.
Info
상대 경로를 인수로 받은 경우 반드시 절대 경로로 바꾸어 저장하세요.
class MyMinecraftPath : MinecraftPath
{
public MyMinecraftPath(string p)
{
BasePath = NormalizePath(p);
Library = NormalizePath(BasePath + "/libs");
Versions = NormalizePath(BasePath + "/vers");
Resource = NormalizePath(BasePath + "/resources");
Runtime = NormalizePath(BasePath + "/java");
Assets = NormalizePath(BasePath + "/assets");
CreateDirs();
}
public override string GetVersionJarPath(string id)
=> NormalizePath($"{Versions}/{id}/{id}.jar");
public override string GetVersionJsonPath(string id)
=> NormalizePath($"{Versions}/{id}/{id}.json");
public override string GetNativePath(string id)
=> NormalizePath($"{Versions}/{id}/natives");
// 주의: 이 경로를 바꾸면 마인크래프트에서 인식하지 못할수도 있습니다
public override string GetIndexFilePath(string assetId)
=> NormalizePath($"{Assets}/indexes/{assetId}.json");
// 주의: 이 경로를 바꾸면 마인크래프트에서 인식하지 못할수도 있습니다
public override string GetAssetObjectPath(string assetId)
=> NormalizePath($"{Assets}/objects");
// 주의: 이 경로를 바꾸면 마인크래프트에서 인식하지 못할수도 있습니다
public override string GetAssetLegacyPath(string assetId)
=> NormalizePath($"{Assets}/virtual/legacy");
// 주의: 이 경로를 바꾸면 마인크래프트에서 인식하지 못할수도 있습니다
public override string GetLogConfigFilePath(string configId)
=> NormalizePath($"{Assets}/log_configs/{configId}" + (!configId.EndsWith(".xml") ? ".xml" : ""));
}