mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
More correct implementation of assigning slots
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user