// priority: 0

onEvent('item.tooltip', tooltip => {

    /*colors
    §1 - dark blue
    §2 - dark green
    §3 - dark aqua
    §4 - dark red
    §5 - purple
    §6 - orange
    §8 - dark gray
    §9 - blue
    §0 - black
    §a - light green
    §b - light aqua
    §c - light red
    §d - pink
    §e - light yellow
    §f - white*/

    //compressium
    for (let i = 1; i <= 9; i++) {
        tooltip.add(
            RegExp(`compressium.*_${i}`),
            Text.gray(
                `Contains ${Math.pow(9, i)
                    .toString()
                    .replace(/\B(?=(\d{3})+(?!\d))/g, ',')} blocks`
            )
        )
    }

    //nbt print
    tooltip.addAdvanced(Ingredient.all, (item, advanced, text) => {
        if (advanced) {
            if (item.nbt) {
                if (tooltip.alt) {
                    text.add(Text.darkGray('NBT: ').append(Text.gray(item.nbt)))
                } else {
                    text.add(Text.darkGray('Hold [').append(Text.gray('ALT')).append(Text.darkGray('] for NBT')))
                }
            }
        }
    })

    //tconstruct
    tooltip.add('tconstruct:part_builder', 'Can be made out of any planks')
    tooltip.add('tconstruct:tinker_station', 'Can be made out of any planks')
    tooltip.add('tconstruct:crafting_station', 'Can be made out of any log')
    tooltip.add(['tconstruct:tinkers_anvil','tconstruct:scorched_anvil'], 'Can be made out of any alloy block')
    tooltip.add(/minecraft:(leather|chainmail|wooden|stone|iron|golden|diamond|netherite)_(sword|shovel|(pick)?axe|hoe|helmet|chestplate|leggings|boots)/, [
        Text.red("1 Durability. This item is for crafting only!"),
    ]);
    tooltip.add(/minecraft:(bow|crossbow)/, [
        Text.red("1 Durability. This item is for crafting only!"),
    ]);

    //ceramics
    tooltip.add('ceramics:clay_plate',['Can be used to create Small Plate Casts'])
    tooltip.add('ceramics:unfired_clay_plate',['Can be used to create Small Plate Casts after fired in a furnace'])

    //miniutilities
    tooltip.add('miniutilities:unstable_ingot',[ Text.green('This WILL kill you, blow up, and lose all your crafting materials to make this if you hold this too long') ])

	//mechanisms
	let main_assembly = (id, stage) => tooltip.add(id, [`§7Main Assembly: §6Chapter ${stage}`, '§8Consider automating this item'])
	main_assembly('kubejs:kinetic_mechanism', "2")
	main_assembly('kubejs:sealed_mechanism', "3")
	main_assembly('create:precision_mechanism', "4")
	main_assembly('kubejs:inductive_mechanism', "5")
	main_assembly('kubejs:calculation_mechanism', "6")
	main_assembly('kubejs:abstruse_mechanism', "7")
	
	//ae2
    tooltip.add('appliedenergistics2:facade', 'Using the same recipe, you can make a facade out of almost any block')

    //framed compact drawers
    tooltip.add(/framedcompactdrawers.*/, `§eCan be framed through crafting table`)

    //cobblefordays
    //ticks are stored in defaultconfigs/cobblefordays-server.toml
    const ticks = {
        tier1: 200,
        tier2: 100,
        tier3: 50,
        tier4: 25,
        tier5: 10
    }
    const items = [
        "cobblefordays:tier_1", "cobblefordays:tier_2", "cobblefordays:tier_3", "cobblefordays:tier_4", "cobblefordays:tier_5"
    ]
    items.forEach((item, i) => {
        const tick = ticks[`tier${i + 1}`]
        tooltip.add(item, `§7Generates 1 cobblestone per §6${tick / 20} §7second(s)`)
    })

    //power pots
    const pots = [
        { energy: 500, output: 16 },
        { energy: 1000, output: 32 },
        { energy: 1500, output: 48 },
        { energy: 2000, output: 64 },
    ]
    pots.forEach((pot, i) => {
        tooltip.add(`ftb-power-pots:power_pot_mk${i + 1}`, `§7Energy (FE) Per Tick: §6${pot.energy}`)
        tooltip.add(`ftb-power-pots:power_pot_mk${i + 1}`, `§7Items Per Output: §6${pot.output}`)
    })

    //cloud in a bottle
    tooltip.add('quark:bottled_cloud', '§6Angel Block §7alternative. Reach clouds and fill the bottle with it.')

})