// Priority: 1
/**
  
  █▀▄▀█ █▀█ █▄░█ █░█ █▀▄▀█ █▀▀ █▄░█ ▀█▀ ▄▀█ █░░   █▀▀ ▀▄▀ █▀█ █▀▀ █▀█ █ █▀▀ █▄░█ █▀▀ █▀▀
  █░▀░█ █▄█ █░▀█ █▄█ █░▀░█ ██▄ █░▀█ ░█░ █▀█ █▄▄   ██▄ █░█ █▀▀ ██▄ █▀▄ █ ██▄ █░▀█ █▄▄ ██▄

  ☻/  * @file JEI script to add item tooltips
  /▌  * @copyright KnightDexx's Modded Minecraft World | ModernGamingWorld | GeekTechMedia
  /▌  * Modified by @Cyn-SolveroftheAbsoluteGremlins on Discord
  /\

  PORTED: 1.20.1 → 1.21.1 NeoForge
  - ItemEvents.modifyTooltips() is unchanged in KubeJS 1.21
  - Text.of() color chaining API is unchanged
  - Added Platform.isLoaded() guards on every mod-specific section

*/
ItemEvents.modifyTooltips(event => {

  //======= Eccentric Tome Books =======
  if (Platform.isLoaded('patchouli'))
    event.add('patchouli:guide_book', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('ars_nouveau'))
    event.add('ars_nouveau:worn_notebook', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('alexsmobs'))
    event.add('alexsmobs:animal_dictionary', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('alexscaves'))
    event.add('alexscaves:cave_book', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('ftbquests'))
    event.add('ftbquests:book', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('immersiveengineering'))
    event.add('immersiveengineering:manual', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('botania'))
    event.add('botania:lexicon', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('rftoolsbase'))
    event.add('rftoolsbase:manual', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('forestry'))
    event.add('forestry:foresters_manual', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('cookingforblockheads'))
    event.add('cookingforblockheads:recipe_book', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('securitycraft'))
    event.add('securitycraft:sc_manual', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('croptopia'))
    event.add('croptopia:guide', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('enigmaticlegacy'))
    event.add('enigmaticlegacy:the_acknowledgment', [Text.of('This book is already included within your Eccentric Tome').yellow()])
  if (Platform.isLoaded('eidolon_repraised'))
    event.add('eidolon_repraised:codex', [Text.of('This book is already included within your Eccentric Tome').yellow()])

  //======= Mystical Agriculture =======
  if (Platform.isLoaded('mysticalagriculture')) {
    event.add('mysticalagriculture:watering_can', [
      [Text.of('Players Only').green()],
      [Text.of('Not Automatable').darkGreen()]
    ])
    event.add('mysticalagriculture:inferium_watering_can', [
      [Text.of('Players Only').green()],
      [Text.of('Not Automatable').darkGreen()]
    ])
    event.add('mysticalagriculture:prudentium_watering_can', [
      [Text.of('Players Only').green()],
      [Text.of('Not Automatable').darkGreen()]
    ])
    event.add('mysticalagriculture:tertium_watering_can', [
      [Text.of('Players Only').green()],
      [Text.of('Not Automatable').darkGreen()]
    ])
    event.add('mysticalagriculture:imperium_watering_can', [
      [Text.of('Players Only').green()],
      [Text.of('Not Automatable').darkGreen()]
    ])
  }

  //======= RS Infinity Booster =======
  if (Platform.isLoaded('rsinfinitybooster')) {
    event.add('rsinfinitybooster:infinity_card', [
      Text.of('Infinite range for RS wireless'),
      Text.of('Only works in the same dimension')
    ])
    event.add('rsinfinitybooster:dimension_card', [
      Text.of('Infinite range for RS wireless'),
      Text.of('Works across dimensions')
    ])
  }

  //======= Pipez =======
  if (Platform.isLoaded('pipez')) {
    event.add('pipez:item_pipe', [
      [Text.of('Default:'), ' ', Text.of('4'), ' ', Text.of('items/20t')],
      [Text.of('Basic:'), ' ', Text.of('8'), ' ', Text.of('items/15t')],
      [Text.of('Improved:').gold(), ' ', Text.of('16').yellow(), ' ', Text.of('items/10t').gold()],
      [Text.of('Advanced:').darkAqua(), ' ', Text.of('32').aqua(), ' ', Text.of('items/5t').darkAqua()],
      [Text.of('Ultimate:').darkGray(), ' ', Text.of('64').gray(), ' ', Text.of('items/t').darkGray()],
      [Text.of('Infinity:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('items/t').darkPurple()],
    ])
    event.add('pipez:fluid_pipe', [
      [Text.of('Default:'), ' ', Text.of('50'), ' ', Text.of('mB/t')],
      [Text.of('Basic:'), ' ', Text.of('100'), ' ', Text.of('mB/t')],
      [Text.of('Improved:').gold(), ' ', Text.of('500').yellow(), ' ', Text.of('mB/t').gold()],
      [Text.of('Advanced:').darkAqua(), ' ', Text.of('2,000').aqua(), ' ', Text.of('mB/t').darkAqua()],
      [Text.of('Ultimate:').darkGray(), ' ', Text.of('10,000').gray(), ' ', Text.of('mB/t').darkGray()],
      [Text.of('Infinity:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('mB/t').darkPurple()],
    ])
    event.add('pipez:gas_pipe', [
      [Text.of('Default:'), ' ', Text.of('200'), ' ', Text.of('mB/t')],
      [Text.of('Basic:'), ' ', Text.of('400'), ' ', Text.of('mB/t')],
      [Text.of('Improved:').gold(), ' ', Text.of('2,000').yellow(), ' ', Text.of('mB/t').gold()],
      [Text.of('Advanced:').darkAqua(), ' ', Text.of('8,000').aqua(), ' ', Text.of('mB/t').darkAqua()],
      [Text.of('Ultimate:').darkGray(), ' ', Text.of('40,000').gray(), ' ', Text.of('mB/t').darkGray()],
      [Text.of('Infinity:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('mB/t').darkPurple()],
    ])
    event.add('pipez:energy_pipe', [
      [Text.of('Default:'), ' ', Text.of('256'), ' ', Text.of('FE/t')],
      [Text.of('Basic:'), ' ', Text.of('1,024'), ' ', Text.of('FE/t')],
      [Text.of('Improved:').gold(), ' ', Text.of('8,192').yellow(), ' ', Text.of('FE/t').gold()],
      [Text.of('Advanced:').darkAqua(), ' ', Text.of('32,768').aqua(), ' ', Text.of('FE/t').darkAqua()],
      [Text.of('Ultimate:').darkGray(), ' ', Text.of('131,072').gray(), ' ', Text.of('FE/t').darkGray()],
      [Text.of('Infinity:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('FE/t').darkPurple()],
    ])

    //======= Pipez Upgrades =======
    event.add('pipez:basic_upgrade', [
      [Text.of('Item:'), ' ', Text.of('8'), ' ', Text.of('items/t')],
      [Text.of('Fluid:'), ' ', Text.of('100'), ' ', Text.of('mB/t')],
      [Text.of('Gas:'), ' ', Text.of('400'), ' ', Text.of('mB/t')],
      [Text.of('Energy:'), ' ', Text.of('1,024'), ' ', Text.of('FE/t')],
    ])
    event.add('pipez:improved_upgrade', [
      [Text.of('Item:').gold(), ' ', Text.of('16').yellow(), ' ', Text.of('items/t').gold()],
      [Text.of('Fluid:').gold(), ' ', Text.of('500').yellow(), ' ', Text.of('mB/t').gold()],
      [Text.of('Gas:').gold(), ' ', Text.of('2,000').yellow(), ' ', Text.of('mB/t').gold()],
      [Text.of('Energy:').gold(), ' ', Text.of('8,192').yellow(), ' ', Text.of('FE/t').gold()],
    ])
    event.add('pipez:advanced_upgrade', [
      [Text.of('Item:').darkAqua(), ' ', Text.of('32').aqua(), ' ', Text.of('items/t').darkAqua()],
      [Text.of('Fluid:').darkAqua(), ' ', Text.of('2,000').aqua(), ' ', Text.of('mB/t').darkAqua()],
      [Text.of('Gas:').darkAqua(), ' ', Text.of('8,000').aqua(), ' ', Text.of('mB/t').darkAqua()],
      [Text.of('Energy:').darkAqua(), ' ', Text.of('32,768').aqua(), ' ', Text.of('FE/t').darkAqua()],
    ])
    event.add('pipez:ultimate_upgrade', [
      [Text.of('Item:').darkGray(), ' ', Text.of('64').gray(), ' ', Text.of('items/t').darkGray()],
      [Text.of('Fluid:').darkGray(), ' ', Text.of('10,000').gray(), ' ', Text.of('mB/t').darkGray()],
      [Text.of('Gas:').darkGray(), ' ', Text.of('40,000').gray(), ' ', Text.of('mB/t').darkGray()],
      [Text.of('Energy:').darkGray(), ' ', Text.of('131,072').gray(), ' ', Text.of('FE/t').darkGray()],
    ])
    event.add('pipez:infinity_upgrade', [
      [Text.of('Item:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('items/t').darkPurple()],
      [Text.of('Fluid:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('mB/t').darkPurple()],
      [Text.of('Gas:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('mB/t').darkPurple()],
      [Text.of('Energy:').darkPurple(), ' ', Text.of('2,147,483,647').lightPurple(), ' ', Text.of('FE/t').darkPurple()],
    ])
  }

  //======= Enderstorage =======
  if (Platform.isLoaded('enderstorage')) {
    event.add('enderstorage:ender_chest', [
      [Text.of('Cross-dimensional wireless item transfer to any chest on the same channel.').gold()],
      [Text.of('Use dye on the colored bars to set the channel.').gold()],
      [Text.of('Use a diamond on the latch to switch to private channel.').gold()],
    ])
    event.add('enderstorage:ender_tank', [
      [Text.of('Cross-dimensional wireless item transfer to any chest on the same channel.').gold()],
      [Text.of('Use dye on the colored bars to set the channel.').gold()],
      [Text.of('Use a diamond on the latch to switch to private channel.').gold()],
    ])
  }

  //======= Vanilla (always safe) =======
  event.add('minecraft:smithing_table', [
    [Text.of('The default recipe for this item has been disabled and can now be discovered through exploration.').gold()]
  ])
  event.add('minecraft:obsidian', [
    [Text.of('The default way to make a nether portal by lighting Obsidian frame is disabled. Please use the Nether Painting!!').gold()]
  ])

  //======= Minecraft Buckets =======
  event.add('minecraft:water_bucket', [
    [Text.of('The water buckets are stackable to save the space in the inventory.').gold()],
    [Text.of('WARNING:').darkRed()],
    [Text.of('By using them as entire stack they turns into one singular empty bucket.').darkPurple()],
    [Text.of('Use them one by one from the stack.').darkPurple()],
  ])
  event.add('minecraft:lava_bucket', [
    [Text.of('Lava buckets can be condensed now! Crouch-right-click to change modes.').gold()],
    [Text.of('Filling acts as a normal bucket, you need buckets in your off-hand.').gold()],
    [Text.of('Emptying acts as a normal lava bucket, your buckets are refunded.').gold()],
    [Text.of('Un-condense the buckets before using in furnaces, or void the lava.').darkRed()],
  ])

  //======= Enigmatic Legacy =======
  if (Platform.isLoaded('enigmaticlegacy')) {
    event.add('enigmaticlegacy:earth_heart', [
      [Text.of('100% drop chance by killing a Wither.').gold()],
      [Text.of('10% drop chance by killing Vex.').gold()],
      [Text.of('5% drop chance by killing Wither Skeleton.').gold()]
    ])
    event.add('enigmaticlegacy:abyssal_heart', [Text.of('100% drop chance by killing a Warden.').gold()])
  }

  //======= Apotheotic Additions =======
  if (Platform.isLoaded('apotheotic_additions')) {
    event.add('apotheotic_additions:apotheotic_coin', [
      [Text.of('Apotheotic coins are located in rogue spawners,').green()],
      [Text.of('they can also be traded from the Wandering Trader.').green()]
    ])
    event.add('apotheotic_additions:infused_coin', [
      [Text.of('Apotheotic coins are located in rogue spawners,').green()],
      [Text.of('they can also be traded from the Wandering Trader.').green()]
    ])
    event.add('apotheotic_additions:ascended_coin', [
      [Text.of('Apotheotic coins are located in rogue spawners,').green()],
      [Text.of('they can also be traded from the Wandering Trader.').green()]
    ])
  }

  //======= Allthemodium =======
  if (Platform.isLoaded('allthemodium')) {
    event.add('allthemodium:teleport_pad', [
      Text.of('Place the pad down in the specified Dimension'),
      Text.of('Sneak Right Click with both hands empty to teleport'),
      Text.of('§aOverworld to Mining Dimension'),
      Text.of('§cThe Nether to The Other'),
      Text.of('§dThe End to The Beyond')
    ])
  }

  //======= Enigmatic Addons =======
  if (Platform.isLoaded('enigmaticaddons')) {
    event.add('enigmaticaddons:lost_engine', [
      [Text.of('Use it with caution.').darkRed()],
      [Text.of('It voids items with durability upon death by lightning.').lightPurple()]
    ])
  }

  //======= Refined Storage + Extra Disks =======
  let warningMessageLine1 = 'Warning: Please do not store too many NBT items.'
  let warningMessageLine2 = 'Use external storage for tools, weapons, armor, etc.'

  if (Platform.isLoaded('refinedstorage')) {
    let rsParts = [
      'refinedstorage:1k_storage_part',
      'refinedstorage:4k_storage_part',
      'refinedstorage:16k_storage_part',
      'refinedstorage:64k_storage_part',
    ]
    rsParts.forEach(part => {
      event.add(part, [
        [Text.of(warningMessageLine1).darkRed()],
        [Text.of(warningMessageLine2).lightPurple()]
      ])
    })
  }

  if (Platform.isLoaded('extradisks')) {
    let extraParts = [
      'extradisks:256k_item_storage_part',
      'extradisks:1024k_item_storage_part',
      'extradisks:4096k_item_storage_part',
      'extradisks:16384k_item_storage_part',
      'extradisks:65536k_item_storage_part',
      'extradisks:262144k_item_storage_part',
      'extradisks:1048576k_item_storage_part',
      'extradisks:infinite_item_storage_part'
    ]
    extraParts.forEach(part => {
      event.add(part, [
        [Text.of(warningMessageLine1).darkRed()],
        [Text.of(warningMessageLine2).lightPurple()]
      ])
    })
  }

})