import { EntityHealthComponent, system, world, EntityEquippableComponent, ItemDurabilityComponent, ItemStack, EquipmentSlot, EntityInventoryComponent } from "@minecraft/server";


const lore_item = {
    "minecraft:shield": ["§r§cSlowness IV §9when used with Broadsword"],
    "fiery:totem_of_undying": ["§r§dRegeneration I §7(Offhand) \n§c+8 HP"],
    "fiery:cursed_totem": ["§r§mSelf-destruct & kill nearest entity"],
    "fiery:crown": ["§r§c+20 HP"],

    "fiery:iron_broadsword": ["§r§7Demolition Leap §c(15 Damage)§9\nCD 20s"],
    "fiery:diamond_broadsword": ["§r§7Demolition Leap §c(16 Damage)§9\nCD 20s"],
    "fiery:netherite_broadsword": ["§r§7Demolition Leap §c(17 Damage)§9\nCD 20s"],
    "fiery:hero_broadsword": ["§r§6Demolition Leap §c(20 Damage)§9\nCD 20s"],
    "fiery:hero_broadsword_copy": ["§r§eReward"],

    "fiery:iron_dagger": ["§r§7Dash §f(+4 Blocks)§9\nCD 3.6s"],
    "fiery:diamond_dagger": ["§r§7Dash §f(+5 Blocks)§9\nCD 2.8s"],
    "fiery:netherite_dagger": ["§r§7Dash §f(+6 Blocks)§9\nCD 2s"],
    "fiery:shadow_dagger": ["§r§4Shadow Dash §f(+8 Blocks)§9\nCD 1.5s"],

    "fiery:iron_spear": ["§r§7Damage Area §c(10 Damage)§9\nCD 5s"],
    "fiery:diamond_spear": ["§r§7Damage Area §c(12 Damage)§9\nCD 5s"],
    "fiery:netherite_spear": ["§r§7Damage Area §c(14 Damage)§9\nCD 5s"],
    "fiery:spear_of_thunder": ["§r§eLightning Strike §c(40 Damage)§9\nCD 24s"],
    "fiery:spear_of_thunder_copy": ["§r§eReward"],

    "fiery:iron_halbert": ["§r§7Stun §c(1 Second)§9\nCD 12s"],
    "fiery:diamond_halbert": ["§r§7Stun §c(2 Seconds)§9\nCD 12s"],
    "fiery:netherite_halbert": ["§r§7Stun §c(3 Seconds)§9\nCD 12s"],
    "fiery:void_breaker": ["§r§4Stun + Wither Effect §c(3 Seconds)§9\nCD 15s"],
    "fiery:void_breaker_copy": ["§r§eReward"],

    "fiery:claymore": ["§r§7Super Jump §f(Resistance I)§9\nCD 12s"],
    "fiery:darksteel_claymore": ["§r§7Super Jump §f(Resistance II)§9\nCD 12s"],
    "fiery:ender_claymore": ["§r§5Teleport §c(Instant Regen)§9\nCD 24s"],

    "fiery:steel_helmet": ["§r§9Immune Poison"],
    "fiery:steel_chestplate": ["§r§9Immune Poison"],
    "fiery:steel_leggings": ["§r§9Immune Poison"],
    "fiery:steel_boots": ["§r§9Immune Poison"],

    "fiery:darksteel_helmet": ["§r§9Immune Poison & Wither"],
    "fiery:darksteel_chestplate": ["§r§9Immune Poison & Wither"],
    "fiery:darksteel_leggings": ["§r§9Immune Poison & Wither"],
    "fiery:darksteel_boots": ["§r§9Immune Poison & Wither"],

    "fiery:basic_smithing_upgrade": ["§r§7Iron Upgrade"],
    "fiery:advanced_smithing_upgrade": ["§r§7Diamond Upgrade"],
    "fiery:cursed_smithing_upgrade": ["§r§4Cursed Upgrade"],
    "fiery:blessed_smithing_upgrade": ["§r§eBlessed Upgrade"],
    "fiery:ancient_smithing_upgrade": ["§4§r§3Ancient Upgrade"],
    "fiery:ender_smithing_upgrade": ["§4§r§5Ender Upgrade"],
    "fiery:smithing_upgrade_base": ["§r§7Used to create smithing templates"],

    "fiery:sculk_horn": ["§r§9Required:\n§3Echo Shard\nWarden Soul §7(Offhand)"],
    "fiery:healing_potion1": ["§r§7Instant Heal (+4 HP)"],
    "fiery:healing_potion2": ["§r§7Instant Heal (+8 HP)"],
    "fiery:tough_potion1": ["§r§7Resistance I (1:30)"],
    "fiery:tough_potion2": ["§r§7Resistance II (0:45)"],
    "fiery:purification_potion1": ["§r§7Immune to all negative effects for 30 seconds"],
    "fiery:purification_potion2": ["§r§7Immune to all negative effects for 60 seconds"],

    "fiery:warden_soul_contract": ["§r§7Used to make a contract with Reanimated Warden"],
    "fiery:vex_soul_contract": ["§r§7Used to make a contract with Vex"],

    "fiery:katana": ["§r§9Not Finished"],
    "fiery:knuckles": ["§r§9Not Finished"],
    "fiery:iron_longsword": ["§r§9Not Finished"],

};

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        const inventory = player.getComponent("inventory").container;
        for (let i = 0; i < 36; i++) {
            const slot = inventory.getSlot(i);
            if (!slot.getItem() || !lore_item[slot.typeId] || slot.getLore().length)
                continue;

            slot.setLore(lore_item[slot.typeId]);
        }
    }
}, 4);