finished Skin UGC

This commit is contained in:
JakeBreath
2026-08-05 09:47:30 -05:00
parent 552f570efb
commit 435ad24da4
8 changed files with 262 additions and 17 deletions
@@ -124,8 +124,45 @@
}
}
// Open a Minecraft Skin project (Steve/Alex player model) with the skin.
async function openSkin(msg) {
await waitFor(() => typeof Formats !== 'undefined' && !!Formats.skin, 15000);
const model = msg.model === 'alex' ? 'alex' : 'steve';
const dialog = Formats.skin.setup_dialog;
dialog.show();
await dialog.setFormValues({
model: model,
texture_source: 'upload_texture',
texture_file: { content: msg.dataUrl, name: 'skin.png', path: 'skin.png' },
layer_template: true,
});
dialog.confirm();
// Reveal every cube (incl. the outer layer) and land in Pose mode.
await new Promise((r) => setTimeout(r, 700));
try {
(typeof Cube !== 'undefined' && Cube.all || []).forEach((c) => { c.visibility = true; });
if (typeof Canvas !== 'undefined' && Canvas.updateAll) Canvas.updateAll();
const pose = Modes && Modes.options && Modes.options.pose;
if (pose && typeof pose.select === 'function') pose.select();
} catch (e) {
console.error('packs skin post-load', e);
}
notify('model-open', { name: msg.name || 'skin' });
}
window.addEventListener('message', (e) => {
if (!e.data || e.data.type !== 'packs-open-model') return;
if (!e.data) return;
if (e.data.type === 'packs-open-skin') {
openSkin(e.data).then(
() => {},
(err) => {
console.error('packs-open-skin failed', err);
notify('model-error', { name: e.data.name || '', error: String(err) });
}
);
return;
}
if (e.data.type !== 'packs-open-model') return;
openModel(e.data).then(
() => {},
(err) => {