Class CustomTooltipManager

java.lang.Object
com.samsthenerd.inline.tooltips.CustomTooltipManager

public class CustomTooltipManager extends Object
An item-less custom tooltip system.

By default Minecraft only supports 3 types of HoverEvents: Text, Item, and Entity (which is kinda just text again). But, Item tooltips have a pretty good tooltip system with TooltipData and TooltipComponents. Unfortunately, using those requires adding a new item, which is rather inconvenient, so instead we hijack an arbitrary vanilla item to throw our tooltip system on.

You can use these tooltips in hover events by making an item based hover event out of the dummy itemstack from getForTooltip(CustomTooltipProvider, Object).

Note that this isn't necessarily a part of the core Inline API, just a useful system used for the built in player facing features.

See Also:
  • Field Details

    • HIJACKED_ITEM

      public static final net.minecraft.item.Item HIJACKED_ITEM
  • Constructor Details

    • CustomTooltipManager

      public CustomTooltipManager()
  • Method Details

    • getForTooltip

      public static <T> net.minecraft.item.ItemStack getForTooltip(CustomTooltipManager.CustomTooltipProvider<T> provider, T content)
      Gets a dummy itemstack hijacked with the data to display the tooltip provided by the provider for the given content.
      Type Parameters:
      T - Type of the content that the provider handles
      Parameters:
      provider - A tooltip provider that can handle the given content.
      content - Arbitrary data to be handled by the provider.
      Returns:
      an itemstack that will have a tooltip given by our provider and content.
    • getProvider

      @Nullable public static CustomTooltipManager.CustomTooltipProvider<?> getProvider(net.minecraft.item.ItemStack stack)
    • getTooltipText

      @Nullable public static <T> List<net.minecraft.text.Text> getTooltipText(net.minecraft.item.ItemStack stack)
    • getTooltipData

      @Nullable public static <T> Optional<net.minecraft.client.item.TooltipData> getTooltipData(net.minecraft.item.ItemStack stack)
    • registerProvider

      Registers a provider.
      Type Parameters:
      T - type that the provider handles
      Parameters:
      provider -
      Returns:
      the same provider.