Interface InlineRenderer<D extends InlineData<D>>

All Known Implementing Classes:
InlineEntityRenderer, InlineErrorRenderer, InlineItemRenderer, InlineSpriteRenderer, PlayerHeadRenderer

public interface InlineRenderer<D extends InlineData<D>>
Renders in place of text based on the InlineData attached to the text.

You can either directly implement this interface or build off of an existing renderer either by inheritance or composition. If you make a new renderer, you'll want to register it with InlineClientAPI.addRenderer(com.samsthenerd.inline.api.client.InlineRenderer<?>).

Inline comes with the following built-in core renderers:

Check out PlayerHeadRenderer for an example of extending by composition and ModIconData for an example of re-using an existing renderer by extending the data class.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A collection of values taken from the text renderer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    charWidth(D data, net.minecraft.text.Style style, int codepoint)
    Gets the width of the render without doing the rendering.
    default GlowHandling
    Indicates preferences for how the render system should handle glow effects with this renderer.
    net.minecraft.util.Identifier
    Gets this renderer's ID.
    default boolean
    handleOwnSizing(D forData)
    Indicates if this renderer wants to handle size modifiers on its own.
    default boolean
    Indicates if this renderer will handle transparency/alpha.
    static boolean
    A small helper for checking if this renderer is being called from a chat renderer.
    static boolean
    isFlat(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.client.font.TextRenderer.TextLayerType layerType)
    A helper method for checking if a given rendering environment is for a flat UI, such as in chat, a tooltip, inventory title, or other similar cases.
    int
    render(D data, net.minecraft.client.gui.DrawContext context, int index, net.minecraft.text.Style style, int codepoint, InlineRenderer.TextRenderingContext trContext)
    Renders in place of a single codepoint/character based on the data given.
  • Field Details

  • Method Details

    • getId

      net.minecraft.util.Identifier getId()
      Gets this renderer's ID. Used primarily by the InlineData to specify which renderer to use for it.
      Returns:
      the id
    • render

      int render(D data, net.minecraft.client.gui.DrawContext context, int index, net.minecraft.text.Style style, int codepoint, InlineRenderer.TextRenderingContext trContext)
      Renders in place of a single codepoint/character based on the data given.
      Parameters:
      data - the data to render.
      context - a DrawContext with a MatrixStack set to the correct position for this character and with a VertexConsumerProvider for rendering to.
      index - the index of this character in the overall string.
      style - the style attached to the text.
      codepoint - the unicode codepoint for this character.
      trContext - a collection of values taken from the text renderer.
      Returns:
      the width that this render takes up. more or less corresponds to pixels in the default font.
    • charWidth

      int charWidth(D data, net.minecraft.text.Style style, int codepoint)
      Gets the width of the render without doing the rendering.
      Parameters:
      data - the data to render.
      style - the style attached to the text.
      codepoint - the unicode codepoint for this character.
      Returns:
      the width that this render takes up. more or less corresponds to pixels in the default font.
    • getGlowPreference

      default GlowHandling getGlowPreference(D forData)
      Indicates preferences for how the render system should handle glow effects with this renderer. Glow effects happen when a sign is clicked with a glow ink sac. Vanilla text handles this by rendering text in 8 offsets, doing this with inline renders tends to create a busy z-fighting mess. Instead, the render system can flatten the rendering to create an outline. See GlowHandling for more details.
      Parameters:
      forData - incase the handling changes based on data. This should really only be used for returning a cache id in the GlowHandling.
      Returns:
      a GlowHandling for if this renderer needs glow help.
    • handleOwnSizing

      default boolean handleOwnSizing(D forData)
      Indicates if this renderer wants to handle size modifiers on its own. The default handling should be fine for most cases as it simply scales the matrix stack before passing to the renderer.
      Parameters:
      forData - incase the handling changes based on data. In the vast majority of cases it shouldn't.
    • handleOwnTransparency

      default boolean handleOwnTransparency(D forData)
      Indicates if this renderer will handle transparency/alpha. Note that the default handling is done with RenderSystem.setShaderColor(float, float, float, float).
      Parameters:
      forData - incase the handling changes based on data. In the vast majority of cases it shouldn't.
    • isFlat

      static boolean isFlat(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.client.font.TextRenderer.TextLayerType layerType)
      A helper method for checking if a given rendering environment is for a flat UI, such as in chat, a tooltip, inventory title, or other similar cases.
      Parameters:
      matrices - the matrix stack given by the rendering env.
      layerType - text layer type for the given env. Can be found with InlineRenderer.TextRenderingContext.layerType()
      Returns:
      if the render context, with the given matrix stack, is flat or not.
    • isChatty

      static boolean isChatty()
      A small helper for checking if this renderer is being called from a chat renderer.

      NOTE: since this has to check the call stack, it's maybe not the most efficient thing in the world. Try to limit calls to it. Using isFlat(net.minecraft.client.util.math.MatrixStack, net.minecraft.client.font.TextRenderer.TextLayerType) can

      Returns:
      if this renderer is being called from a chat renderer.