mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 16:35:39 +00:00
Skip encoding/decoding step when importing and downloading projects
This commit is contained in:
@@ -44,11 +44,13 @@ export function CustomizedPanel({ tab }: Props) {
|
||||
const entries = Object.entries(pack).flatMap(([type, files]) => {
|
||||
const prefix = `data/minecraft/${type}/`
|
||||
return [...files.entries()].map(([name, data]) => {
|
||||
return [prefix + name + '.json', stringifySource(JSON.stringify(data, null, 2), 'json')] as [string, string]
|
||||
const text = stringifySource(JSON.stringify(data, null, 2), 'json')
|
||||
return [prefix + name + '.json', new TextEncoder().encode(text)] as [string, Uint8Array]
|
||||
})
|
||||
})
|
||||
const pack_format = config.versions.find(v => v.id === version)!.pack_format
|
||||
entries.push(['pack.mcmeta', stringifySource(JSON.stringify({ pack: { pack_format, description: 'Customized world from misode.github.io' } }, null, 2), 'json')])
|
||||
const packMcmetaText = stringifySource(JSON.stringify({ pack: { pack_format, description: 'Customized world from misode.github.io' } }, null, 2), 'json')
|
||||
entries.push(['pack.mcmeta', new TextEncoder().encode(packMcmetaText)])
|
||||
const url = await writeZip(entries)
|
||||
download.current.setAttribute('href', url)
|
||||
download.current.setAttribute('download', 'customized.zip')
|
||||
|
||||
Reference in New Issue
Block a user