Resolve pack_format from the pack's mcVersion
The previous hardcoded pack_format 34 + supported_formats 34..75
covered 1.21 through 1.21.11 only, so a pack generated for the
current latest (26.1.2 → format 84) was rejected as outdated.
Add src/installer-rp/packFormat.ts with a 1.21 → 26.2 lookup table
from the Minecraft wiki and resolveResourcePackFormat() that returns
{matched, format}. Unknown mcVersion falls back to the table's most
recent entry, with a log line warning the user.
Plumb mcVersion through the load → install flow:
- rp:packs:load now also fetches /manifest/<key>.json alongside
/file/list/<key>.json and runs it through the existing
normalizePackDefinition so the editor and the installer agree on
the mcVersion shape. Pack manifest load failures fall back to an
empty mcVersion (which then triggers the latest-format fallback).
- RpFetchedPack carries mcVersion; the install handler hands it to
buildResourcepackZip.
- buildResourcepackZip drops the constant pack_format / supported_
formats and uses the resolved format both as pack_format and as
the {min,max} of supported_formats. Each pack is thus pinned to
exactly the MC version it was authored for.
- The renderer's pack card now shows "마인크래프트 <version>" in
the small line so the user can confirm before installing.
Verified locally: pack.mcmeta generated for mcVersion "1.21",
"1.21.6", "26.1.2", and the bogus "99.9.9" produce pack_format
34 / 63 / 84 / 86 (last falls back to the table tail) respectively.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
44
src/installer-rp/packFormat.ts
Normal file
44
src/installer-rp/packFormat.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// Minecraft Java Edition 버전 → resource pack format 번호.
|
||||
// 출처: https://minecraft.wiki/w/Pack_format (수동 동기화).
|
||||
// 1.21.9 부터는 minor 버전(예: 69.0)이 도입됐지만 JSON Number 로 0 차이는
|
||||
// 표현되지 않으므로 정수만 사용한다.
|
||||
const TABLE: Array<readonly [string, number]> = [
|
||||
['1.21', 34],
|
||||
['1.21.1', 34],
|
||||
['1.21.2', 42],
|
||||
['1.21.3', 42],
|
||||
['1.21.4', 46],
|
||||
['1.21.5', 55],
|
||||
['1.21.6', 63],
|
||||
['1.21.7', 64],
|
||||
['1.21.8', 64],
|
||||
['1.21.9', 69],
|
||||
['1.21.10', 69],
|
||||
['1.21.11', 75],
|
||||
['26.1', 84],
|
||||
['26.1.1', 84],
|
||||
['26.1.2', 84],
|
||||
['26.2', 86]
|
||||
]
|
||||
|
||||
/** 테이블에서 마지막(=최신) 항목의 포맷. 알 수 없는 mcVersion 에 대한 폴백. */
|
||||
export const LATEST_KNOWN_FORMAT: number = TABLE[TABLE.length - 1][1]
|
||||
|
||||
export interface ResolvedFormat {
|
||||
/** 매칭된 mcVersion 키 (없으면 null). */
|
||||
matched: string | null
|
||||
/** pack.mcmeta 에 들어갈 pack_format 값. */
|
||||
format: number
|
||||
}
|
||||
|
||||
/**
|
||||
* mcVersion 문자열 ("1.21.6", "26.1.2", …) 에서 pack_format 을 찾는다.
|
||||
* 정확히 일치하는 게 있으면 그 값, 없으면 가장 최근 알려진 포맷을 폴백.
|
||||
*/
|
||||
export function resolveResourcePackFormat(mcVersion: string): ResolvedFormat {
|
||||
const key = (mcVersion || '').trim()
|
||||
for (const [v, f] of TABLE) {
|
||||
if (v === key) return { matched: v, format: f }
|
||||
}
|
||||
return { matched: null, format: LATEST_KNOWN_FORMAT }
|
||||
}
|
||||
Reference in New Issue
Block a user