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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder for creatingPreviewContextinstances. -
Method Summary
Modifier and TypeMethodDescriptionstatic PreviewContext.Builderbuilder(net.minecraft.world.item.ItemStack stack) Creates a newPreviewContext.Builderinstance.config()static PreviewContextof(net.minecraft.world.item.ItemStack stack) Deprecated, for removal: This API element is subject to removal in a future version.static PreviewContextof(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.Usebuilder(ItemStack)instead.net.minecraft.world.entity.player.Playerowner()Gets the player associated with this context, or null if it does not exist.net.minecraft.core.HolderLookup.Providernet.minecraft.world.item.ItemStackstack()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.Usebuilder(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.Usebuilder(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 newPreviewContext.Builderinstance.This is the recommended way to create a
PreviewContextinstance as of 4.1.0.- Parameters:
stack- The stack to create the context with, may not be null.- Returns:
- a new
PreviewContext.Builderinstance. - 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
- 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
-
builder(ItemStack)instead.