';
+
+ // Доступные рецепты — показываем только те, для которых есть ресурсы
+ for (let i = 0; i < SMELTING_RECIPES.length; i++) {
+ const recipe = SMELTING_RECIPES[i];
+ const haveCount = inv[recipe.in] || 0;
+ const canSmelt = haveCount >= recipe.qty;
+
+ // Иконка результата
+ const outDef = BLOCKS[recipe.out];
+ const outItem = ITEMS[recipe.out];
+ const iconStr = outItem ? outItem.icon : (outDef ? '🧱' : '❓');
+ const nameStr = outItem ? outItem.n : (outDef ? outDef.n : recipe.out);
+ const inItem = ITEMS[recipe.in];
+ const inDef = BLOCKS[recipe.in];
+ const inName = inItem ? inItem.n : (inDef ? inDef.n : recipe.in);
+
+ html += `
`;
+ html += `
${iconStr}
`;
+ html += `
`;
+ html += `
${nameStr}
`;
+ html += `
${inName} x${recipe.qty} (есть: ${haveCount}) • ${recipe.time}с
`;
+ html += `
`;
+ html += `
`;
+ html += `
`;
+ }
+
+ // Текущий прогресс
+ if (active) {
+ const pct = Math.min(100, Math.floor((active.progress / active.recipe.time) * 100));
+ html += `
`;
+ html += `
🔥 Обжиг: ${pct}%
`;
+ html += `
`;
+ html += `
`;
+ html += `
`;
+ }
+
+ html += '
';
+ furnaceContent.innerHTML = html;
+ }
+
+ // Глобальная функция для кнопки обжига
+ window._smelt = (recipeIdx) => {
+ if (!currentFurnaceKey) return;
+ const recipe = SMELTING_RECIPES[recipeIdx];
+ if ((inv[recipe.in] || 0) < recipe.qty) return;
+
+ // Уже обжигаем в этой печи?
+ if (activeFurnaces.has(currentFurnaceKey)) return;
+
+ // Забираем ресурсы
+ inv[recipe.in] -= recipe.qty;
+
+ // Запускаем обжиг
+ activeFurnaces.set(currentFurnaceKey, {
+ recipe: recipe,
+ progress: 0
+ });
+
+ playSound('fire');
+ rebuildHotbar();
+ renderFurnaceUI();
+ };
+
+ // Тик печей — вызывается в главном цикле
+ function tickFurnaces(dt) {
+ for (const [key, furnace] of activeFurnaces) {
+ furnace.progress += dt;
+ if (furnace.progress >= furnace.recipe.time) {
+ // Обжиг завершён — выдаём результат
+ const outItem = furnace.recipe.out;
+ if (ITEMS[outItem]) {
+ inv[outItem] = (inv[outItem] || 0) + furnace.recipe.outQty;
+ } else if (BLOCKS[outItem]) {
+ inv[outItem] = (inv[outItem] || 0) + furnace.recipe.outQty;
+ }
+ playSound('stone_build');
+ activeFurnaces.delete(key);
+
+ // Если эта печь открыта — обновляем UI
+ if (key === currentFurnaceKey) {
+ renderFurnaceUI();
+ }
+ }
+ }
+ }
+
+ // ==================== ГОЛОСОВОЙ ЧАТ ====================
+ let voiceSocket = null;
+ let voiceStream = null;
+ let audioCtx = null;
+ let voiceProcessor = null;
+ let voiceActive = false;
+ let voiceMode = 'near'; // 'near' or 'world'
+ let voiceDebugCount = 0;
+ const VOICE_SERVER = 'https://voicegrech.mkn8n.ru';
+
+ // Кнопка микрофона
+ const voiceBtn = document.createElement('div');
+ voiceBtn.innerHTML = '🎤