const FIRE_BLOCKS = [
    "minecraft:fire",
    "minecraft:campfire",
    "minecraft:soul_campfire",
    "minecraft:magma",
    "minecraft:lava",
    "minecraft:flowing_lava",
    "farmersdelight:stove",
    "brewinandchewin:heating_cask"
];
const ICE_BLOCKS = [
    "minecraft:ice",
    "minecraft:packed_ice",
    "minecraft:blue_ice",
    "brewinandchewin:ice_crate"
];

/**
 * Получить числовой тег температуры для UI (0=cold, 1=chilly, 2=warm, 3=hot, undefined=normal)
 * @param {Entity} entity - Сущность типа 'brewinandchewin:keg'
 * @param {number} [radius=2] - Радиус поиска блоков
 * @returns {number|undefined} - 0,1,2,3 или undefined
 */
export function getTemperatureTag(entity, radius = 2) {
    if (!entity || !entity.dimension || !entity.location) return undefined; // исправлено!
    const { x, y, z } = entity.location;
    let fire_count = 0;
    let ice_count = 0;
    for (let dx = -radius; dx <= radius; dx++) {
        for (let dy = -radius; dy <= radius; dy++) {
            for (let dz = -radius; dz <= radius; dz++) {
                const nx = Math.floor(x + dx);
                const ny = Math.floor(y + dy);
                const nz = Math.floor(z + dz);
                const block = entity.dimension.getBlock({ x: nx, y: ny, z: nz });
                if (!block) continue;
                const blockId = block.typeId;
                if (FIRE_BLOCKS.includes(blockId)) fire_count++;
                if (ICE_BLOCKS.includes(blockId)) ice_count++;
            }
        }
    }
    const diff = fire_count - ice_count;
    if (diff <= -2) return 1; // cold
    if (diff === -1) return 2; // chilly
    if (diff === 1) return 3; // warm
    if (diff >= 2) return 4; // hot
    return 0; // normal
} 