Interface PreviewProviderRegistry


@NonExtendable public interface PreviewProviderRegistry
Provides a way to register preview providers for items and a way to access them.
Since:
3.0.0
  • Method Details

    • getInstance

      @Nonnull static PreviewProviderRegistry getInstance()
      Gets the preview provider registry instance.
      Returns:
      The registry instance.
      Since:
      3.0.0
    • register

      void register(net.minecraft.resources.ResourceLocation id, PreviewProvider provider, Iterable<net.minecraft.world.item.Item> items)
      Registers a PreviewProvider. New preview providers can only be registered inside the ShulkerBoxTooltipApi.registerProviders(PreviewProviderRegistry) method.
      Parameters:
      id - The id of the preview provider.
      provider - The provider.
      items - The items for which this provider will work. When multiple providers are registered for the same item, the one with the highest priority is chosen.
      Since:
      3.0.0
    • register

      void register(net.minecraft.resources.ResourceLocation id, PreviewProvider provider, net.minecraft.world.item.Item... items)
      Registers a PreviewProvider. New preview providers can only be registered inside the ShulkerBoxTooltipApi.registerProviders(PreviewProviderRegistry) method.
      Parameters:
      id - The id of the preview provider.
      provider - The provider.
      items - The items for which this provider will work. When multiple providers are registered for the same item, the one with the highest priority is chosen.
      Since:
      3.0.0
    • get

      @Nullable PreviewProvider get(net.minecraft.resources.ResourceLocation id)
      Attempts to get the corresponding preview provider associated with the given item stack.
      Parameters:
      id - The id the provider was registered with.
      Returns:
      The associated provider, can be null.
      Since:
      3.0.0
    • get

      @Nullable PreviewProvider get(net.minecraft.world.item.ItemStack stack)
      Gets the associated provider for the given item stack.
      Parameters:
      stack - The target item stack.
      Returns:
      The associated provider, or null if the stack does not have a preview provider.
      Since:
      3.0.0
    • get

      @Nullable PreviewProvider get(net.minecraft.world.item.Item item)
      Gets the associated provider for the given item.
      Parameters:
      item - The target item.
      Returns:
      The associated provider, or null if the item does not have a preview provider.
      Since:
      3.0.0
    • getId

      @Nullable net.minecraft.resources.ResourceLocation getId(PreviewProvider provider)
      Attempts to get the corresponding identifier associated with the given preview provider.
      Parameters:
      provider - The preview provider
      Returns:
      The id of given provider, or null if it was not registered.
      Since:
      3.0.0
    • getItems

      @Nonnull Set<net.minecraft.world.item.Item> getItems(PreviewProvider provider)
      Returns the set of items the given PreviewProvider works with.

      The set of items may be smaller than the one given in register(ResourceLocation, PreviewProvider, Iterable) if the provider's priority was lower than other providers for each missing item.

      Parameters:
      provider - The preview provider
      Returns:
      The immutable set of items, will be empty if provider was not registered.
      Since:
      3.0.0
    • getProviders

      @Nonnull Set<PreviewProvider> getProviders()
      Gets the set of all registered preview providers.
      Returns:
      The set of all registered preview providers.
      Since:
      3.0.0
    • getIds

      @Nonnull Set<net.minecraft.resources.ResourceLocation> getIds()
      Gets the set of all the registered identifiers.
      Returns:
      the set of all registered ids.
      Since:
      3.0.0