aboutsummaryrefslogtreecommitdiff
path: root/src/lib/minecraft/Inventory.svelte
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-02-20 21:38:14 -0600
committermat <github@matdoes.dev>2022-02-20 21:38:14 -0600
commit13e5974114f759bae73f3bfd68c62ce9cfaf785e (patch)
tree8a196b27b8d4dece1dc2187332422a4e41423dfa /src/lib/minecraft/Inventory.svelte
parent582409e7cb1598b65bee6d1023b77620bb3791af (diff)
downloadskyblock-stats-13e5974114f759bae73f3bfd68c62ce9cfaf785e.tar.gz
skyblock-stats-13e5974114f759bae73f3bfd68c62ce9cfaf785e.tar.bz2
skyblock-stats-13e5974114f759bae73f3bfd68c62ce9cfaf785e.zip
add more stuff to profile and fix bugs
Diffstat (limited to 'src/lib/minecraft/Inventory.svelte')
-rw-r--r--src/lib/minecraft/Inventory.svelte14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/minecraft/Inventory.svelte b/src/lib/minecraft/Inventory.svelte
index d29b1e0..3068f67 100644
--- a/src/lib/minecraft/Inventory.svelte
+++ b/src/lib/minecraft/Inventory.svelte
@@ -1,22 +1,24 @@
<script lang="ts">
+ import type { Inventory, Item as APIItem } from '$lib/APITypes'
+
import Item from './Item.svelte'
- export let items
+ export let items: Inventory
export let name = ''
export let pack = ''
export let groupLimit = 9
- if (name === 'inventory')
- // in the inventory, the first 9 items are the hotbar and should be at the end
- items = items.slice(9).concat(items.slice(0, 9))
-
// each item group has 9 items
- let itemGroups = []
+ let itemGroups: APIItem[][] = []
$: {
itemGroups = []
for (let i = 0; i < items.length; i += groupLimit) {
itemGroups.push(items.slice(i, i + groupLimit))
}
+ if (name === 'inventory') {
+ // in the inventory, the first 9 items are the hotbar and should be at the end
+ itemGroups = itemGroups.slice(1).concat(itemGroups.slice(0, 1))
+ }
}
</script>