Exemple #1
0
        // This method is an event listener. It will be called when an item tooltip is rendered.
        // The ItemTooltipEvent parameter contains the original tooltip data.
        public void OnItemTooltip(ItemTooltipEvent evt)
        {
            // Check if the item is not null. Also checks if the tooltip already has price info.
            // In this case, -1 means there is no price data in the tooltip.
            if (evt.Item != null && evt.MoneyToShow == -1)
            {
                // Uses bookcase's ItemUtils to get the price of the item.
                int price = ItemUtils.GetSellPrice(evt.Item, true);

                // Checks if the item actually has a sell value.
                if (price > 0)
                {
                    // Changes the amount of money shown on the tooltip to reflect the price.
                    // The money symbol graphic is already part of the vanilla tooltip. It's normally just disabled (-1).
                    // By changing this value to something greater than 0, the info becomes visible.
                    evt.MoneyToShow = price;
                }
            }
        }