From 582409e7cb1598b65bee6d1023b77620bb3791af Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Sun, 20 Feb 2022 02:16:09 -0600
Subject: add inventories

---
 src/lib/minecraft/Inventory.svelte | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

(limited to 'src/lib/minecraft/Inventory.svelte')

diff --git a/src/lib/minecraft/Inventory.svelte b/src/lib/minecraft/Inventory.svelte
index 3d3b9c0..d29b1e0 100644
--- a/src/lib/minecraft/Inventory.svelte
+++ b/src/lib/minecraft/Inventory.svelte
@@ -4,6 +4,7 @@
 	export let items
 	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
@@ -13,14 +14,14 @@
 	let itemGroups = []
 	$: {
 		itemGroups = []
-		for (let i = 0; i < items.length; i += 9) {
-			itemGroups.push(items.slice(i, i + 9))
+		for (let i = 0; i < items.length; i += groupLimit) {
+			itemGroups.push(items.slice(i, i + groupLimit))
 		}
 	}
 </script>
 
 <div class:inventory-container-{name}={name !== ''}>
-	{#each itemGroups as itemGroup, groupIndex}
+	{#each itemGroups as itemGroup}
 		<div>
 			{#each itemGroup as item}
 				<Item {item} {pack} isslot />
@@ -28,18 +29,3 @@
 		</div>
 	{/each}
 </div>
-
-<!-- {%- macro inventory(items, name='', pack='') -%}
-	<div{% if name %} class="inventory-container-{{ name }}"{% endif %}>
-		{%- if name == 'inventory' -%}
-			{%- set items = items|slice(9)|append(items|slice(0, 9)) -%}
-		{%- endif -%}
-
-		{%- for itemData in items -%}
-			{%- if loop.index0 > 0 and loop.index0 % 9 == 0 %}</div>{%- endif -%}
-			{%- if loop.index0 % 9 == 0 %}<div>{%- endif -%}
-			{{- item(itemData, slot=true, pack=pack) -}}
-		{%- endfor -%}
-		</div>
-	</div>
-{%- endmacro -%} -->
-- 
cgit 

