import net.minecraft.item.ItemStack
import net.minecraft.util.text.TextFormatting
import net.minecraftforge.event.entity.player.ItemTooltipEvent

class ToolTipAddition {
    ItemStack item
    String tt
    int index

    ToolTipAddition(ItemStack stack = ItemStack.EMPTY, String tt = "", int index = -1) {
        this.item = stack
        this.tt = tt
        this.index = index
    }
}

ttmap = [] as ToolTipAddition[];

def injectToolTip( item, String tt, int index = -1 ) {
    ttmap = ttmap.plus(new ToolTipAddition(item, tt, index));
}

event_manager.listen { ItemTooltipEvent event ->
    for (ToolTipAddition tta in ttmap) {
        if (ItemStack.areItemsEqual(event.getItemStack(), tta.item)) {
            (tta.index == -1) ? event.getToolTip().add(tta.tt) : event.getToolTip().add(tta.index, tta.tt)
        }
    }
}

// Forget this exists
BLACK = TextFormatting.BLACK.toString()
DARK_BLUE = TextFormatting.DARK_BLUE.toString()
DARK_GREEN = TextFormatting.DARK_GREEN.toString()
DARK_AQUA = TextFormatting.DARK_AQUA.toString()
DARK_RED = TextFormatting.DARK_RED.toString()
DARK_PURPLE = TextFormatting.DARK_PURPLE.toString()
GOLD = TextFormatting.GOLD.toString()
GRAY = TextFormatting.GRAY.toString()
DARK_GRAY = TextFormatting.DARK_GRAY.toString()
BLUE = TextFormatting.BLUE.toString()
GREEN = TextFormatting.GREEN.toString()
AQUA = TextFormatting.AQUA.toString()
RED = TextFormatting.RED.toString()
LIGHT_PURPLE = TextFormatting.LIGHT_PURPLE.toString()
YELLOW = TextFormatting.YELLOW.toString()
WHITE = TextFormatting.WHITE.toString()
OBFUSCATED = TextFormatting.OBFUSCATED.toString()
BOLD = TextFormatting.BOLD.toString()
STRIKETHROUGH = TextFormatting.STRIKETHROUGH.toString()
UNDERLINE = TextFormatting.UNDERLINE.toString()
ITALIC = TextFormatting.ITALIC.toString()
RESET = TextFormatting.RESET.toString()

///Commonly used "Mixes" of colors & formatting - Feel Free to add

LORE = TextFormatting.GRAY.toString() + TextFormatting.ITALIC.toString()
LOREYELLOW = TextFormatting.YELLOW.toString() + TextFormatting.ITALIC.toString()

// Examples
// injectToolTip(item('minecraft:apple'), GOLD + 'very yummy') // inserts 'very yummy' at the end of tt
// injectToolTip(item('minecraft:pumpkin'), 'not eddible in this form', 0) // inserts 'not eddible in this form' at the beginning of tt



/////// ALL TOOLTIPS //////
//Storage Core 1
injectToolTip(item('tjcore:storage_core_1'), LORE + 'Mighty Storage',1)
injectToolTip(item('tjcore:storage_core_1'), LORE + 'in microscopic form',2 )

injectToolTip(item('minecraft:apple'), GOLD + ITALIC + 'very yummy' + GRAY + 'or so we thought')

//Magic Warnings
injectToolTip(item('botania:twigwand'), LORE + 'Botania Intergration WIP - Progress at your own risk!',1)
injectToolTip(item('thaumcraft:thaumonomicon'), LORE + 'Thaumcraft Intergration WIP - Progress at your own risk!',1)
injectToolTip(item('astralsorcery:itemwand').withNbt(["astralsorcery": []]), LORE + 'Astral Intergration WIP - Progress at your own risk!',1)
injectToolTip(item('thaumcraft:nugget', 9), LORE + 'DISABLED - Look at Arachnite Ore - Crucible will be removed eventually',1)
injectToolTip(item('gregtech:machine', 1019), LORE + 'Someone once said "A literal line... of asses"',1)
injectToolTip(item('ironbackpacks:backpack'), RED + BOLD + 'WARNING! ' + GRAY + 'Do not update backpacks with items in them!',1)
injectToolTip(item('appliedenergistics2:part', 260), RED + BOLD + 'WARNING! ' + GRAY + 'Busses are laggy! Please Resort to using Interfaces/Storage Busses!',1)
injectToolTip(item('appliedenergistics2:part', 240), RED + BOLD + 'WARNING! ' + GRAY + 'Busses are laggy! Please Resort to using Interfaces/Storage Busses!',1)
