/*
let fire = [
    "soul_form",
    "hellstone_ingot",
    "thunder_fire_overload",
    "nuclear_furnace_component",
    "upgrade_templates/ignitium_ingot",
    "invert",
    "subterranodon",
    "burn",
    "attribute_fire",
    "fire_increase",
    "fire_breath",
    "art_of_forging:flame_protection",
    "art_of_forging:soul_charged",
    "insulation",
    "twilight",
    "upgrade_templates/netherite_ingot",
    "fire_dust",
    "moltengold_ingot",
    "cooked_netherite_monstrosity_meat",
    "ignitium_ingot",
    "lava_eaters_skin",
    "blaze_rod",
    "magma_cream",
    "netherite_block"
]

let lighting = [
    "damp",
    "telecore",
    "south_pole",
    "north_pole",
    "thunder",
    "essence_of_the_storm",
    "thunderous_wrath",
    "call_thunder",
    "lei_ling",
    "lightning_spell"
]
let pestilence = [
    "waste",
    "nuclear_bomb",
    "uranium_spurs",
    "radiation",
    "disorienting_gai",
    "pestilence_attribute",
    "he_huan_san",
    "lime_powder",
    "poison_immunity",
    "hua_gu_san",
    "black_death",
    "wu_bu_she",
    "twilight",
    "poison_spell",
    "poison",
    "eternal_madness",
    "black_death",
]
let radiation = [
    "hellstone_ingot",
    "nuclear_furnace_component",
    "aberration",
    "nuclear_bomb",
    "acidic_radrock",
    "uranium_spurs",
    "fissile",
    "radiation"
]
let criticalStrike = [
    "gambler",
    "gazing_pearl",
    "dong_xi",
    "kubejs_criticalStrike",
    "all_kubejs_criticalStrike",
    "red_corundum_cluster",
    "black_beetle_vocalcord",
    "tui_jin_qi",
    "machine_star"
]
let jab = [
    "jab",
    "fragment_of_eden",
    "euclidean_dagger",
    "orange_corundum_cluster",
    "connected"
]
let wither = [
    "withered_bone",
    "withered_horn",
    "wither_skeleton_skull",
    "witherite_block"
]
const typeMaps = {
    fire: fire,
    lighting: lighting,
    pestilence: pestilence,
    radiation: radiation,
    criticalStrike: criticalStrike,
    jab: jab,
    wither: wither
};

// 处理 effects，生成新数组
let processedEffects = global.all_effect.map(function (effect) {
    let types = [];

    // 遍历每个 type 列表
    for (let typeName in typeMaps) {
        let list = typeMaps[typeName];
        if (list.includes(effect.effect_name)) {
            types.push(typeName);
        }
    }

    return {
        effect_name: effect.effect_name,
        effect_length: effect.effect_length,
        group: effect.group,
        type: types.length > 0 ? types : []
    };
});

// 提示玩家
Client.player.tell("效果类型数据已更新！");

// 写入文件
JsonIO.jsjs$write('kubejs/startup_scripts/global/text.json', processedEffects);
*/

// ItemEvents.rightClicked(event => {
//     // 加载随机源类，用于生成交易报价
//     let RandomSource = Java.loadClass('net.minecraft.util.RandomSource');
//     let random = RandomSource.create();
//     let player = event.entity; // 触发事件的玩家

//     // 遍历所有已注册的村民职业
//     VillagerUtils.getProfessions().forEach(professionId => {
//         // === 新增：获取该职业对应的工作方块（POI）===
//         let aa= professionId.name()
//         console.log(aa)
//         console.log(typeof aa)

//         // 遍历该职业的 1~5 级交易
//         for (let levelNum = 1; levelNum < 6; levelNum++) {
//             let trades = VillagerUtils.getVillagerTrades(professionId, levelNum);
//             if (!trades || trades.length === 0) continue;

//             trades.forEach(trade => {
//                 let offer = trade.getOffer(player, random);
//                 if (offer) {
//                     let result = offer.getResult();
//                     let costA = offer.getBaseCostA();
//                     let costB = offer.getCostB();

//                     // console.log(`等级: ${levelNum}`);
//                     // console.log(`出售: ${result.getItem().getDescriptionId()} x${result.getCount()}`);
//                     // console.log(`价格: ${costA.getItem().getDescriptionId()} x${costA.getCount()}`);
//                     // if (!costB.isEmpty()) {
//                     //     console.log(`第二价格: ${costB.getItem().getDescriptionId()} x${costB.getCount()}`);
//                     // }
//                     // console.log(`最大交易: ${offer.getMaxUses()}, 经验: ${offer.getXp()}`);
//                     // console.log("---");
//                 }
//             });
//         }
//         console.log("---");
//         // console.log("\n"); // 职业之间空一行，提升可读性
//     });
// });


// let $VillagersHelper = Java.loadClass("jeresources.util.VillagersHelper");

// VillagerUtils.getProfessions().forEach(profession => {
//     // console.log(profession.toString());
//     if (profession.toString() == "nitwit") return
//     // let AAA = $VillagersHelper.getPoiBlocks(profession).iterator().next().block.idlet $VillagersHelper = Java.loadClass("jeresources.util.VillagersHelper");


//     let blockStates = $VillagersHelper.getPoiBlocks(profession);
//     if (!blockStates || blockStates.isEmpty()) {
//         console.log(profession + " → 无 POI 方块");
//         return;
//     }

//     // / 手动去重：用一个对象或数组记录已见过的 ID
//     let seen = {};      // 用对象模拟 Set（key 唯一）
//     let uniqueList = []; // 存储去重后的 ID

//     let iter = blockStates.iterator();
//     while (iter.hasNext()) {
//         let id = iter.next().block.id;
//         if (!seen[id]) {
//             seen[id] = true;
//             uniqueList.push(id);
//         }
//     }

//     // 拼接字符串
//     let idList = "";
//     for (let i = 0; i < uniqueList.length; i++) {
//         if (i > 0) idList += ", ";
//         idList += uniqueList[i];
//     }

//     console.log(profession.toString() + " → 工作方块: " + idList);
// });






// let processedEffects = [];
// global.materials.forEach(effect => {
//     let ftb_id = effect.ftb_id; // 原始值

//     global.materials_ftbid.forEach(e => {
//         if (e.name == effect.material) {
//             ftb_id = ""; // 或 null / "0"
//         }
//     });

//     processedEffects.push({
//         material: effect.material,
//         ftb_id: ftb_id,   // ✅ 字段名应为 ftb_id
//         tags: effect.tags
//     });
// });

// console.log(processedEffects);
// console.log(processedEffects)
// let materials_ftbid_String1 = `global.materials1 = ${JSON.stringify(processedEffects, null, '\t')};`;

// JSIO.write("kubejs/startup_scripts/global/material_ftbid1.js", materials_ftbid_String1)