Build resource pack zip and drop it into .minecraft
Add archiver dep (v7 — v8 dropped the function-style default export
that the @types still describe) and a new src/installer-rp/pack.ts
that assembles the resource pack tree under tempDir/resourcepack/
and zips it to %appdata%/.minecraft/resourcepacks/<key>_musicquiz.zip.
The tree matches Minecraft 1.21+ painting variant + custom sound
conventions:
pack.mcmeta pack_format 34,
supported 34..75
assets/musicquiz/sounds.json stream:true per track
assets/musicquiz/sounds/track_NN.ogg from tempDir/music
assets/musicquiz/textures/painting/cover_NN.png from tempDir/painting
Music NN.ogg is renamed to track_NN.ogg at copy time so the sound
event ids stay readable. The painting_variant JSON definitions are
intentionally NOT generated here — those live in the data pack and
are owned by /op/datapack on the website.
Wire step 2-4 of the install IPC to call buildResourcepackZip with
the now-populated music/painting temp dirs. Step 2-5 is now just a
log line since buildResourcepackZip writes directly to the final
path.
Verified by a node smoke test: tempDir of two stub ogg files plus
two 256x256 PNGs produces a valid zip with the expected entries
and UTF-8 Korean strings in pack.mcmeta description.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { ensureYtDlpExe } from './ytdlp.js'
|
||||
import { ensureFfmpegExe } from './ffmpeg.js'
|
||||
import { downloadMusicTrack } from './music.js'
|
||||
import { downloadImage, normalizeToCover, coverFileName } from './images.js'
|
||||
import { buildResourcepackZip } from './pack.js'
|
||||
|
||||
interface RpInstallerState {
|
||||
manifestUrl: string
|
||||
@@ -211,18 +212,21 @@ ipcMain.handle('rp:install:start', async (): Promise<{ resourcepackPath: string
|
||||
sendLog(`${i + 1}번 사진 완료: ${path.basename(outPath)}`)
|
||||
}
|
||||
|
||||
// 2-4. 리소스팩 zip 빌드
|
||||
sendLog('리소스팩 zip 빌드 중… (TODO)')
|
||||
// 2-4. 리소스팩 zip 빌드 (pack.mcmeta + sounds.json + 음악·이미지)
|
||||
throwIfCancelled()
|
||||
|
||||
// 2-5. %appdata%/.minecraft/resourcepacks/ 에 배치
|
||||
const resourcepackName = `${state.selectedKey}_musicquiz.zip`
|
||||
const resourcepackDir = path.join(getAppDataDir(), '.minecraft', 'resourcepacks')
|
||||
await fsp.mkdir(resourcepackDir, { recursive: true })
|
||||
const resourcepackPath = path.join(resourcepackDir, resourcepackName)
|
||||
// TODO: 실제 zip 파일을 위치시킴. 지금은 빈 placeholder.
|
||||
await fsp.writeFile(resourcepackPath, '', { flag: 'a' })
|
||||
sendLog(`리소스팩 zip 빌드 중… (${resourcepackName})`)
|
||||
await buildResourcepackZip({
|
||||
musicDir,
|
||||
paintingDir,
|
||||
packName: pack.name,
|
||||
workDir: tempRoot,
|
||||
outZipPath: resourcepackPath
|
||||
})
|
||||
|
||||
// 2-5. %appdata%/.minecraft/resourcepacks/ 에 배치 (위 빌드가 직접 outZipPath 에 저장)
|
||||
sendLog(`설치 완료: ${resourcepackPath}`)
|
||||
return { resourcepackPath }
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user