@@ -3,6 +3,7 @@ import config from '../Config.js'
3
3
import { Store } from '../Store.js'
4
4
import { message } from '../Utils.js'
5
5
import type { BlockStateRegistry , VersionId } from './Schemas.js'
6
+ import { checkVersion } from './Schemas.js'
6
7
7
8
const CACHE_NAME = 'misode-v2'
8
9
const CACHE_LATEST_VERSION = 'cached_latest_version'
@@ -124,6 +125,9 @@ export async function fetchItemComponents(versionId: VersionId) {
124
125
console . debug ( `[fetchItemComponents] ${ versionId } ` )
125
126
const version = config . versions . find ( v => v . id === versionId ) !
126
127
const result = new Map < string , Map < string , unknown > > ( )
128
+ if ( ! checkVersion ( versionId , '1.20.5' ) ) {
129
+ return result
130
+ }
127
131
try {
128
132
const data = await cachedFetch < Record < string , Record < string , unknown > > > ( `${ mcmeta ( version , 'summary' ) } /item_components/data.min.json` )
129
133
for ( const [ id , components ] of Object . entries ( data ) ) {
@@ -267,11 +271,28 @@ async function loadImage(src: string) {
267
271
}
268
272
*/
269
273
274
+ interface DeprecatedInfo {
275
+ removed : string [ ]
276
+ renamed : Record < string , string >
277
+ }
278
+
270
279
export async function fetchLanguage ( versionId : VersionId , lang : string = 'en_us' ) {
271
280
const version = config . versions . find ( v => v . id === versionId ) !
272
281
await validateCache ( version )
273
282
try {
274
- return await cachedFetch < Record < string , string > > ( `${ mcmeta ( version , 'assets' ) } /assets/minecraft/lang/${ lang } .json` )
283
+ const translations = await cachedFetch < Record < string , string > > ( `${ mcmeta ( version , 'assets' ) } /assets/minecraft/lang/${ lang } .json` )
284
+ if ( checkVersion ( versionId , '1.21.2' ) ) {
285
+ const deprecated = await cachedFetch < DeprecatedInfo > ( `${ mcmeta ( version , 'assets' ) } /assets/minecraft/lang/deprecated.json` )
286
+ for ( const key of deprecated . removed ) {
287
+ delete translations [ key ]
288
+ }
289
+ for ( const [ oldKey , newKey ] of Object . entries ( deprecated . renamed ) ) {
290
+ const value = translations [ oldKey ]
291
+ delete translations [ oldKey ]
292
+ translations [ newKey ] = value
293
+ }
294
+ }
295
+ return translations
275
296
} catch ( e ) {
276
297
throw new Error ( `Error occured while fetching language: ${ message ( e ) } ` )
277
298
}
0 commit comments