diff --git a/src/app/components/previews/LootTable.ts b/src/app/components/previews/LootTable.ts index 15ee7f70..87ba95c5 100644 --- a/src/app/components/previews/LootTable.ts +++ b/src/app/components/previews/LootTable.ts @@ -471,6 +471,7 @@ const LootFunctions: Record LootFunction> = { .set('seed', new NbtLong(typeof seed === 'number' ? BigInt(seed) : BigInt(0)))) }, set_lore: ({ lore }) => (item) => { + if (!Array.isArray(lore)) return const lines: string[] = lore.flatMap((line: any) => line !== undefined ? [JSON.stringify(line)] : []) // TODO: account for mode item.set('lore', new NbtList(lines.map(l => new NbtString(l)))) diff --git a/src/app/components/previews/LootTable1204.ts b/src/app/components/previews/LootTable1204.ts index 3627a9b1..a4eac639 100644 --- a/src/app/components/previews/LootTable1204.ts +++ b/src/app/components/previews/LootTable1204.ts @@ -351,6 +351,9 @@ const LootFunctions: Record LootFunction> = { } }, set_enchantments: ({ enchantments, add }) => (item, ctx) => { + if (!isObject(enchantments)) { + return + } Object.entries(enchantments).forEach(([id, level]) => { const lvl = computeInt(level, ctx) try { @@ -359,6 +362,7 @@ const LootFunctions: Record LootFunction> = { }) }, set_lore: ({ lore, replace }) => (item) => { + if (!Array.isArray(lore)) return const lines: string[] = lore.flatMap((line: any) => line !== undefined ? [JSON.stringify(line)] : []) const newLore = replace ? lines : [...item.tag.getCompound('display').getList('Lore', NbtType.String).map(s => s.getAsString()), ...lines] getOrCreateTag(item, 'display').set('Lore', new NbtList(newLore.map(l => new NbtString(l))))