fix: PCK3, hex values and force slim skins to be wide

This commit is contained in:
neoapps-dev 2026-04-16 17:04:22 +03:00
parent 1a0f51d698
commit afebdffced
2 changed files with 46 additions and 13 deletions

View file

@ -171,7 +171,7 @@ export default function PckEditorView() {
const handleNewPCK = () => { const handleNewPCK = () => {
playPressSound(); playPressSound();
const newPck: PCKFile = { const newPck: PCKFile = {
version: 2, version: 3,
endianness: "little", endianness: "little",
xmlSupport: false, xmlSupport: false,
properties: ["ANIM", "BOX"], properties: ["ANIM", "BOX"],
@ -624,7 +624,7 @@ export default function PckEditorView() {
const newVal = e.target.checked const newVal = e.target.checked
? currentVal | item.flag ? currentVal | item.flag
: currentVal & ~item.flag; : currentVal & ~item.flag;
handlePropertyEdit(idx, newVal.toString()); handlePropertyEdit(idx, `0x${newVal.toString(16).toUpperCase().padStart(8, "0")}`);
}} }}
className="hidden" className="hidden"
/> />

View file

@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import { useLocalStorage } from "./useLocalStorage"; import { useLocalStorage } from "./useLocalStorage";
import { PckService } from "../services/PckService"; import { PckService } from "../services/PckService";
import { TauriService } from "../services/TauriService"; import { TauriService } from "../services/TauriService";
import { PCKAssetType, PCKProperty } from "../types/pck";
interface Edition { interface Edition {
id: string; id: string;
supportsSlimSkins?: boolean; supportsSlimSkins?: boolean;
@ -25,8 +25,13 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) {
img.onload = async () => { img.onload = async () => {
if (cancelled) return; if (cancelled) return;
const cvs = document.createElement("canvas"); const cvs = document.createElement("canvas");
cvs.width = img.width; if (skinIsSlim) {
cvs.height = img.height; cvs.width = 64;
cvs.height = 64;
} else {
cvs.width = 64;
cvs.height = 32;
}
const ctx = cvs.getContext("2d"); const ctx = cvs.getContext("2d");
if (ctx) { if (ctx) {
ctx.drawImage(img, 0, 0); ctx.drawImage(img, 0, 0);
@ -35,25 +40,53 @@ export function useSkinSync({ profile, editions }: UseSkinSyncProps) {
try { try {
const res = await fetch(b64); const res = await fetch(b64);
const buf = await res.arrayBuffer(); const buf = await res.arrayBuffer();
const animValue = (skinIsSlim) ? (1 << 19) : 0; const animValue = (skinIsSlim) ? "0x00040000" : "0x00040000"; //neo: forces wide skin, because slim is not even working.
let boxes: PCKProperty[] = [];
/*if (skinIsSlim) {
boxes.push({
key: "BOX",
value: "ARM0 -2 1 -1 3 10 3 40 16 0 0 0"
});
boxes.push({
key: "BOX",
value: "ARM1 -1 1 -1 3 10 3 52 16 0 0 0"
});
}*/
const pckBuf = PckService.serializePCK({ const pckBuf = PckService.serializePCK({
version: 2, version: 3,
endianness: "little", endianness: "little",
xmlSupport: false, xmlSupport: true,
properties: ["ANIM"], properties: ["ANIM", "DISPLAYNAME", "THEMENAME", "GAME_FLAGS", "FREE", "BOX"],
files: [{ files: [{
id: "0",
path: "0",
type: PCKAssetType.INFO,
size: 0,
data: new Uint8Array(0),
properties: [{
key: "PACKID",
value: "9999"
}]
}, {
id: "dlcskin00000001", id: "dlcskin00000001",
path: "dlcskin00000001.png", path: "dlcskin00000001.png",
type: 0, type: PCKAssetType.SKIN,
size: buf.byteLength, size: buf.byteLength,
data: new Uint8Array(buf), data: new Uint8Array(buf),
properties: [{ properties: [{
key: "ANIM",
value: animValue.toString(10)
}, {
key: "DISPLAYNAME", key: "DISPLAYNAME",
value: "Custom Skin" value: "Custom Skin"
}, { }, {
key: "GAME_FLAGS",
value: "0x18"
}, {
key: "FREE",
value: "1"
},
{
key: "ANIM",
value: animValue
}, ...boxes, {
key: "THEMENAME", key: "THEMENAME",
value: "Emerald Launcher" value: "Emerald Launcher"
}] }]