Skip to content

Commit

Permalink
Fix #546 catch invalid recipe resource locations in result
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Sep 5, 2024
1 parent ee91810 commit 337b7d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/components/previews/RecipePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,18 @@ function placeItems(recipe: any, animation: number, itemTags: Map<string, any>)
items.set(resultSlot, base)
}
} else if (typeof result === 'string') {
items.set(resultSlot, new ItemStack(Identifier.parse(result), 1))
try {
items.set(resultSlot, new ItemStack(Identifier.parse(result), 1))
} catch (e) {}
} else if (typeof result === 'object' && result !== null) {
const id = typeof result.id === 'string' ? result.id
: typeof result.item === 'string' ? result.item
: 'minecraft:air'
const count = typeof result.count === 'number' ? result.count : 1
// TODO: add components
items.set(resultSlot, new ItemStack(Identifier.parse(id), count))
try {
items.set(resultSlot, new ItemStack(Identifier.parse(id), count))
} catch (e) {}
}

return items
Expand Down

0 comments on commit 337b7d9

Please sign in to comment.