aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/BackgroundImage.svelte26
-rw-r--r--src/lib/minecraft/Inventory.svelte3
-rw-r--r--src/lib/minecraft/Item.svelte5
-rw-r--r--src/lib/minecraft/inventory.ts25
-rw-r--r--src/lib/sections/Armor.svelte4
-rw-r--r--src/lib/sections/Collections.svelte8
-rw-r--r--src/lib/sections/Inventories.svelte47
7 files changed, 93 insertions, 25 deletions
diff --git a/src/lib/BackgroundImage.svelte b/src/lib/BackgroundImage.svelte
new file mode 100644
index 0000000..c059119
--- /dev/null
+++ b/src/lib/BackgroundImage.svelte
@@ -0,0 +1,26 @@
+<script lang="ts">
+ import { browser } from '$app/env'
+
+ import { onDestroy } from 'svelte'
+
+ export let url: string
+
+ // cursed svelte :D
+ $: bodyStyle =
+ '<sty' + 'le id="background-image-style">:root{--background:url(' + url + ')}</st' + 'yle>'
+
+ // get rid of the body style when we leave the page
+ // not doing this will sometimes cause the background to stay
+ onDestroy(() => {
+ bodyStyle = ''
+ // hack since sometimes the style is not removed
+ if (browser) {
+ let styleEl = document.getElementById('background-image-style')
+ if (styleEl) styleEl.remove()
+ }
+ })
+</script>
+
+<svelte:head>
+ {@html bodyStyle}
+</svelte:head>
diff --git a/src/lib/minecraft/Inventory.svelte b/src/lib/minecraft/Inventory.svelte
index 0a6a179..b3c464d 100644
--- a/src/lib/minecraft/Inventory.svelte
+++ b/src/lib/minecraft/Inventory.svelte
@@ -1,11 +1,12 @@
<script lang="ts">
import type { Inventory, Item as APIItem } from '$lib/APITypes'
+ import type { MatcherFile } from 'skyblock-assets'
import Item from './Item.svelte'
export let items: Inventory
export let name = ''
- export let pack = ''
+ export let pack: MatcherFile | undefined = undefined
export let groupLimit = 9
// each item group has 9 items
diff --git a/src/lib/minecraft/Item.svelte b/src/lib/minecraft/Item.svelte
index 13ca8c7..5553840 100644
--- a/src/lib/minecraft/Item.svelte
+++ b/src/lib/minecraft/Item.svelte
@@ -1,11 +1,12 @@
<script lang="ts">
- import MinecraftTooltip from './MinecraftTooltip.svelte'
import { formattingCodeToHtml, removeFormattingCode } from '$lib/utils'
+ import MinecraftTooltip from './MinecraftTooltip.svelte'
+ import type { MatcherFile } from 'skyblock-assets'
import { itemToUrl } from './inventory'
export let item: any | null
export let isslot = true
- export let pack = ''
+ export let pack: MatcherFile | undefined = undefined
let itemLoreHtml: string | null
let itemNameHtml: string | null
diff --git a/src/lib/minecraft/inventory.ts b/src/lib/minecraft/inventory.ts
index 72d72ee..e9d840c 100644
--- a/src/lib/minecraft/inventory.ts
+++ b/src/lib/minecraft/inventory.ts
@@ -1,7 +1,6 @@
import * as skyblockAssets from 'skyblock-assets'
import vanilla from 'skyblock-assets/matchers/vanilla.json'
-import packshq from 'skyblock-assets/matchers/vanilla.json'
-import furfsky_reborn from 'skyblock-assets/matchers/furfsky_reborn.json'
+
export interface Item {
id?: string
@@ -36,7 +35,7 @@ const INVENTORIES = {
export type Inventories = { [name in keyof typeof INVENTORIES]: Item[] }
-export function itemToUrl(item: Item, packName?: string): string {
+export function itemToUrl(item: Item, pack?: skyblockAssets.MatcherFile): string {
const itemNbt: skyblockAssets.NBT = {
display: {
Name: item.display?.name
@@ -46,20 +45,28 @@ export function itemToUrl(item: Item, packName?: string): string {
},
}
let textureUrl: string
- if (item.head_texture)
- textureUrl = `https://mc-heads.net/head/${item.head_texture}`
- else
+ if (item.head_texture) {
+ // if it's a head, try without vanilla and if it fails just use the mc-heads url
+ textureUrl = skyblockAssets.getTextureUrl({
+ id: item.vanillaId,
+ nbt: itemNbt,
+ packs: pack ? [pack] : [],
+ noNullTexture: true
+ })
+ if (textureUrl === null)
+ textureUrl = `https://mc-heads.net/head/${item.head_texture}`
+ } else
textureUrl = skyblockAssets.getTextureUrl({
id: item.vanillaId,
nbt: itemNbt,
- packs: [furfsky_reborn, vanilla]
+ packs: pack ? [pack, vanilla as skyblockAssets.MatcherFile] : [vanilla as skyblockAssets.MatcherFile],
})
return textureUrl
}
-export function skyblockItemToUrl(skyblockItem: string | Item) {
+export function skyblockItemToUrl(skyblockItem: string | Item, pack?: skyblockAssets.MatcherFile) {
const item: Item = typeof skyblockItem === 'string' ? skyblockItemNameToItem(skyblockItem) : skyblockItem
- const itemTextureUrl = itemToUrl(item, 'packshq')
+ const itemTextureUrl = itemToUrl(item, pack)
return itemTextureUrl
}
diff --git a/src/lib/sections/Armor.svelte b/src/lib/sections/Armor.svelte
index 655de31..285a898 100644
--- a/src/lib/sections/Armor.svelte
+++ b/src/lib/sections/Armor.svelte
@@ -1,8 +1,10 @@
<script lang="ts">
import type { CleanMemberProfile } from '$lib/APITypes'
import Inventory from '$lib/minecraft/Inventory.svelte'
+ import type { MatcherFile } from 'skyblock-assets'
+
export let data: CleanMemberProfile
- export let pack
+ export let pack: MatcherFile
</script>
{#if data.member.inventories}
diff --git a/src/lib/sections/Collections.svelte b/src/lib/sections/Collections.svelte
index 9624ec2..7ca1969 100644
--- a/src/lib/sections/Collections.svelte
+++ b/src/lib/sections/Collections.svelte
@@ -1,9 +1,10 @@
<script lang="ts">
+ import furfskyReborn from 'skyblock-assets/matchers/furfsky_reborn.json'
import type { CleanMemberProfile, Collection } from '$lib/APITypes'
import { skyblockItemToUrl } from '$lib/minecraft/inventory'
import ListItemWithIcon from '$lib/ListItemWithIcon.svelte'
- import { cleanId } from '$lib/utils'
import Tooltip from '$lib/Tooltip.svelte'
+ import { cleanId } from '$lib/utils'
export let data: CleanMemberProfile
@@ -21,7 +22,10 @@
<h3>{cleanId(categoryName)}</h3>
<ul>
{#each collections as collection}
- <ListItemWithIcon url={skyblockItemToUrl(collection.name)} alt={cleanId(collection.name)}>
+ <ListItemWithIcon
+ url={skyblockItemToUrl(collection.name, furfskyReborn)}
+ alt={cleanId(collection.name)}
+ >
<Tooltip>
<span slot="tooltip">
Amount: {collection.xp.toLocaleString()}
diff --git a/src/lib/sections/Inventories.svelte b/src/lib/sections/Inventories.svelte
index 8be6853..9001430 100644
--- a/src/lib/sections/Inventories.svelte
+++ b/src/lib/sections/Inventories.svelte
@@ -1,11 +1,11 @@
<script lang="ts">
+ import { skyblockItemToUrl, type Item } from '$lib/minecraft/inventory'
import Inventory from '$lib/minecraft/Inventory.svelte'
- import { fade } from 'svelte/transition'
+ import type { MatcherFile } from 'skyblock-assets'
import { cleanId } from '$lib/utils'
- import { skyblockItemToUrl, type Item } from '$lib/minecraft/inventory'
export let data
- export let pack
+ export let pack: MatcherFile
let displayingInventories: string[] = []
for (const inventoryName in data.member.inventories)
@@ -19,11 +19,38 @@
vanillaId: 'nether_star',
display: { name: 'SkyBlock Menu' },
},
- ender_chest: 'ender_chest',
- potion_bag: 'potion',
- fishing_bag: 'fishing_rod',
- quiver: 'arrow',
- wardrobe: 'leather_chestplate',
+ ender_chest: {
+ vanillaId: 'ender_chest',
+ display: { name: '\\u00a7aEnder Chest' },
+ },
+ talisman_bag: {
+ vanillaId: 'skull:3',
+ display: { name: 'Accessory Bag' },
+ head_texture: '961a918c0c49ba8d053e522cb91abc74689367b4d8aa06bfc1ba9154730985ff',
+ },
+ potion_bag: {
+ vanillaId: 'skull:3',
+ display: { name: 'Potion Bag' },
+ head_texture: '9f8b82427b260d0a61e6483fc3b2c35a585851e08a9a9df372548b4168cc817c',
+ },
+ fishing_bag: {
+ vanillaId: 'skull:3',
+ display: { name: 'Fishing Bag' },
+ head_texture: 'eb8e297df6b8dffcf135dba84ec792d420ad8ecb458d144288572a84603b1631',
+ },
+ quiver: {
+ vanillaId: 'skull:3',
+ display: {
+ name: 'Quiver',
+ },
+ head_texture: '4cb3acdc11ca747bf710e59f4c8e9b3d949fdd364c6869831ca878f0763d1787',
+ },
+ wardrobe: {
+ vanillaId: 'leather_chestplate',
+ display: {
+ name: '\\u00a7aWardrobe',
+ },
+ },
}
</script>
@@ -38,7 +65,7 @@
<img
class="inventory-tab-icon"
loading="lazy"
- src={skyblockItemToUrl(inventoryIconMap[inventoryName])}
+ src={skyblockItemToUrl(inventoryIconMap[inventoryName], pack)}
alt={cleanId(inventoryName)}
/>
{/if}
@@ -68,7 +95,7 @@
color: var(--theme-main-text);
border: none;
border-radius: 0;
- /* padding: 0.8em; */
+ padding: 0 0.5em;
cursor: pointer;
transition-duration: 200ms;
height: 2.5em;