Skip to content

Commit 13ea2ec

Browse files
committed
Fixed #67
1 parent ab0db40 commit 13ea2ec

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/exporting.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ async function exportPredicate(
237237
ajSettings: aj.Settings
238238
) {
239239
console.groupCollapsed('Export Predicate Model')
240-
const projectName = safeFunctionName(ajSettings.projectName)
241240

242241
const predicateJSON = {
243242
parent: 'item/generated',
@@ -249,6 +248,7 @@ async function exportPredicate(
249248
includedRigs: {},
250249
},
251250
}
251+
252252
let usedIDs = []
253253
function* idGen() {
254254
let id = 1
@@ -257,12 +257,24 @@ async function exportPredicate(
257257
id++
258258
}
259259
}
260+
260261
if (fs.existsSync(ajSettings.predicateFilePath)) {
261-
const oldPredicate: PredicateModel = JSON.parse(
262-
await fs.promises.readFile(ajSettings.predicateFilePath, {
262+
const stringContent = await fs.promises.readFile(
263+
ajSettings.predicateFilePath,
264+
{
263265
encoding: 'utf-8',
264-
})
266+
}
265267
)
268+
let oldPredicate: PredicateModel
269+
try {
270+
oldPredicate = JSON.parse(stringContent)
271+
} catch (err) {
272+
throwPredicateMergingError(
273+
tl(
274+
'animatedJava.dialogs.errors.predicateMergeFailed.reasons.invalidJson'
275+
)
276+
)
277+
}
266278
console.log(oldPredicate)
267279
// @ts-ignore
268280
if (oldPredicate) {
@@ -347,8 +359,8 @@ async function exportPredicate(
347359
})
348360
}
349361

350-
predicateJSON.overrides.sort((a: any,b: any) => {
351-
return (a.predicate.custom_model_data - b.predicate.custom_model_data)
362+
predicateJSON.overrides.sort((a: any, b: any) => {
363+
return a.predicate.custom_model_data - b.predicate.custom_model_data
352364
})
353365
//@ts-ignore
354366
predicateJSON.aj.includedRigs[Project.UUID] = {

src/lang/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ animatedJava:
190190
reasons:
191191
overridesMissing: Model overrides list missing.
192192
ajMetaMissing: Model file to merge into is not an Animated Java predicate file.
193+
invalidJson: Model file to merge into does not contain valid JSON
193194

194195
invalidAnimationSnappingValue:
195196
title: Invalid Animation Snapping Value

src/util/minecraft/resourcepack.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from 'path'
33
import { CustomError } from '../customError'
44
import { tl } from '../intl'
55
import { normalizePath } from '../misc'
6-
import { format } from '../replace'
76

87
export function getTexturePath(texture: any) {
98
if (!texture.path || !texture.saved) {

0 commit comments

Comments
 (0)