Fix #640 handle malformed set_enchantments in loot table preview

This commit is contained in:
Misode
2024-11-27 21:40:39 +01:00
parent fdcb3f2b70
commit 794657d0f5

View File

@@ -432,6 +432,9 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
}
},
set_enchantments: ({ enchantments, add }) => (item, ctx) => {
if (typeof enchantments !== 'object' || enchantments === null) {
return
}
if (item.is('book')) {
item.id = Identifier.create('enchanted_book')
item.base = ctx.getBaseComponents(item.id.toString())