Interface ShulkerBoxTooltipApi


public interface ShulkerBoxTooltipApi
Implement this interface and use this as your entrypoint.

Example plugin: register a preview for barrels

  public class MyModShulkerBoxTooltipPlugin implements ShulkerBoxTooltipApi {
    @Override
    public void registerProviders(PreviewProviderRegistry registry) {
      registry.register(new Identifier("mymod", "barrel_example"),
          new BlockEntityPreviewProvider(27, true), Items.BARREL);
    }
  }

Registering a plugin (on NeoForge):

ModLoadingContext.get().registerExtensionPoint(ShulkerBoxTooltipPlugin.class,
    () -> new ShulkerBoxTooltipPlugin(MyModShulkerBoxTooltipPlugin::new));

Registering a plugin (on Forge):

FMLJavaModLoadingContext context = // get instance from your mod's constructor
context.registerExtensionPoint(ShulkerBoxTooltipPlugin.class,
    () -> new ShulkerBoxTooltipPlugin(MyModShulkerBoxTooltipPlugin::new));

Registering a plugin (on Fabric): Inside the fabric.mod.json file, add:

{
  "entrypoints": {
    "shulkerboxtooltip": [
      "com.mymod.MyModShulkerBoxTooltipPlugin"
    ]
  }
}
Since:
1.3.0
  • Method Details

    • getPreviewProviderForStack

      @Nullable static PreviewProvider getPreviewProviderForStack(net.minecraft.world.item.ItemStack stack)
      Attempts to get the corresponding preview provider associated with the given item stack, ignoring data-driven overrides.
      Parameters:
      stack - The stack
      Returns:
      the associated PreviewProvider for the passed ItemStack
      Since:
      2.0.0
    • getPreviewProviderForStackWithOverrides

      @Nullable static PreviewProvider getPreviewProviderForStackWithOverrides(net.minecraft.world.item.ItemStack stack)
      Attempts to get the corresponding preview provider associated with the given item stack using data-driven overrides if available.
      Parameters:
      stack - The stack
      Returns:
      the associated PreviewProvider for the passed ItemStack.
      Since:
      4.2.0
    • isPreviewAvailable

      @Environment(CLIENT) static boolean isPreviewAvailable(PreviewContext context)
      (Client-only) Returns whether a preview is requested (see getCurrentPreviewType(boolean)) and a preview is available for the given context.
      Parameters:
      context - The preview context.
      Returns:
      true if the requested preview is available for display.
      Since:
      2.0.0
    • getProviderIfPreviewAvailable

      @Nullable @Environment(CLIENT) static PreviewProvider getProviderIfPreviewAvailable(PreviewContext context)
      (Client-only) Attempts to get the corresponding preview provider associated with the given item stack using data-driven overrides if available AND a preview is requested (see getCurrentPreviewType(boolean)) and a preview is available for the given context.

      Same behavior as calling isPreviewAvailable(PreviewContext) followed by getPreviewProviderForStackWithOverrides(ItemStack).

      Parameters:
      context - The preview context.
      Returns:
      the associated PreviewProvider if the requested preview is available for display, null otherwise.
      Since:
      5.4.0
    • getCurrentPreviewType

      @Environment(CLIENT) @Nonnull static PreviewType getCurrentPreviewType(boolean hasFullPreviewMode)
      (Client-only) Returns the currently requested preview type.

      The requested preview type depends on factors like whether the preview keys are pressed, or the preview is force-enabled through the config.

      Parameters:
      hasFullPreviewMode - Is the full preview mode available?
      Returns:
      The preview type
      Since:
      2.0.0
    • hasModAvailable

      static boolean hasModAvailable(net.minecraft.server.level.ServerPlayer player)
      Checks whether the given player has ShulkerBoxTooltip installed and enabled server integration.
      Parameters:
      player - The player.
      Returns:
      true if the player has the mod installed and server integration turned on.
      Since:
      2.0.0
    • registerColors

      @Environment(CLIENT) default void registerColors(ColorRegistry registry)
      (Client-only) Called on each entrypoint to register color keys and categories.

      While registering color keys is optional, it allows them to be customized be the users though the configuration screen/file.

      ShulkerBoxTooltip is guaranteed to always call this method on all plugins before calling registerProviders(PreviewProviderRegistry).

      Parameters:
      registry - The color registry instance.
      Since:
      3.2.0
    • registerProviders

      void registerProviders(PreviewProviderRegistry registry)
      Called on each entrypoint to register preview providers.
      Parameters:
      registry - The provider registry instance..
      Since:
      3.0.0