From 0d76ff9cbacbc280d9d29be005dd1c9360fd6174 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 11 Nov 2022 17:44:12 +0100 Subject: [PATCH] More correct implementation of assigning slots --- src/app/previews/LootTable.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/previews/LootTable.ts b/src/app/previews/LootTable.ts index 20856930..a89ef949 100644 --- a/src/app/previews/LootTable.ts +++ b/src/app/previews/LootTable.ts @@ -89,7 +89,18 @@ function fillContainer(items: Item[], ctx: LootContext): SlottedItem[] { } function assignSlots(items: Item[]): SlottedItem[] { - return items.flatMap((item, i) => item.count > 0 ? [({ slot: i, item })] : []) + const results: SlottedItem[] = [] + let slot = 0 + for (const item of items) { + if (slot >= 27) { + break + } + if (item.id !== 'minecraft:air' && item.count > 0) { + results.push({ slot, item }) + slot += 1 + } + } + return results } function splitItem(item: Item, count: number): Item {