package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import net.minecraft.inventory.Slot import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // Please use LorenzToolTipEvent over ItemTooltipEvent if no special EventPriority is necessary class ToolTipData { @SubscribeEvent(priority = EventPriority.LOWEST) fun onTooltip(event: ItemTooltipEvent) { val toolTip = event.toolTip ?: return val slot = lastSlot ?: return val itemStack = event.itemStack ?: return try { LorenzToolTipEvent(slot, itemStack, toolTip).postAndCatch() } catch (e: Throwable) { ErrorManager.logErrorWithData( e, "Error in item tool tip parsing or rendering detected", "toolTip" to toolTip, "slot" to slot, "slotNumber" to slot.slotNumber, "slotIndex" to slot.slotIndex, "itemStack" to itemStack, "name" to itemStack.name, "internal name" to itemStack.getInternalName(), "lore" to itemStack.getLore(), ) } } companion object { var lastSlot: Slot? = null } }