게임 경로 설정¶
게임 파일이 저장되는 마인크래프트 디렉토리의 경로와 구조를 바꿀 수 있습니다.
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" : ""));
}
API References¶
Constructors¶
Constructors
public MinecraftPath()
기본 경로로 인스턴스를 초기화합니다.
new MinecraftPath(MinecraftPath.GetOSDefaultPath())
와 동일합니다.
public MinecraftPath(string p)
지정된 경로 p
로 인스턴스를 초기화합니다.
Initialize(p)
와 CreateDirs()
를 호출합니다.
Properties¶
Properties
BasePath
Type: string
루트 디렉터리 경로
Assets
Type: string
Library
Type: string
Versions
Type: string
Runtime
Type: string
MJava
의 기본 다운로드 경로
Resource
Type: string
구버전 마인크래프트에서 Assets 디렉터리로 사용하는 경로
Methods¶
Methods
public void CreateDirs()
BasePath
, Assets
, Library
, Versions
, Runtime
, Resource
디렉터리를 생성합니다.
public virtual string GetIndexFilePath(string assetId)
에셋 인덱스 파일 경로를 가져옵니다.
public virtual string GetAssetObjectPath(string assetId)
에셋 객체 디렉터리 경로를 가져옵니다.
public virtual string GetAssetLegacyPath(string assetId)
에셋 레거시 디렉터리 경로를 가져옵니다.
public virtual string GetVersionJarPath(string id)
클라이언트 jar 파일 경로를 가져옵니다.
public virtual string GetVersionJsonPath(string id)
클라이언트 json 파일 경로를 가져옵니다.
public virtual string GetNativePath(string id)
네이티브 디렉터리 경로를 가져옵니다. 네이티브 dll 파일들이 여기에 저장됩니다.
protected static string Dir(string path)
path
를 정규화하고 디렉터리를 생성합니다.
protected static string NormalizePath(string path)
path
를 정규화합니다. 상대 경로를 절대 경로로 변환하고 잘못된 디렉터리 구분자를 교체합니다. (Windows에서는 /
를 \
로 교체)