1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
import * as skyblockAssets from 'skyblock-assets'
import vanilla from 'skyblock-assets/matchers/vanilla.json'
import packshq from 'skyblock-assets/matchers/vanilla.json'
interface Item {
id?: string
count?: number
vanillaId: string
display?: {
name?: string
lore?: string[]
glint?: boolean
}
reforge?: string
anvil_uses?: number
timestamp?: string
enchantments?: { [name: string]: number }
head_texture?: string
}
const INVENTORIES = {
armor: 'inv_armor',
inventory: 'inv_contents',
ender_chest: 'ender_chest_contents',
talisman_bag: 'talisman_bag',
potion_bag: 'potion_bag',
fishing_bag: 'fishing_bag',
quiver: 'quiver',
trick_or_treat_bag: 'candy_inventory_contents',
wardrobe: 'wardrobe_contents'
}
export type Inventories = { [name in keyof typeof INVENTORIES]: Item[] }
export function itemToUrl(item: Item, packName?: string): string {
const itemNbt: skyblockAssets.NBT = {
display: {
Name: item.display?.name
},
ExtraAttributes: {
id: item.id,
},
}
let textureUrl: string
if (item.head_texture)
textureUrl = `https://mc-heads.net/head/${item.head_texture}`
else
textureUrl = skyblockAssets.getTextureUrl({
id: item.vanillaId,
nbt: itemNbt,
packs: [packshq, vanilla]
})
if (!textureUrl)
console.log('no texture', item)
return textureUrl
}
export async function skyblockItemToUrl(skyblockItemName: string) {
const item = skyblockItemNameToItem(skyblockItemName)
const itemTextureUrl = await itemToUrl(item, 'packshq')
return itemTextureUrl
}
export function skyblockItemNameToItem(skyblockItemName: string): Item {
let item: Item
if (Object.keys(skyblockItems).includes(skyblockItemName)) {
item = skyblockItems[skyblockItemName]
} else {
item = {
vanillaId: `minecraft:${skyblockItemName}`
}
}
return item
}
const skyblockItems: { [itemName: string]: Item } = {
ink_sac: { vanillaId: 'minecraft:dye' },
cocoa_beans: { vanillaId: 'minecraft:dye:3' },
lapis_lazuli: { vanillaId: 'minecraft:dye:4' },
lily_pad: { vanillaId: 'minecraft:waterlily' },
melon_slice: { vanillaId: 'minecraft:melon' },
mithril_ore: {
vanillaId: 'minecraft:prismarine_crystals',
display: { name: 'Mithril Ore' }
},
acacia_log: { vanillaId: 'minecraft:log2' },
birch_log: { vanillaId: 'minecraft:log:2' },
cod: { vanillaId: 'minecraft:fish' },
dark_oak_log: { vanillaId: 'minecraft:log2:1' },
jungle_log: { vanillaId: 'minecraft:log:3' },
oak_log: { vanillaId: 'minecraft:log' },
pufferfish: { vanillaId: 'minecraft:fish:3' },
salmon: { vanillaId: 'minecraft:fish:1' },
spruce_log: { vanillaId: 'minecraft:log:1' },
gemstone: {
vanillaId: 'minecraft:skull',
head_texture: '39b6e047d3b2bca85e8cc49e5480f9774d8a0eafe6dfa9559530590283715142'
},
hard_stone: { vanillaId: 'minecraft:stone' },
}
|