Class TooltipFormatterRegistry

java.lang.Object
johnsmith.enchantmentcore.api.tooltip.TooltipFormatterRegistry

public class TooltipFormatterRegistry extends Object
Client-side registry and dispatch pipeline for EnchantmentTooltipFormatter implementations.

Invoked by ItemStackMixin when rendering minecraft:enchantments or minecraft:stored_enchantments tooltip components. Evaluates enabled formatters in descending priority order and falls back to Enchantment.getFullname(Holder, int) if no formatter handles the entry.

  • Constructor Details

    • TooltipFormatterRegistry

      public TooltipFormatterRegistry()
  • Method Details

    • registerFormatter

      public static void registerFormatter(EnchantmentTooltipFormatter formatter)
      Registers an EnchantmentTooltipFormatter and marks the priority order as dirty.
      Parameters:
      formatter - The formatter instance to register.
    • getFormatted

      public static List<net.minecraft.network.chat.Component> getFormatted(net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment, int level, net.minecraft.world.item.ItemStack itemStack)
      Evaluates registered, enabled EnchantmentTooltipFormatters in descending priority order and returns the first non-empty formatted tooltip component list for the given enchantment.
      Parameters:
      enchantment - The target enchantment Holder.
      level - The active level of the enchantment.
      itemStack - The ItemStack hosting the enchantment.
      Returns:
      A list of formatted Component lines, or a singleton list containing Enchantment.getFullname(Holder, int) if unhandled.