@@ -2,7 +2,7 @@ import { Identifier } from 'deepslate'
22import { route } from 'preact-router'
33import { useCallback , useEffect , useMemo , useRef , useState } from 'preact/hooks'
44import 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'
66import { useModal } from '../../contexts/Modal.jsx'
77import { useSpyglass } from '../../contexts/Spyglass.jsx'
88import { useFocus } from '../../hooks/useFocus.js'
@@ -17,6 +17,7 @@ import { ProjectCreation } from './ProjectCreation.jsx'
1717import { ProjectDeletion } from './ProjectDeletion.jsx'
1818
1919export 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` )
0 commit comments