diff options
author | mat <github@matdoes.dev> | 2022-03-27 17:15:25 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-27 17:15:25 -0500 |
commit | c76570072611b61aaf8f0db5f6870ffaf4e6d422 (patch) | |
tree | 522828b301426271ed3f6212bef247f2b2da645a | |
parent | 32799f64bdabbc9514cb579c5454b1fc5044dacc (diff) | |
download | skyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.tar.gz skyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.tar.bz2 skyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.zip |
Resize heads in inventory to use less bandwidth
-rw-r--r-- | src/lib/minecraft/Inventory.svelte | 2 | ||||
-rw-r--r-- | src/lib/minecraft/Item.svelte | 3 | ||||
-rw-r--r-- | src/lib/minecraft/inventory.ts | 11 | ||||
-rw-r--r-- | src/lib/sections/Inventories.svelte | 2 |
4 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/minecraft/Inventory.svelte b/src/lib/minecraft/Inventory.svelte index b3c464d..b01f27b 100644 --- a/src/lib/minecraft/Inventory.svelte +++ b/src/lib/minecraft/Inventory.svelte @@ -26,7 +26,7 @@ <div class="inventory-container" style="--group-limit:{groupLimit}"> {#each itemGroups as itemGroup} {#each itemGroup as item} - <Item {item} {pack} isslot /> + <Item {item} {pack} headSize={50} isslot /> {/each} {/each} </div> diff --git a/src/lib/minecraft/Item.svelte b/src/lib/minecraft/Item.svelte index c121f12..4d0997c 100644 --- a/src/lib/minecraft/Item.svelte +++ b/src/lib/minecraft/Item.svelte @@ -7,6 +7,7 @@ export let item: any | null export let isslot = true export let pack: MatcherFile | undefined = undefined + export let headSize: number | undefined = undefined let itemLoreHtml: string | null let itemNameHtml: string | null @@ -15,7 +16,7 @@ $: itemLoreHtml = item ? item.display.lore.map(l => formattingCodeToHtml(l)).join('<br>') : null $: itemNameHtml = item ? formattingCodeToHtml(item.display.name) : null - $: imageUrl = item ? itemToUrl(item, pack) : null + $: imageUrl = item ? itemToUrl(item, pack, headSize) : null </script> {#if item} diff --git a/src/lib/minecraft/inventory.ts b/src/lib/minecraft/inventory.ts index 563e96a..871af93 100644 --- a/src/lib/minecraft/inventory.ts +++ b/src/lib/minecraft/inventory.ts @@ -97,7 +97,7 @@ export const inventoryIconMap: Record<string, string | Item> = { export type Inventories = { [name in keyof typeof INVENTORIES]: Item[] } -export function itemToUrl(item: Item, pack?: skyblockAssets.MatcherFile): string { +export function itemToUrl(item: Item, pack?: skyblockAssets.MatcherFile, headSize?: number): string { const itemNbt: skyblockAssets.NBT = { display: { Name: item.display?.name @@ -115,8 +115,11 @@ export function itemToUrl(item: Item, pack?: skyblockAssets.MatcherFile): string packs: pack ? [pack] : [], noNullTexture: true }) - if (textureUrl === null) + if (textureUrl === null) { textureUrl = `https://mc-heads.net/head/${item.headTexture}` + if (headSize) + textureUrl += `/${headSize}` + } } else textureUrl = skyblockAssets.getTextureUrl({ id: item.vanillaId, @@ -126,9 +129,9 @@ export function itemToUrl(item: Item, pack?: skyblockAssets.MatcherFile): string return textureUrl } -export function skyblockItemToUrl(skyblockItem: string | Item, pack?: skyblockAssets.MatcherFile) { +export function skyblockItemToUrl(skyblockItem: string | Item, pack?: skyblockAssets.MatcherFile, headSize?: number) { const item: Item = typeof skyblockItem === 'string' ? skyblockItemNameToItem(skyblockItem) : skyblockItem - const itemTextureUrl = itemToUrl(item, pack) + const itemTextureUrl = itemToUrl(item, pack, headSize) return itemTextureUrl } diff --git a/src/lib/sections/Inventories.svelte b/src/lib/sections/Inventories.svelte index 27bdd72..07d5504 100644 --- a/src/lib/sections/Inventories.svelte +++ b/src/lib/sections/Inventories.svelte @@ -26,7 +26,7 @@ <img class="inventory-tab-icon" loading="lazy" - src={skyblockItemToUrl(inventoryIconMap[inventoryName], pack)} + src={skyblockItemToUrl(inventoryIconMap[inventoryName], pack, 50)} alt={cleanId(inventoryName)} /> {/if} |