Interface PreviewProvider

All Known Implementing Classes:
BlockEntityPreviewProvider, EmptyPreviewProvider

public interface PreviewProvider
Describes preview properties for a registered set of items.
Since:
1.3.0
  • Method Details

    • shouldDisplay

      boolean shouldDisplay(PreviewContext context)
      Queries if the preview window should be displayed for the given context. Should return false if the inventory is empty.
      Parameters:
      context - The preview context.
      Returns:
      Whether the preview should be displayed.
      Since:
      2.0.0
    • getInventory

      List<net.minecraft.world.item.ItemStack> getInventory(PreviewContext context)
      Fetches the items to be displayed in the preview.
      Parameters:
      context - The preview context.
      Returns:
      The list of items, may not be null or contain null elements.
      Since:
      2.0.0
    • getInventoryMaxSize

      int getInventoryMaxSize(PreviewContext context)
      Returns the maximum amount of slots this preview can display.
      Parameters:
      context - The preview context.
      Returns:
      The maximum inventory size for the given stack.
      Since:
      2.0.0
    • getMaxRowSize

      default int getMaxRowSize(PreviewContext context)
      The maximum number of item stacks to be displayed in a row in full preview mode.
      Parameters:
      context - The preview context.
      Returns:
      the row size, defaults to the max row size in config if 0.
      Since:
      2.0.0
    • getCompactMaxRowSize

      default int getCompactMaxRowSize(PreviewContext context)
      The maximum number of item stacks to be displayed in a row in compact preview mode.
      Parameters:
      context - The preview context.
      Returns:
      the row size in compact mode, defaults to the max row size in config if 0.
      Since:
      5.2.0
    • isFullPreviewAvailable

      default boolean isFullPreviewAvailable(PreviewContext context)
      Returns whether this provider supports full preview mode.
      Parameters:
      context - The preview context.
      Returns:
      If false, compact mode will be the only type of preview.
      Since:
      2.0.0
    • showTooltipHints

      default boolean showTooltipHints(PreviewContext context)
      Should hint be shown in the item's tooltip?
      Parameters:
      context - The preview context.
      Returns:
      whether the hints should be shown.
      Since:
      2.0.0
    • getTooltipHintLangKey

      default String getTooltipHintLangKey(PreviewContext context)
      The translation key for a hint that tells the user how to enter compact preview mode.
      Parameters:
      context - The preview context.
      Returns:
      The text to be displayed for the compact preview mode.
      Since:
      2.0.0
    • getFullTooltipHintLangKey

      default String getFullTooltipHintLangKey(PreviewContext context)
      The translation key for a hint that tells the user how to enter full preview mode.
      Parameters:
      context - The preview context.
      Returns:
      The text to be displayed for the full preview mode.
      Since:
      2.0.0
    • getLockKeyTooltipHintLangKey

      default String getLockKeyTooltipHintLangKey(PreviewContext context)
      The translation key for a hint that tells the user how to lock the tooltip window.
      Parameters:
      context - The preview context.
      Returns:
      The text to be displayed for the lock tooltip hint.
      Since:
      3.4.0
    • getWindowColorKey

      @Environment(CLIENT) default ColorKey getWindowColorKey(PreviewContext context)
      Which color the preview window should be in?
      Parameters:
      context - The preview context.
      Returns:
      The desired ColorKey instance.
      Since:
      3.2.0
    • getRenderer

      @Environment(CLIENT) default PreviewRenderer getRenderer()
      Get the renderer to use for this type of preview.
      Returns:
      A PreviewRenderer instance.
      Since:
      1.3.0
    • addTooltip

      default List<net.minecraft.network.chat.Component> addTooltip(PreviewContext context)
      Adds lines the stack tooltip. Returned lines are added only if tooltip type is set to MODDED in the config.
      Parameters:
      context - The preview context.
      Returns:
      A list of Text components. If empty, no text will be added to the tooltip.
      Since:
      2.0.0
    • onInventoryAccessStart

      @Environment(CLIENT) default void onInventoryAccessStart(PreviewContext context)
      This method should be called every time the inventory of the stack starts being accessed (i.e. by hovering it).
      Parameters:
      context - The preview context.
      Since:
      2.0.0
    • getTextureOverride

      @Nullable @Environment(CLIENT) default net.minecraft.resources.ResourceLocation getTextureOverride(PreviewContext context)
      Overrides the texture used to display the preview window.
      Parameters:
      context - The preview context.
      Returns:
      The texture path, or null for the default texture.
      Since:
      2.2.0
    • getPriority

      default int getPriority()
      Priority of this preview provider, relative to other providers targeting the same item. The provider that returns the highest number will be chosen, in case the priorities are equal, the provider will be chosen arbitrarily chosen.
      Returns:
      The priority of this preview provider.
      Since:
      2.3.0