From 2706ad9cbcb196c13ef7c6fb8233fd3f713de2c6 Mon Sep 17 00:00:00 2001 From: neoapps-dev Date: Mon, 20 Apr 2026 11:37:53 +0300 Subject: [PATCH] feat: use a seeded id for skin and cape --- src/hooks/useSkinSync.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hooks/useSkinSync.ts b/src/hooks/useSkinSync.ts index 9cf058b..f2ee326 100644 --- a/src/hooks/useSkinSync.ts +++ b/src/hooks/useSkinSync.ts @@ -92,6 +92,16 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) { setCapeBase64(null); } + const getSeededId = (name: string) => { + let hash = 0; + for (let i = 0; i < name.length; i++) { + hash = (hash << 5) - hash + name.charCodeAt(i); + hash |= 0; + } + return Math.abs(hash).toString().padStart(8, "0").slice(-8); + }; + + const seededId = getSeededId(profile); const files: any[] = [ { id: "0", @@ -107,8 +117,8 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) { ], }, { - id: "dlcskin99999999", - path: "dlcskin99999999.png", + id: `dlcskin${seededId}`, + path: `dlcskin${seededId}.png`, type: PCKAssetType.SKIN, size: skinBuf.byteLength, data: new Uint8Array(skinBuf), @@ -136,7 +146,7 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) { }, { key: "CAPEPATH", - value: "dlccape99999999.png", + value: `dlccape${seededId}.png`, }, ], }, @@ -144,8 +154,8 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) { if (capeBuf) { files.push({ - id: "dlccape99999999", - path: "dlccape99999999.png", + id: `dlccape${seededId}`, + path: `dlccape${seededId}.png`, type: PCKAssetType.CAPE, size: capeBuf.byteLength, data: new Uint8Array(capeBuf),