Skip to content

Commit 7ceb74f

Browse files
committed
Fix #652 add pack.mcmeta when downloading project zip
1 parent 22d35ef commit 7ceb74f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/app/components/generator/ProjectPanel.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Identifier } from 'deepslate'
22
import { route } from 'preact-router'
33
import { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'
44
import config from '../../Config.js'
5-
import { DRAFT_PROJECT, getProjectRoot, useLocale, useProject } from '../../contexts/index.js'
5+
import { DRAFT_PROJECT, getProjectRoot, useLocale, useProject, useVersion } from '../../contexts/index.js'
66
import { useModal } from '../../contexts/Modal.jsx'
77
import { useSpyglass } from '../../contexts/Spyglass.jsx'
88
import { useFocus } from '../../hooks/useFocus.js'
@@ -17,6 +17,7 @@ import { ProjectCreation } from './ProjectCreation.jsx'
1717
import { ProjectDeletion } from './ProjectDeletion.jsx'
1818

1919
export function ProjectPanel() {
20+
const { version } = useVersion()
2021
const { locale } = useLocale()
2122
const { showModal } = useModal()
2223
const { projects, project, projectUri, setProjectUri, changeProject } = useProject()
@@ -54,6 +55,12 @@ export function ProjectPanel() {
5455
const data = await client.fs.readFile(projectRoot + e)
5556
return [e, data] as [string, Uint8Array]
5657
}))
58+
if (!zipEntries.some(e => e[0] === 'pack.mcmeta')) {
59+
const packFormat = config.versions.find(v => v.id === version)!.pack_format
60+
const packMcmeta = { pack: { description: project.name, pack_format: packFormat } }
61+
const data = new TextEncoder().encode(JSON.stringify(packMcmeta, null, 2))
62+
zipEntries.push(['pack.mcmeta', data])
63+
}
5764
const url = await writeZip(zipEntries)
5865
download.current.setAttribute('href', url)
5966
download.current.setAttribute('download', `${project.name.replaceAll(' ', '_')}.zip`)

src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"id": "1.21.4",
168168
"dynamic": true,
169169
"name": "1.21.4",
170-
"pack_format": 58,
170+
"pack_format": 61,
171171
"show": true
172172
}
173173
],

0 commit comments

Comments
 (0)