Interface PreviewContext


public interface PreviewContext
Provides information for item previews, such as the item stack and player that owns the stack (if present).
Since:
2.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A builder for creating PreviewContext instances.
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(net.minecraft.world.item.ItemStack stack)
    Creates a new PreviewContext.Builder instance.
     
    of(net.minecraft.world.item.ItemStack stack)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use builder(ItemStack) instead.
    of(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player owner)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use builder(ItemStack) instead.
    net.minecraft.world.entity.player.Player
    Gets the player associated with this context, or null if it does not exist.
    net.minecraft.core.HolderLookup.Provider
     
    net.minecraft.world.item.ItemStack
    Gets the item stack associated with this context.
  • Method Details

    • of

      @Nonnull @Contract("_ -> new") @Deprecated(since="4.1.0", forRemoval=true) static PreviewContext of(net.minecraft.world.item.ItemStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use builder(ItemStack) instead.
      Creates a preview context with an item stack.
      Parameters:
      stack - The stack.
      Returns:
      The created preview context
      Since:
      2.0.0
    • of

      @Nonnull @Contract("_, _ -> new") @Deprecated(since="4.1.0", forRemoval=true) static PreviewContext of(net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.world.entity.player.Player owner)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use builder(ItemStack) instead.
      Creates a preview context with an item stack and an owner.
      Parameters:
      stack - The stack.
      owner - The owner, may be null.
      Returns:
      The created preview context
      Since:
      2.0.0
    • builder

      @Nonnull @Contract("_ -> new") static PreviewContext.Builder builder(net.minecraft.world.item.ItemStack stack)
      Creates a new PreviewContext.Builder instance.

      This is the recommended way to create a PreviewContext instance as of 4.1.0.

      Parameters:
      stack - The stack to create the context with, may not be null.
      Returns:
      a new PreviewContext.Builder instance.
      Since:
      4.1.0
    • stack

      @Nonnull net.minecraft.world.item.ItemStack stack()
      Gets the item stack associated with this context.
      Returns:
      The item stack.
      Since:
      3.1.0
    • owner

      @Nullable net.minecraft.world.entity.player.Player owner()
      Gets the player associated with this context, or null if it does not exist.
      Returns:
      The owner of this item stack, may be null.
      Since:
      3.1.0
    • config

      @Nonnull PreviewConfiguration config()
      Returns:
      the configuration in use for this context.
      Since:
      3.3.0
    • registryLookup

      @Nullable net.minecraft.core.HolderLookup.Provider registryLookup()
      Returns:
      the registry lookup for this context, if available.
      Since:
      4.1.0