aboutsummaryrefslogtreecommitdiff
path: root/src/lib/minecraft/inventory.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-27 17:15:25 -0500
committermat <github@matdoes.dev>2022-03-27 17:15:25 -0500
commitc76570072611b61aaf8f0db5f6870ffaf4e6d422 (patch)
tree522828b301426271ed3f6212bef247f2b2da645a /src/lib/minecraft/inventory.ts
parent32799f64bdabbc9514cb579c5454b1fc5044dacc (diff)
downloadskyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.tar.gz
skyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.tar.bz2
skyblock-stats-c76570072611b61aaf8f0db5f6870ffaf4e6d422.zip
Resize heads in inventory to use less bandwidth
Diffstat (limited to 'src/lib/minecraft/inventory.ts')
-rw-r--r--src/lib/minecraft/inventory.ts11
1 files changed, 7 insertions, 4 deletions
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
}