diff --git a/src/lib/constants/rift.ts b/src/lib/constants/rift.ts index d26eeabe..3ec0883f 100644 --- a/src/lib/constants/rift.ts +++ b/src/lib/constants/rift.ts @@ -29,7 +29,7 @@ export const RIFT_TIMECHARMS = [ { name: "Supreme Timecharm", id: "wyldly_supreme", - texture: "/api/item/SPRUCE_LEAVES" + texture: "/api/item/LEAVES:1" }, { name: "mrahcemiT esrevrorriM", diff --git a/src/lib/helper/item.ts b/src/lib/helper/item.ts index 8530bfa4..2624c433 100644 --- a/src/lib/helper/item.ts +++ b/src/lib/helper/item.ts @@ -1,7 +1,7 @@ -import * as constants from "../constants/constants"; +import type { DatabaseItem, Item, ItemQuery } from "$types/stats"; import sanitize from "mongo-sanitize"; +import * as constants from "../constants/constants"; import * as helper from "../helper"; -import type { DatabaseItem, Item, ItemQuery } from "$types/stats"; /** * Gathers Item Data visualized similarily to in-game NBT format based on a query diff --git a/src/lib/renderer.ts b/src/lib/renderer.ts index 69c6416c..1147441c 100644 --- a/src/lib/renderer.ts +++ b/src/lib/renderer.ts @@ -16,6 +16,7 @@ import fs from "fs-extra"; import sanitize from "mongo-sanitize"; import path from "path"; +import type { ItemQuery } from "$types/global"; import minecraftData from "minecraft-data"; import * as helper from "./helper"; import { getItemData } from "./helper/item"; @@ -442,7 +443,7 @@ async function renderPotion(type: string, color: string) { * @param {object} query * @returns Image of an item */ -export async function renderItem(skyblockId: string | undefined, query: SkyBlockItemQuery): Promise { +export async function renderItem(skyblockId: string | undefined, query: ItemQuery): Promise { query = sanitize(query); let itemQuery = query ?? {}; diff --git a/src/routes/api/item/[id=itemId]/+server.ts b/src/routes/api/item/[id=itemId]/+server.ts index 4f30265c..46e46973 100644 --- a/src/routes/api/item/[id=itemId]/+server.ts +++ b/src/routes/api/item/[id=itemId]/+server.ts @@ -1,13 +1,14 @@ -import type { RequestHandler } from "./$types"; import { renderItem } from "$lib/renderer"; import { error } from "@sveltejs/kit"; +import type { RequestHandler } from "./$types"; // GET /api/head/[id=itemId] export const GET: RequestHandler = async ({ params }) => { const { id } = params; try { - const attachment = await renderItem(id, {}); + const damage = parseInt(id.split(":")?.at(-1) ?? ""); + const attachment = await renderItem(id, { damage: isNaN(damage) ? 0 : damage }); return new Response(attachment.image, { headers: { "Content-Type": "image/png" } }); } catch (errorMsg) {