Skip to content

Commit

Permalink
refactor(rendering): small changes to the way we handle /item/ endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Feb 5, 2025
1 parent 0015f71 commit cf834e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/server/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export async function applyResourcePack(item: ProcessedItem, packs: string[]) {
const url = json.textures.SKIN.url;
const uuid = url.split("/").pop();

item.texture_path = `/api/head/${uuid}?v6`;
item.texture_path = `/api/head/${uuid}`;
} catch (e) {
console.error(e);
}
Expand Down
15 changes: 14 additions & 1 deletion src/lib/server/helper/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,20 @@ export async function renderItem(skyblockId: string | undefined, query: ItemQuer
helper.applyResourcePack(item, query.packs);

if (item.texture_path && item.texture_path.includes("/api/")) {
outputTexture.image = item.texture_path;
if (item.texture_path.startsWith("/api/leather/")) {
const args = item.texture_path.split("/");
const color = args.pop();
const type = args.pop();

outputTexture.image = await getArmor(type, color);
} else if (item.texture_path.startsWith("/api/head/")) {
const args = item.texture_path.split("/");
const id = args.pop();

outputTexture.image = await getHead(id);
} else {
outputTexture.image = outputTexture.texture_path;
}
} else if (item.texture_path !== undefined && item.texture_path.endsWith("/skull-3.png") === false) {
outputTexture.image = await fs.readFile(`static/${item.texture_path}`);
} else if (item.texture !== undefined && item.texture) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/stats/pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function getProfilePets(userProfile: Member, pets: Pet[]) {

const skinData = pet.skin ? NEU_ITEMS.get(`PET_SKIN_${pet.skin}`) : null;
const texture = helper.getHeadTextureUUID((skinData ?? petData).nbttag.SkullOwner.Properties.textures[0].Value);
outputPet.texture_path = `/api/head/${texture}?v6`;
outputPet.texture_path = `/api/head/${texture}`;
if (outputPet.skin) {
outputPet.display_name += " ✦";
}
Expand Down

0 comments on commit cf834e0

Please sign in to comment.