// Smelt window UI. The engine reports progress and a verdict for each mod;
// this file only turns that into the four screens a player ever sees.
(function () {
const S = window.Sprites;
const icon = {
min: '',
max: '',
close: '',
check: '',
plus: '',
folder: '',
};
// What the engine reports for each mod it reads.
const VERDICTS = {
'spyglass-zoom-2.1.jar': {
name: 'Spyglass Zoom', verdict: 'works', kind: 'code',
title: 'Ready for Minecraft on Rust',
lines: [['ok', 'Zoom key and smooth zoom, rewritten in Rust']],
out: 'spyglass-zoom.hnmod', size: '52 KB',
added: 'Horizon asks you to trust new mods the first time it starts them.',
},
'corner-clock-1.3.jar': {
name: 'Corner Clock', verdict: 'partly', kind: 'code',
title: 'Ready, with one gap',
lines: [['ok', 'The clock in the corner of your screen'], ['warn', 'Its settings menu doesn’t come over yet']],
out: 'corner-clock.hnmod', size: '38 KB',
added: 'Horizon asks you to trust new mods the first time it starts them.',
},
'copper-decor-1.0.jar': {
name: 'Copper Decor', verdict: 'works', kind: 'content',
title: 'Ready for Minecraft on Rust',
lines: [['ok', '48 blocks, 31 recipes and all their textures'], ['ok', 'No code inside, so there’s nothing to trust']],
out: 'copper-decor.hmod', size: '1.4 MB',
added: 'Restart Horizon to see the new blocks.',
},
'shader-tweaks-0.9.jar': {
name: 'Shader Tweaks', verdict: 'no', kind: 'none',
title: 'This one can’t come over yet',
lines: [['off', 'It changes how the game draws the world. Minecraft on Rust can’t load that kind of change yet.']],
},
};
const PILL = { works: 'Works', partly: 'Partly', no: 'Won’t run' };
const STEPS = ['Reading the mod', 'Rewriting it in Rust', 'Packing it for Horizon'];
const SEGMENTS = 24;
const app = document.getElementById('app');
app.innerHTML = `
${S.svg('ingot', 20)}smelt
Java mods for Minecraft on Rust
${icon.min}${icon.max}${icon.close}
`;
const zone = app.querySelector('.zone');
const stage = app.querySelector('.stage');
const toast = app.querySelector('#toast');
const devSwitch = app.querySelector('#dev');
const dash = '';
let current = null;
let devOn = false;
function set(cls, html) {
zone.className = 'zone ' + cls;
stage.classList.toggle('wide', cls === 'dev');
zone.innerHTML = html;
}
function idle(over) {
hideToast();
set(over ? 'over' : 'dashed', `${dash}
${S.svg('jar', 48)}
${S.svg('ingot', 48)}
${over ? 'Release to smelt' : 'Drop a mod here'}
A Fabric or NeoForge .jar. It comes out as a Rust mod for Minecraft on Rust.
Works offline. Nothing leaves your PC.
`);
const pick = zone.querySelector('#pick');
if (pick) pick.onclick = () => chooser.click();
}
function smelting(file) {
set('solid', `
${S.svg('jar', 96)}
${S.svg('ingot', 96)}
${file}
${''.repeat(SEGMENTS)}
${STEPS.map((s) => `${s}`).join('')}
`);
}
function progress(p, step) {
const morph = zone.querySelector('.morph');
if (!morph) return;
morph.style.setProperty('--p', p.toFixed(3));
const on = Math.round(p * SEGMENTS);
zone.querySelectorAll('.bar i').forEach((seg, i) => {
seg.classList.toggle('on', i < on);
seg.classList.toggle('tip', i === on - 1 && p < 1);
});
zone.querySelectorAll('.steps span').forEach((s, i) => {
s.className = i < step ? 'past' : i === step ? 'now' : '';
});
}
function result(v) {
current = v;
if (devOn && v.verdict !== 'no') return developer(v);
const art = v.verdict === 'no' ? S.svg('slag', 96) : S.svg(v.kind === 'content' ? 'block' : 'ingot', 96);
const artCls = v.verdict === 'no' ? 'no' : v.kind === 'content' ? 'content' : '';
const buttons = v.verdict === 'no'
? ``
: ``;
set('solid', `