site: add video field and set volume default 0.5 in datapack SNBT
곡 SNBT 출력을 {volume:0.5, title, author, alias, description, video} 형식으로
변경(요청). video = MusicListEntry.url(유튜브 영상 주소). volume 기본값을
1.0 → 0.5 로 변경. 헤더 안내 주석도 새 형식에 맞춤.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -21,16 +21,18 @@ function aliasListSnbt(aliases: string[]): string {
|
|||||||
return `[${parts.join(',')}]`
|
return `[${parts.join(',')}]`
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 한 곡(MusicListEntry) → `{volume:1.0, title:"...", author:"...", alias:[...], description:"..."}` SNBT. */
|
/** 한 곡(MusicListEntry) → `{volume:0.5, title:"...", author:"...", alias:[...], description:"...", video:"..."}` SNBT. */
|
||||||
function entrySnbt(entry: MusicListEntry): string {
|
function entrySnbt(entry: MusicListEntry): string {
|
||||||
const title = escapeSnbtString(entry.title ?? '')
|
const title = escapeSnbtString(entry.title ?? '')
|
||||||
// launcher 의 artist → 데이터팩 SNBT 의 author. 빈 값은 빈 문자열로 그대로 둔다.
|
// launcher 의 artist → 데이터팩 SNBT 의 author. 빈 값은 빈 문자열로 그대로 둔다.
|
||||||
const author = escapeSnbtString(entry.artist ?? '')
|
const author = escapeSnbtString(entry.artist ?? '')
|
||||||
const alias = aliasListSnbt(entry.aliases ?? [])
|
const alias = aliasListSnbt(entry.aliases ?? [])
|
||||||
const description = escapeSnbtString(entry.description ?? '')
|
const description = escapeSnbtString(entry.description ?? '')
|
||||||
// launcher 가 생성하는 항목에는 volume 기본값 1.0 을 항상 넣는다.
|
// video = 곡의 유튜브 영상 주소(MusicListEntry.url).
|
||||||
|
const video = escapeSnbtString(entry.url ?? '')
|
||||||
|
// launcher 가 생성하는 항목에는 volume 기본값 0.5 를 항상 넣는다.
|
||||||
// 운영자는 생성된 mcfunction 에서 곡별로 직접 값을 바꿔 사용한다.
|
// 운영자는 생성된 mcfunction 에서 곡별로 직접 값을 바꿔 사용한다.
|
||||||
return `{volume:1.0, title:"${title}", author:"${author}", alias:${alias}, description:"${description}"}`
|
return `{volume:0.5, title:"${title}", author:"${author}", alias:${alias}, description:"${description}", video:"${video}"}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,11 +43,11 @@ function entrySnbt(entry: MusicListEntry): string {
|
|||||||
export function buildSongsMcfunction(list: PackList): string {
|
export function buildSongsMcfunction(list: PackList): string {
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
lines.push('# 곡 한 개 = 한 줄.')
|
lines.push('# 곡 한 개 = 한 줄.')
|
||||||
lines.push('# 필수 — title, author, alias, description')
|
lines.push('# 필수 — title, author, alias, description, video')
|
||||||
lines.push('# 선택 — volume (이 곡만의 /playsound 음량. 미지정시 init/config.mcfunction')
|
lines.push('# 선택 — volume (이 곡만의 /playsound 음량. 미지정시 init/config.mcfunction')
|
||||||
lines.push('# 의 audio.volume 사용)')
|
lines.push('# 의 audio.volume 사용)')
|
||||||
lines.push('# 곡 순서가 리소스팩의 track_NN / cover_NN 인덱스와 1:1 매칭된다.')
|
lines.push('# 곡 순서가 리소스팩의 track_NN / cover_NN 인덱스와 1:1 매칭된다.')
|
||||||
lines.push('# 예) {volume:1.0, title:"Quiet Song", author:"...", alias:[...], description:"..."}')
|
lines.push('# 예) {volume:0.5, title:"Quiet Song", author:"...", alias:[...], description:"...", video:"..."}')
|
||||||
lines.push('data modify storage mq:main songs set value []')
|
lines.push('data modify storage mq:main songs set value []')
|
||||||
for (const entry of list.music) {
|
for (const entry of list.music) {
|
||||||
lines.push(`data modify storage mq:main songs append value ${entrySnbt(entry)}`)
|
lines.push(`data modify storage mq:main songs append value ${entrySnbt(entry)}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user